Changes in tests/configs/parsenums.cfa [481f882:a46f7b6]
- File:
-
- 1 edited
-
tests/configs/parsenums.cfa (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/configs/parsenums.cfa
r481f882 ra46f7b6 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2022 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // configs/parsenums.cfa 8 // Testing parsing of integer arguments 9 // 10 // Author : Thierry Delisle 11 // Created On : Wed Oct 12 15:28:01 2022 12 // Last Modified By : 13 // Last Modified On : 14 // Update Count : 15 // 1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <string.h> 4 5 #include <errno.h> 6 #include <signal.h> 7 8 extern "C" { 9 #include <sys/types.h> 10 #include <sys/wait.h> 11 #include <unistd.h> 12 } 16 13 17 14 #include <parseargs.hfa> 18 15 #include <fstream.hfa> 19 20 #include "../meta/fork+exec.hfa"21 16 22 17 #if __SIZEOF_LONG__ == 4 … … 33 28 34 29 int main(int argc, char * argv[]) { 35 check_main(argv[0]);30 if(!getenv("CFATEST_FORK_EXEC_TEXT")) return true_main(argv[0]); 36 31 37 32 int i = -3; … … 61 56 } 62 57 63 int true_main(const char * path, char * env[]) { 58 int do_wait(pid_t pid) { 59 int wstatus; 60 int options = 0; 61 pid_t ret = waitpid(pid, &wstatus, options); 62 fflush(stdout); 63 if(ret < 0) { 64 fprintf(stderr, "Fork returned with error: %d '%s'\n", errno, strerror(errno)); 65 exit(1); 66 } 67 return wstatus; 68 } 69 70 pid_t strict_fork(void) { 71 fflush(stdout); 72 pid_t ret = fork(); 73 if(ret < 0) { 74 fprintf(stderr, "Fork returned with error: %d '%s'\n", errno, strerror(errno)); 75 exit(1); 76 } 77 return ret; 78 } 79 80 void print_status(int wstatus) { 81 printf("Child status:\n"); 82 printf(" WIFEXITED : %d", WIFEXITED(wstatus)); 83 printf(" WEXITSTATUS : %d", WEXITSTATUS(wstatus)); 84 printf(" WIFSIGNALED : %d", WIFSIGNALED(wstatus)); 85 printf(" WTERMSIG : %d", WTERMSIG(wstatus)); 86 printf(" WCOREDUMP : %d", WCOREDUMP(wstatus)); 87 printf(" WIFSTOPPED : %d", WIFSTOPPED(wstatus)); 88 printf(" WSTOPSIG : %d", WSTOPSIG(wstatus)); 89 printf(" WIFCONTINUED: %d\n", WIFCONTINUED(wstatus)); 90 } 91 92 int true_main(const char * path) { 93 char * env[] = { "CFATEST_FORK_EXEC_TEXT=1", 0p }; 94 64 95 printf("no arg:\n"); 65 96 if(pid_t child = strict_fork(); child == 0) { … … 74 105 print_status(status); 75 106 } 107 printf("\n"); 76 108 77 109 printf("all 0 arg:\n"); … … 87 119 print_status(status); 88 120 } 121 printf("\n"); 89 122 90 123 printf("negative vals arg:\n"); … … 100 133 print_status(status); 101 134 } 135 printf("\n"); 102 136 103 137 printf("funky notation arg:\n"); … … 113 147 print_status(status); 114 148 } 149 printf("\n"); 115 150 116 151 printf("big values arg:\n"); … … 126 161 print_status(status); 127 162 } 163 printf("\n"); 128 164 129 165 printf("too big values arg:\n"); … … 139 175 print_status(status); 140 176 } 177 printf("\n"); 141 178 142 179 if(pid_t child = strict_fork(); child == 0) { … … 151 188 print_status(status); 152 189 } 190 printf("\n"); 153 191 154 192 if(pid_t child = strict_fork(); child == 0) { … … 163 201 print_status(status); 164 202 } 203 printf("\n"); 165 204 166 205 if(pid_t child = strict_fork(); child == 0) { … … 175 214 print_status(status); 176 215 } 216 printf("\n"); 177 217 178 218 printf("negative errors arg:\n"); … … 188 228 print_status(status); 189 229 } 230 printf("\n"); 190 231 191 232 if(pid_t child = strict_fork(); child == 0) { … … 200 241 print_status(status); 201 242 } 243 printf("\n"); 202 244 203 245 if(pid_t child = strict_fork(); child == 0) { … … 212 254 print_status(status); 213 255 } 256 printf("\n"); 214 257 215 258 printf("All Done!\n");
Note:
See TracChangeset
for help on using the changeset viewer.