1 /* 2 * Copyright (c) 2014 Fujitsu Ltd. 3 * Author: Zeng Linggang <zenglg.jy (at) cn.fujitsu.com> 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of version 2 of the GNU General Public License as 7 * published by the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it would be useful, but 10 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 * 13 * You should have received a copy of the GNU General Public License along 14 * with this program; if not, write the Free Software Foundation, Inc., 15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 */ 17 /* 18 * Test Description: 19 * Verify that, 20 * The calling process does not have any unwaited-for children, 21 * ECHILD would return. 22 */ 23 24 #include <errno.h> 25 #include <sys/types.h> 26 #include <sys/wait.h> 27 28 #include "test.h" 29 30 char *TCID = "wait01"; 31 int TST_TOTAL = 1; 32 static void setup(void); 33 static void wait_verify(void); 34 static void cleanup(void); 35 36 int main(int argc, char **argv) 37 { 38 int lc; 39 40 tst_parse_opts(argc, argv, NULL, NULL); 41 42 setup(); 43 44 for (lc = 0; TEST_LOOPING(lc); lc++) { 45 tst_count = 0; 46 wait_verify(); 47 } 48 49 cleanup(); 50 tst_exit(); 51 } 52 53 static void setup(void) 54 { 55 tst_sig(NOFORK, DEF_HANDLER, cleanup); 56 57 TEST_PAUSE; 58 } 59 60 static void wait_verify(void) 61 { 62 TEST(wait(NULL)); 63 64 if (TEST_RETURN != -1) { 65 tst_resm(TFAIL | TTERRNO, "wait failed unexpectedly: %ld", 66 TEST_RETURN); 67 return; 68 } 69 70 if (TEST_ERRNO == ECHILD) { 71 tst_resm(TPASS | TTERRNO, "wait failed as expected"); 72 } else { 73 tst_resm(TFAIL | TTERRNO, 74 "wait failed unexpectedly; expected: %d - %s", 75 ECHILD, strerror(ECHILD)); 76 } 77 } 78 79 static void cleanup(void) 80 { 81 } 82