Changes in / [4af5396:a25bcf8]
- Files:
-
- 2 deleted
- 10 edited
-
libcfa/src/parseargs.cfa (modified) (2 diffs)
-
libcfa/src/parseargs.hfa (modified) (1 diff)
-
tests/configs/.expect/parsebools.txt (modified) (7 diffs)
-
tests/configs/.expect/parsenums.x64.txt (modified) (12 diffs)
-
tests/configs/.expect/parsenums.x86.txt (modified) (12 diffs)
-
tests/configs/.expect/usage.txt (deleted)
-
tests/configs/parsebools.cfa (modified) (9 diffs)
-
tests/configs/parsenums.cfa (modified) (15 diffs)
-
tests/configs/usage.cfa (deleted)
-
tests/meta/.expect/fork+exec.txt (modified) (3 diffs)
-
tests/meta/fork+exec.hfa (modified) (2 diffs)
-
tests/test.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/parseargs.cfa
r4af5396 ra25bcf8 1 //2 // Cforall Version 1.0.0 Copyright (C) 2022 University of Waterloo3 //4 // The contents of this file are covered under the licence agreement in the5 // file "LICENCE" distributed with Cforall.6 //7 // parseargs.cfa8 // implementation of arguments parsing (argc, argv)9 //10 // Author : Thierry Delisle11 // Created On : Wed Oct 12 15:28:01 202212 // Last Modified By :13 // Last Modified On :14 // Update Count :15 //16 17 1 #include "parseargs.hfa" 18 2 19 #include <assert.h>20 3 #include <ctype.h> 21 4 #include <stdint.h> … … 163 146 } 164 147 165 static inline int next_newline(const char * str) {166 int ret;167 const char * ptr = strstr(str, "\n");168 if(!ptr) return MAX;169 170 /* paranoid */ verify( str <= ptr);171 intptr_t low = (intptr_t)str;172 intptr_t hi = (intptr_t)ptr;173 ret = hi - low;174 175 return ret;176 }177 178 148 //----------------------------------------------------------------------------- 179 149 // Print usage 180 150 static void printopt(FILE * out, int width, int max, char sn, const char * ln, const char * help) { 181 // check how wide we should be printing182 // this includes all options and the help message183 151 int hwidth = max - (11 + width); 184 152 if(hwidth <= 0) hwidth = max; 185 153 186 // check which pieces we have 187 bool has_ln = ln && strcmp("", ln); 188 bool has_help = help && strcmp("", help); 189 190 // print the small name if present 191 if(sn != '\0') fprintf(out, " -%c", sn); 192 else fprintf(out, " "); 193 194 // print a comma if we have both short and long names 195 if(sn != '\0' && has_ln) fprintf(out, ", "); 196 else fprintf(out, " "); 197 198 // print the long name if present 199 if(has_ln) fprintf(out, "--%-*s", width, ln); 200 else if(has_help) fprintf(out, " %-*s", width, ""); 201 202 if(has_help) { 203 // print the help 204 // We need to wrap at the max width, and also indent newlines so everything is nice and pretty 205 206 // for each line to print 207 for() { 208 //find out if there is a newline 209 int nextnl = next_newline(help); 210 int real = min(min(strlen(help), hwidth), nextnl); 211 212 fprintf(out, " %.*s", real, help); 213 // printf("%d %d\n", real, nextnl); 214 help += real; 215 if( nextnl == real ) help++; 216 if('\0' == *help) break; 217 fprintf(out, "\n%*s", width + 8, ""); 218 } 219 } 220 fprintf(out, "\n"); 154 char sname[4] = { ' ', ' ', ' ', '\0' }; 155 if(sn != '\0') { 156 sname[0] = '-'; 157 sname[1] = sn; 158 sname[2] = ','; 159 } 160 161 fprintf(out, " %s --%-*s %.*s\n", sname, width, ln, hwidth, help); 162 for() { 163 help += min(strlen(help), hwidth); 164 if('\0' == *help) break; 165 fprintf(out, "%*s%.*s\n", width + 11, "", hwidth, help); 166 } 221 167 } 222 168 -
libcfa/src/parseargs.hfa
r4af5396 ra25bcf8 1 //2 // Cforall Version 1.0.0 Copyright (C) 2022 University of Waterloo3 //4 // The contents of this file are covered under the licence agreement in the5 // file "LICENCE" distributed with Cforall.6 //7 // parseargs.cfa -- PUBLIC8 // API for arguments parsing (argc, argv)9 //10 // Author : Thierry Delisle11 // Created On : Wed Oct 12 15:28:01 202212 // Last Modified By :13 // Last Modified On :14 // Update Count :15 //16 1 #pragma once 17 2 -
tests/configs/.expect/parsebools.txt
r4af5396 ra25bcf8 7 7 set false :true 8 8 Child status: 9 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 09 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 10 10 11 11 all true/set arg: … … 17 17 set false :false 18 18 Child status: 19 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 019 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 20 20 21 21 all false/unset arg: … … 27 27 set false :true 28 28 Child status: 29 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 029 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 30 30 31 31 gibberish arg 1: … … 43 43 -h, --help print this help message 44 44 Child status: 45 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 045 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 46 46 47 47 gibberish arg 2: … … 59 59 -h, --help print this help message 60 60 Child status: 61 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 061 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 62 62 63 63 gibberish arg 3: … … 74 74 -h, --help print this help message 75 75 Child status: 76 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 076 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 77 77 78 78 gibberish arg 4: … … 89 89 -h, --help print this help message 90 90 Child status: 91 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 091 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 92 92 93 93 All Done! -
tests/configs/.expect/parsenums.x64.txt
r4af5396 ra25bcf8 6 6 double :3.3 7 7 Child status: 8 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 08 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 9 9 10 10 all 0 arg: … … 15 15 double :0. 16 16 Child status: 17 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 017 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 18 18 19 19 negative vals arg: … … 24 24 double :-1. 25 25 Child status: 26 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 026 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 27 27 28 28 funky notation arg: … … 33 33 double :5000000. 34 34 Child status: 35 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 035 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 36 36 37 37 big values arg: … … 42 42 double :5000000. 43 43 Child status: 44 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 044 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 45 45 46 46 too big values arg: … … 57 57 -h, --help print this help message 58 58 Child status: 59 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 059 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 60 60 61 61 Argument '4294967296' for option u could not be parsed … … 71 71 -h, --help print this help message 72 72 Child status: 73 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 073 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 74 74 75 75 Argument '18446744073709551616' for option l could not be parsed … … 85 85 -h, --help print this help message 86 86 Child status: 87 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 087 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 88 88 89 89 Argument '18446744073709551616' for option L could not be parsed … … 99 99 -h, --help print this help message 100 100 Child status: 101 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 0101 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 102 102 103 103 negative errors arg: … … 114 114 -h, --help print this help message 115 115 Child status: 116 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 0116 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 117 117 118 118 Argument '-1' for option l could not be parsed … … 128 128 -h, --help print this help message 129 129 Child status: 130 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 0130 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 131 131 132 132 Argument '-1' for option L could not be parsed … … 142 142 -h, --help print this help message 143 143 Child status: 144 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 0144 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 145 145 146 146 All Done! -
tests/configs/.expect/parsenums.x86.txt
r4af5396 ra25bcf8 6 6 double :3.3 7 7 Child status: 8 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 08 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 9 9 10 10 all 0 arg: … … 15 15 double :0. 16 16 Child status: 17 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 017 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 18 18 19 19 negative vals arg: … … 24 24 double :-1. 25 25 Child status: 26 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 026 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 27 27 28 28 funky notation arg: … … 33 33 double :5000000. 34 34 Child status: 35 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 035 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 36 36 37 37 big values arg: … … 42 42 double :5000000. 43 43 Child status: 44 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0,IFCONTINUED: 044 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 0 45 45 46 46 too big values arg: … … 57 57 -h, --help print this help message 58 58 Child status: 59 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 059 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 60 60 61 61 Argument '4294967296' for option u could not be parsed … … 71 71 -h, --help print this help message 72 72 Child status: 73 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 073 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 74 74 75 75 Argument '4294967296' for option l could not be parsed … … 85 85 -h, --help print this help message 86 86 Child status: 87 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 087 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 88 88 89 89 Argument '18446744073709551616' for option L could not be parsed … … 99 99 -h, --help print this help message 100 100 Child status: 101 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 0101 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 102 102 103 103 negative errors arg: … … 114 114 -h, --help print this help message 115 115 Child status: 116 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 0116 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 117 117 118 118 Argument '-1' for option l could not be parsed … … 128 128 -h, --help print this help message 129 129 Child status: 130 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 0130 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 131 131 132 132 Argument '-1' for option L could not be parsed … … 142 142 -h, --help print this help message 143 143 Child status: 144 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1,IFCONTINUED: 0144 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0 145 145 146 146 All Done! -
tests/configs/parsebools.cfa
r4af5396 ra25bcf8 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/parsebools.cfa 8 // Testing parsing of boolean 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 16 20 #include "../meta/fork+exec.hfa" 17 int true_main(const char * exec); 21 18 22 19 int main(int argc, char * argv[]) { 23 check_main(argv[0]);20 if(!getenv("CFATEST_FORK_EXEC_TEXT")) return true_main(argv[0]); 24 21 25 22 bool YN = false; … … 51 48 } 52 49 53 int true_main(const char * path, char * env[]) { 50 int do_wait(pid_t pid) { 51 int wstatus; 52 int options = 0; 53 pid_t ret = waitpid(pid, &wstatus, options); 54 fflush(stdout); 55 if(ret < 0) { 56 fprintf(stderr, "Fork returned with error: %d '%s'\n", errno, strerror(errno)); 57 exit(1); 58 } 59 return wstatus; 60 } 61 62 pid_t strict_fork(void) { 63 fflush(stdout); 64 pid_t ret = fork(); 65 if(ret < 0) { 66 fprintf(stderr, "Fork returned with error: %d '%s'\n", errno, strerror(errno)); 67 exit(1); 68 } 69 return ret; 70 } 71 72 void print_status(int wstatus) { 73 printf("Child status:\n"); 74 printf(" WIFEXITED : %d", WIFEXITED(wstatus)); 75 printf(" WEXITSTATUS : %d", WEXITSTATUS(wstatus)); 76 printf(" WIFSIGNALED : %d", WIFSIGNALED(wstatus)); 77 printf(" WTERMSIG : %d", WTERMSIG(wstatus)); 78 printf(" WCOREDUMP : %d", WCOREDUMP(wstatus)); 79 printf(" WIFSTOPPED : %d", WIFSTOPPED(wstatus)); 80 printf(" WSTOPSIG : %d", WSTOPSIG(wstatus)); 81 printf(" WIFCONTINUED: %d\n", WIFCONTINUED(wstatus)); 82 } 83 84 int true_main(const char * path) { 85 char * env[] = { "CFATEST_FORK_EXEC_TEXT=1", 0p }; 86 54 87 printf("no arg:\n"); 55 88 if(pid_t child = strict_fork(); child == 0) { … … 64 97 print_status(status); 65 98 } 99 printf("\n"); 66 100 67 101 printf("all true/set arg:\n"); … … 77 111 print_status(status); 78 112 } 113 printf("\n"); 79 114 80 115 printf("all false/unset arg:\n"); … … 90 125 print_status(status); 91 126 } 127 printf("\n"); 92 128 93 129 printf("gibberish arg 1:\n"); … … 103 139 print_status(status); 104 140 } 141 printf("\n"); 105 142 106 143 printf("gibberish arg 2:\n"); … … 116 153 print_status(status); 117 154 } 155 printf("\n"); 118 156 119 157 printf("gibberish arg 3:\n"); … … 129 167 print_status(status); 130 168 } 169 printf("\n"); 131 170 132 171 printf("gibberish arg 4:\n"); … … 142 181 print_status(status); 143 182 } 183 printf("\n"); 144 184 145 185 printf("All Done!\n"); -
tests/configs/parsenums.cfa
r4af5396 ra25bcf8 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"); -
tests/meta/.expect/fork+exec.txt
r4af5396 ra25bcf8 4 4 Success! 5 5 Child status: 6 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 7 6 WIFEXITED : 1 7 WEXITSTATUS : 0 8 WIFSIGNALED : 0 9 WTERMSIG : 0 10 WCOREDUMP : 0 11 WIFSTOPPED : 0 12 WSTOPSIG : 0 13 WIFCONTINUED: 0 8 14 1 arg: 9 15 arguments are: … … 11 17 Success! 12 18 Child status: 13 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 14 19 WIFEXITED : 1 20 WEXITSTATUS : 0 21 WIFSIGNALED : 0 22 WTERMSIG : 0 23 WCOREDUMP : 0 24 WIFSTOPPED : 0 25 WSTOPSIG : 0 26 WIFCONTINUED: 0 15 27 5 arg: 16 28 arguments are: … … 22 34 Success! 23 35 Child status: 24 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 25 36 WIFEXITED : 1 37 WEXITSTATUS : 0 38 WIFSIGNALED : 0 39 WTERMSIG : 0 40 WCOREDUMP : 0 41 WIFSTOPPED : 0 42 WSTOPSIG : 0 43 WIFCONTINUED: 0 26 44 All Done! -
tests/meta/fork+exec.hfa
r4af5396 ra25bcf8 28 28 } 29 29 30 static int true_main(const char * path, char * env[]);30 static int true_main(const char * exec, char * env[]); 31 31 32 32 static int do_wait(pid_t pid) { … … 55 55 static void print_status(int wstatus) { 56 56 printf("Child status:\n"); 57 printf("IFEXITED : %d, ", WIFEXITED(wstatus)); 58 printf("EXITSTATUS : %d, ", WEXITSTATUS(wstatus)); 59 printf("IFSIGNALED : %d, ", WIFSIGNALED(wstatus)); 60 printf("TERMSIG : %d, ", WTERMSIG(wstatus)); 61 printf("COREDUMP : %d, ", WCOREDUMP(wstatus)); 62 printf("IFSTOPPED : %d, ", WIFSTOPPED(wstatus)); 63 printf("STOPSIG : %d, ", WSTOPSIG(wstatus)); 64 printf("IFCONTINUED: %d", WIFCONTINUED(wstatus)); 65 printf("\n"); 66 printf("\n"); 57 printf(" WIFEXITED : %d\n", WIFEXITED(wstatus)); 58 printf(" WEXITSTATUS : %d\n", WEXITSTATUS(wstatus)); 59 printf(" WIFSIGNALED : %d\n", WIFSIGNALED(wstatus)); 60 printf(" WTERMSIG : %d\n", WTERMSIG(wstatus)); 61 printf(" WCOREDUMP : %d\n", WCOREDUMP(wstatus)); 62 printf(" WIFSTOPPED : %d\n", WIFSTOPPED(wstatus)); 63 printf(" WSTOPSIG : %d\n", WSTOPSIG(wstatus)); 64 printf(" WIFCONTINUED: %d\n", WIFCONTINUED(wstatus)); 67 65 } 68 66 -
tests/test.py
r4af5396 ra25bcf8 72 72 # this is a valid name, let's check if it already exists 73 73 found = [test for test in all_tests if canonical_path( test.target() ) == testname] 74 setup = settings.all_arch if options.arch else [None]74 setup = itertools.product(settings.all_arch if options.arch else [None]) 75 75 if not found: 76 76 # it's a new name, create it according to the name and specified architecture
Note:
See TracChangeset
for help on using the changeset viewer.