blob: 6cc48870cd8fbf23a0427dabbf45c5ef9d745bab [file] [log] [blame]
plars865695b2001-08-27 22:15:12 +00001/*
DAN LIdc8c2f32013-04-25 11:04:48 +08002 * Copyright (c) International Business Machines Corp., 2001
plars865695b2001-08-27 22:15:12 +00003 *
DAN LIdc8c2f32013-04-25 11:04:48 +08004 * 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.
plars865695b2001-08-27 22:15:12 +00008 *
DAN LIdc8c2f32013-04-25 11:04:48 +08009 * 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.
plars865695b2001-08-27 22:15:12 +000013 *
DAN LIdc8c2f32013-04-25 11:04:48 +080014 * 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
plars865695b2001-08-27 22:15:12 +000017 */
18
19/*
DAN LIdc8c2f32013-04-25 11:04:48 +080020 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
plars865695b2001-08-27 22:15:12 +000028
29#include "test.h"
plars865695b2001-08-27 22:15:12 +000030
31#include <errno.h>
32#include <sys/time.h>
33
subrata_modak56207ce2009-03-23 13:35:39 +000034char *TCID = "getitimer02";
plars865695b2001-08-27 22:15:12 +000035int TST_TOTAL = 1;
plars865695b2001-08-27 22:15:12 +000036
vapierbdbacc92006-02-27 04:30:24 +000037#if !defined(UCLINUX)
38
DAN LIdc8c2f32013-04-25 11:04:48 +080039static void cleanup(void);
40static void setup(void);
vapierbdbacc92006-02-27 04:30:24 +000041
robbiew12c43922003-03-26 19:40:11 +000042int main(int ac, char **av)
plars865695b2001-08-27 22:15:12 +000043{
Cyril Hrubis89af32a2012-10-24 16:39:11 +020044 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020045 const char *msg;
plars865695b2001-08-27 22:15:12 +000046
DAN LIdc8c2f32013-04-25 11:04:48 +080047 msg = parse_opts(ac, av, NULL, NULL);
48 if (msg != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -080049 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
plars865695b2001-08-27 22:15:12 +000050
DAN LIdc8c2f32013-04-25 11:04:48 +080051 setup();
plars865695b2001-08-27 22:15:12 +000052
53 for (lc = 0; TEST_LOOPING(lc); lc++) {
Caspar Zhangd59a6592013-03-07 14:59:12 +080054 tst_count = 0;
plars865695b2001-08-27 22:15:12 +000055
plars865695b2001-08-27 22:15:12 +000056 /* call with a bad address */
57 TEST(getitimer(ITIMER_REAL, (struct itimerval *)-1));
subrata_modakbdbaec52009-02-26 12:14:51 +000058
plars865695b2001-08-27 22:15:12 +000059 if (TEST_RETURN == 0) {
60 tst_resm(TFAIL, "call failed to produce "
61 "expected error - errno = %d - %s",
62 TEST_ERRNO, strerror(TEST_ERRNO));
63 continue;
64 }
subrata_modakbdbaec52009-02-26 12:14:51 +000065
plars865695b2001-08-27 22:15:12 +000066 switch (TEST_ERRNO) {
67 case EFAULT:
68 tst_resm(TPASS, "expected failure - errno = %d - %s",
69 TEST_ERRNO, strerror(TEST_ERRNO));
70 break;
71 default:
72 tst_resm(TFAIL, "call failed to produce "
73 "expected error - errno = %d - %s",
74 TEST_ERRNO, strerror(TEST_ERRNO));
75 }
76 }
77
78 cleanup();
79
Garrett Cooper7d0a4a52010-12-16 10:05:08 -080080 tst_exit();
plars865695b2001-08-27 22:15:12 +000081}
82
DAN LIdc8c2f32013-04-25 11:04:48 +080083static void setup(void)
plars865695b2001-08-27 22:15:12 +000084{
plars865695b2001-08-27 22:15:12 +000085 tst_sig(NOFORK, DEF_HANDLER, cleanup);
86
plars865695b2001-08-27 22:15:12 +000087 TEST_PAUSE;
88}
89
DAN LIdc8c2f32013-04-25 11:04:48 +080090static void cleanup(void)
plars865695b2001-08-27 22:15:12 +000091{
plars865695b2001-08-27 22:15:12 +000092}
93
vapierbdbacc92006-02-27 04:30:24 +000094#else
95
96int main(void)
97{
98 tst_resm(TINFO, "test is not available on uClinux");
Garrett Cooper2c282152010-12-16 00:55:50 -080099 tst_exit();
vapierbdbacc92006-02-27 04:30:24 +0000100}
101
Chris Dearmanec6edca2012-10-17 19:54:01 -0700102#endif /* if !defined(UCLINUX) */