plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 1 | /* |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 2 | * Copyright (c) International Business Machines Corp., 2001 |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 3 | * |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 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. |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 8 | * |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 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. |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 13 | * |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 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 |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | /* |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 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 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 28 | |
| 29 | #include "test.h" |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 30 | |
| 31 | #include <errno.h> |
| 32 | #include <sys/time.h> |
| 33 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 34 | char *TCID = "getitimer02"; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 35 | int TST_TOTAL = 1; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 36 | |
vapier | bdbacc9 | 2006-02-27 04:30:24 +0000 | [diff] [blame] | 37 | #if !defined(UCLINUX) |
| 38 | |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 39 | static void cleanup(void); |
| 40 | static void setup(void); |
vapier | bdbacc9 | 2006-02-27 04:30:24 +0000 | [diff] [blame] | 41 | |
robbiew | 12c4392 | 2003-03-26 19:40:11 +0000 | [diff] [blame] | 42 | int main(int ac, char **av) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 43 | { |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 44 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 45 | const char *msg; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 46 | |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 47 | msg = parse_opts(ac, av, NULL, NULL); |
| 48 | if (msg != NULL) |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 49 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 50 | |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 51 | setup(); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 52 | |
| 53 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 54 | tst_count = 0; |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 55 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 56 | /* call with a bad address */ |
| 57 | TEST(getitimer(ITIMER_REAL, (struct itimerval *)-1)); |
subrata_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 58 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 59 | 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_modak | bdbaec5 | 2009-02-26 12:14:51 +0000 | [diff] [blame] | 65 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 66 | 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 Cooper | 7d0a4a5 | 2010-12-16 10:05:08 -0800 | [diff] [blame] | 80 | tst_exit(); |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 81 | } |
| 82 | |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 83 | static void setup(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 84 | { |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 85 | tst_sig(NOFORK, DEF_HANDLER, cleanup); |
| 86 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 87 | TEST_PAUSE; |
| 88 | } |
| 89 | |
DAN LI | dc8c2f3 | 2013-04-25 11:04:48 +0800 | [diff] [blame] | 90 | static void cleanup(void) |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 91 | { |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 92 | } |
| 93 | |
vapier | bdbacc9 | 2006-02-27 04:30:24 +0000 | [diff] [blame] | 94 | #else |
| 95 | |
| 96 | int main(void) |
| 97 | { |
| 98 | tst_resm(TINFO, "test is not available on uClinux"); |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 99 | tst_exit(); |
vapier | bdbacc9 | 2006-02-27 04:30:24 +0000 | [diff] [blame] | 100 | } |
| 101 | |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 102 | #endif /* if !defined(UCLINUX) */ |