Home | History | Annotate | Download | only in sbrk
      1 /*
      2  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
      3  *  AUTHOR		: William Roske
      4  *  CO-PILOT		: Dave Fenner
      5  *
      6  * This program is free software; you can redistribute it and/or modify it
      7  * under the terms of version 2 of the GNU General Public License as
      8  * published by the Free Software Foundation.
      9  *
     10  * This program is distributed in the hope that it would be useful, but
     11  * WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     13  *
     14  * Further, this software is distributed without any warranty that it is
     15  * free of the rightful claim of any third person regarding infringement
     16  * or the like.  Any license provided herein, whether implied or
     17  * otherwise, applies only to this software file.  Patent licenses, if
     18  * any, provided herein do not apply to combinations of this program with
     19  * other software, or any other product whatsoever.
     20  *
     21  * You should have received a copy of the GNU General Public License along
     22  * with this program; if not, write the Free Software Foundation, Inc.,
     23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
     24  *
     25  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
     26  * Mountain View, CA  94043, or:
     27  *
     28  * http://www.sgi.com
     29  *
     30  * For further information regarding this notice, see:
     31  *
     32  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
     33  *
     34  */
     35 /*
     36  * DESCRIPTION
     37  *	1.) test sbrk(8192) should return successfully.
     38  *	2.) test sbrk(-8192) should return successfully.
     39  */
     40 
     41 #include <unistd.h>
     42 #include <errno.h>
     43 #include <string.h>
     44 #include <signal.h>
     45 #include <sys/types.h>
     46 
     47 #include "test.h"
     48 
     49 char *TCID = "sbrk01";
     50 
     51 static struct test_case_t {
     52 	long increment;
     53 } test_cases[] = {
     54 	{8192},
     55 	{-8192},
     56 };
     57 
     58 static void setup(void);
     59 static void sbrk_verify(const struct test_case_t *);
     60 static void cleanup(void);
     61 
     62 int TST_TOTAL = ARRAY_SIZE(test_cases);
     63 
     64 int main(int ac, char **av)
     65 {
     66 	int lc;
     67 	int i;
     68 
     69 	tst_parse_opts(ac, av, NULL, NULL);
     70 
     71 	setup();
     72 
     73 	for (lc = 0; TEST_LOOPING(lc); lc++) {
     74 
     75 		tst_count = 0;
     76 
     77 		for (i = 0; i < TST_TOTAL; i++)
     78 			sbrk_verify(&test_cases[i]);
     79 	}
     80 
     81 	cleanup();
     82 	tst_exit();
     83 
     84 }
     85 
     86 static void setup(void)
     87 {
     88 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
     89 
     90 	TEST_PAUSE;
     91 }
     92 
     93 static void sbrk_verify(const struct test_case_t *test)
     94 {
     95 	void *tret;
     96 
     97 	tret = sbrk(test->increment);
     98 	TEST_ERRNO = errno;
     99 
    100 	if (tret == (void *)-1) {
    101 		tst_resm(TFAIL | TTERRNO, "sbrk - Increase by %ld bytes failed",
    102 			 test->increment);
    103 	} else {
    104 		tst_resm(TPASS, "sbrk - Increase by %ld bytes returned %p",
    105 			 test->increment, tret);
    106 	}
    107 }
    108 
    109 static void cleanup(void)
    110 {
    111 }
    112