Changeset 481f882 for tests/configs/parsenums.cfa
- Timestamp:
- Oct 12, 2022, 4:32:49 PM (20 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 38cc59f
- Parents:
- a51b8f6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/configs/parsenums.cfa
ra51b8f6 r481f882 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 } 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 // 13 16 14 17 #include <parseargs.hfa> 15 18 #include <fstream.hfa> 19 20 #include "../meta/fork+exec.hfa" 16 21 17 22 #if __SIZEOF_LONG__ == 4 … … 28 33 29 34 int main(int argc, char * argv[]) { 30 if(!getenv("CFATEST_FORK_EXEC_TEXT")) return true_main(argv[0]);35 check_main(argv[0]); 31 36 32 37 int i = -3; … … 56 61 } 57 62 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 63 int true_main(const char * path, char * env[]) { 95 64 printf("no arg:\n"); 96 65 if(pid_t child = strict_fork(); child == 0) { … … 105 74 print_status(status); 106 75 } 107 printf("\n");108 76 109 77 printf("all 0 arg:\n"); … … 119 87 print_status(status); 120 88 } 121 printf("\n");122 89 123 90 printf("negative vals arg:\n"); … … 133 100 print_status(status); 134 101 } 135 printf("\n");136 102 137 103 printf("funky notation arg:\n"); … … 147 113 print_status(status); 148 114 } 149 printf("\n");150 115 151 116 printf("big values arg:\n"); … … 161 126 print_status(status); 162 127 } 163 printf("\n");164 128 165 129 printf("too big values arg:\n"); … … 175 139 print_status(status); 176 140 } 177 printf("\n");178 141 179 142 if(pid_t child = strict_fork(); child == 0) { … … 188 151 print_status(status); 189 152 } 190 printf("\n");191 153 192 154 if(pid_t child = strict_fork(); child == 0) { … … 201 163 print_status(status); 202 164 } 203 printf("\n");204 165 205 166 if(pid_t child = strict_fork(); child == 0) { … … 214 175 print_status(status); 215 176 } 216 printf("\n");217 177 218 178 printf("negative errors arg:\n"); … … 228 188 print_status(status); 229 189 } 230 printf("\n");231 190 232 191 if(pid_t child = strict_fork(); child == 0) { … … 241 200 print_status(status); 242 201 } 243 printf("\n");244 202 245 203 if(pid_t child = strict_fork(); child == 0) { … … 254 212 print_status(status); 255 213 } 256 printf("\n");257 214 258 215 printf("All Done!\n");
Note: See TracChangeset
for help on using the changeset viewer.