• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) International Business Machines  Corp., 2001
3  *
4  * This program is free software;  you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY;  without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
12  * the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program;  if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /*
20   HISTORY
21   03/2001 - Written by Wayne Boyer
22 
23   TEST ITEMS:
24   Check that a getitimer() call fails as expected
25   with an incorrect second argument.
26 */
27 
28 
29 #include "test.h"
30 
31 #include <errno.h>
32 #include <sys/time.h>
33 
34 char *TCID = "getitimer02";
35 int TST_TOTAL = 1;
36 
37 #if !defined(UCLINUX)
38 
39 static void cleanup(void);
40 static void setup(void);
41 
main(int ac,char ** av)42 int main(int ac, char **av)
43 {
44 	int lc;
45 
46 	tst_parse_opts(ac, av, NULL, NULL);
47 
48 	setup();
49 
50 	for (lc = 0; TEST_LOOPING(lc); lc++) {
51 		tst_count = 0;
52 
53 		/* call with a bad address */
54 		TEST(getitimer(ITIMER_REAL, (struct itimerval *)-1));
55 
56 		if (TEST_RETURN == 0) {
57 			tst_resm(TFAIL, "call failed to produce "
58 				 "expected error - errno = %d - %s",
59 				 TEST_ERRNO, strerror(TEST_ERRNO));
60 			continue;
61 		}
62 
63 		switch (TEST_ERRNO) {
64 		case EFAULT:
65 			tst_resm(TPASS, "expected failure - errno = %d - %s",
66 				 TEST_ERRNO, strerror(TEST_ERRNO));
67 			break;
68 		default:
69 			tst_resm(TFAIL, "call failed to produce "
70 				 "expected error - errno = %d - %s",
71 				 TEST_ERRNO, strerror(TEST_ERRNO));
72 		}
73 	}
74 
75 	cleanup();
76 
77 	tst_exit();
78 }
79 
setup(void)80 static void setup(void)
81 {
82 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
83 
84 	TEST_PAUSE;
85 }
86 
cleanup(void)87 static void cleanup(void)
88 {
89 }
90 
91 #else
92 
main(void)93 int main(void)
94 {
95 	tst_resm(TINFO, "test is not available on uClinux");
96 	tst_exit();
97 }
98 
99 #endif /* if !defined(UCLINUX) */
100