Changeset 4af5396
- Timestamp:
- Oct 13, 2022, 10:00:03 PM (3 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 80fbdc9
- Parents:
- a25bcf8 (diff), f82f07e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/parseargs.cfa
ra25bcf8 r4af5396 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 // parseargs.cfa 8 // implementation of arguments parsing (argc, argv) 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 // 16 1 17 #include "parseargs.hfa" 2 18 19 #include <assert.h> 3 20 #include <ctype.h> 4 21 #include <stdint.h> … … 146 163 } 147 164 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 148 178 //----------------------------------------------------------------------------- 149 179 // Print usage 150 180 static void printopt(FILE * out, int width, int max, char sn, const char * ln, const char * help) { 181 // check how wide we should be printing 182 // this includes all options and the help message 151 183 int hwidth = max - (11 + width); 152 184 if(hwidth <= 0) hwidth = max; 153 185 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 } 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"); 167 221 } 168 222 -
libcfa/src/parseargs.hfa
ra25bcf8 r4af5396 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 // parseargs.cfa -- PUBLIC 8 // API for arguments parsing (argc, argv) 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 16 #pragma once 2 17 -
tests/configs/.expect/parsebools.txt
ra25bcf8 r4af5396 7 7 set false :true 8 8 Child status: 9 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 09 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 10 10 11 11 all true/set arg: … … 17 17 set false :false 18 18 Child status: 19 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 019 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 20 20 21 21 all false/unset arg: … … 27 27 set false :true 28 28 Child status: 29 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 029 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 30 30 31 31 gibberish arg 1: … … 43 43 -h, --help print this help message 44 44 Child status: 45 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 045 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 0 46 46 47 47 gibberish arg 2: … … 59 59 -h, --help print this help message 60 60 Child status: 61 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 061 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 0 62 62 63 63 gibberish arg 3: … … 74 74 -h, --help print this help message 75 75 Child status: 76 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 076 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 0 77 77 78 78 gibberish arg 4: … … 89 89 -h, --help print this help message 90 90 Child status: 91 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 091 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 0 92 92 93 93 All Done! -
tests/configs/.expect/parsenums.x64.txt
ra25bcf8 r4af5396 6 6 double :3.3 7 7 Child status: 8 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 08 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 9 9 10 10 all 0 arg: … … 15 15 double :0. 16 16 Child status: 17 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 017 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 18 18 19 19 negative vals arg: … … 24 24 double :-1. 25 25 Child status: 26 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 026 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 27 27 28 28 funky notation arg: … … 33 33 double :5000000. 34 34 Child status: 35 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 035 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 36 36 37 37 big values arg: … … 42 42 double :5000000. 43 43 Child status: 44 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 044 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 45 45 46 46 too big values arg: … … 57 57 -h, --help print this help message 58 58 Child status: 59 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 059 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 073 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 087 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0101 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 0 102 102 103 103 negative errors arg: … … 114 114 -h, --help print this help message 115 115 Child status: 116 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0116 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0130 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0144 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 0 145 145 146 146 All Done! -
tests/configs/.expect/parsenums.x86.txt
ra25bcf8 r4af5396 6 6 double :3.3 7 7 Child status: 8 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 08 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 9 9 10 10 all 0 arg: … … 15 15 double :0. 16 16 Child status: 17 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 017 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 18 18 19 19 negative vals arg: … … 24 24 double :-1. 25 25 Child status: 26 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 026 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 27 27 28 28 funky notation arg: … … 33 33 double :5000000. 34 34 Child status: 35 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 035 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 36 36 37 37 big values arg: … … 42 42 double :5000000. 43 43 Child status: 44 WIFEXITED : 1 WEXITSTATUS : 0 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 0 WIFCONTINUED: 044 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 45 45 46 46 too big values arg: … … 57 57 -h, --help print this help message 58 58 Child status: 59 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 059 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 073 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 087 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0101 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 0 102 102 103 103 negative errors arg: … … 114 114 -h, --help print this help message 115 115 Child status: 116 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0116 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0130 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 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 WIFEXITED : 1 WEXITSTATUS : 1 WIFSIGNALED : 0 WTERMSIG : 0 WCOREDUMP : 0 WIFSTOPPED : 0 WSTOPSIG : 1 WIFCONTINUED: 0144 IFEXITED : 1, EXITSTATUS : 1, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 1, IFCONTINUED: 0 145 145 146 146 All Done! -
tests/configs/parsebools.cfa
ra25bcf8 r4af5396 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/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 // 13 16 14 17 #include <parseargs.hfa> 15 18 #include <fstream.hfa> 16 19 17 int true_main(const char * exec); 20 #include "../meta/fork+exec.hfa" 18 21 19 22 int main(int argc, char * argv[]) { 20 if(!getenv("CFATEST_FORK_EXEC_TEXT")) return true_main(argv[0]);23 check_main(argv[0]); 21 24 22 25 bool YN = false; … … 48 51 } 49 52 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 53 int true_main(const char * path, char * env[]) { 87 54 printf("no arg:\n"); 88 55 if(pid_t child = strict_fork(); child == 0) { … … 97 64 print_status(status); 98 65 } 99 printf("\n");100 66 101 67 printf("all true/set arg:\n"); … … 111 77 print_status(status); 112 78 } 113 printf("\n");114 79 115 80 printf("all false/unset arg:\n"); … … 125 90 print_status(status); 126 91 } 127 printf("\n");128 92 129 93 printf("gibberish arg 1:\n"); … … 139 103 print_status(status); 140 104 } 141 printf("\n");142 105 143 106 printf("gibberish arg 2:\n"); … … 153 116 print_status(status); 154 117 } 155 printf("\n");156 118 157 119 printf("gibberish arg 3:\n"); … … 167 129 print_status(status); 168 130 } 169 printf("\n");170 131 171 132 printf("gibberish arg 4:\n"); … … 181 142 print_status(status); 182 143 } 183 printf("\n");184 144 185 145 printf("All Done!\n"); -
tests/configs/parsenums.cfa
ra25bcf8 r4af5396 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"); -
tests/meta/.expect/fork+exec.txt
ra25bcf8 r4af5396 4 4 Success! 5 5 Child status: 6 WIFEXITED : 1 7 WEXITSTATUS : 0 8 WIFSIGNALED : 0 9 WTERMSIG : 0 10 WCOREDUMP : 0 11 WIFSTOPPED : 0 12 WSTOPSIG : 0 13 WIFCONTINUED: 0 6 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 7 14 8 1 arg: 15 9 arguments are: … … 17 11 Success! 18 12 Child status: 19 WIFEXITED : 1 20 WEXITSTATUS : 0 21 WIFSIGNALED : 0 22 WTERMSIG : 0 23 WCOREDUMP : 0 24 WIFSTOPPED : 0 25 WSTOPSIG : 0 26 WIFCONTINUED: 0 13 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 14 27 15 5 arg: 28 16 arguments are: … … 34 22 Success! 35 23 Child status: 36 WIFEXITED : 1 37 WEXITSTATUS : 0 38 WIFSIGNALED : 0 39 WTERMSIG : 0 40 WCOREDUMP : 0 41 WIFSTOPPED : 0 42 WSTOPSIG : 0 43 WIFCONTINUED: 0 24 IFEXITED : 1, EXITSTATUS : 0, IFSIGNALED : 0, TERMSIG : 0, COREDUMP : 0, IFSTOPPED : 0, STOPSIG : 0, IFCONTINUED: 0 25 44 26 All Done! -
tests/meta/fork+exec.hfa
ra25bcf8 r4af5396 28 28 } 29 29 30 static int true_main(const char * exec, char * env[]);30 static int true_main(const char * path, 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(" 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)); 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"); 65 67 } 66 68 -
tests/test.py
ra25bcf8 r4af5396 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 = itertools.product(settings.all_arch if options.arch else [None])74 setup = 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.