- Timestamp:
- Apr 10, 2022, 2:53:18 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- d8e2a09
- Parents:
- 4559b34 (diff), 6256891 (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. - Location:
- tests
- Files:
-
- 51 added
- 21 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
tests/.expect/declarationSpecifier.arm64.txt
r4559b34 r92538ab 1132 1132 char **_X13cfa_args_argvPPc_1; 1133 1133 char **_X13cfa_args_envpPPc_1; 1134 signed int _X17cfa_main_returnedi_1 = ((signed int )0);1134 __attribute__ ((weak)) extern signed int _X17cfa_main_returnedi_1; 1135 1135 signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){ 1136 1136 __attribute__ ((unused)) signed int _X12_retval_maini_1; … … 1149 1149 signed int _tmp_cp_ret6; 1150 1150 signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6); 1151 { 1152 ((void)(_X17cfa_main_returnedi_1=((signed int )1))); 1151 if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) { 1152 { 1153 ((void)(_X17cfa_main_returnedi_1=((signed int )1))); 1154 } 1155 1153 1156 } 1154 1157 -
tests/.expect/gccExtensions.arm64.txt
r4559b34 r92538ab 324 324 char **_X13cfa_args_argvPPc_1; 325 325 char **_X13cfa_args_envpPPc_1; 326 signed int _X17cfa_main_returnedi_1 = ((signed int )0);326 __attribute__ ((weak)) extern signed int _X17cfa_main_returnedi_1; 327 327 signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){ 328 328 __attribute__ ((unused)) signed int _X12_retval_maini_1; … … 341 341 signed int _tmp_cp_ret6; 342 342 signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6); 343 { 344 ((void)(_X17cfa_main_returnedi_1=((signed int )1))); 343 if ( ((&_X17cfa_main_returnedi_1)!=((signed int *)0)) ) { 344 { 345 ((void)(_X17cfa_main_returnedi_1=((signed int )1))); 346 } 347 345 348 } 346 349 -
tests/.expect/random.arm64.txt
r4559b34 r92538ab 1 1 õ 2 2 = 3 V 3 K 4 4 -911259971 5 5 6 6 -4 6 11 7 7 1232105397 8 8 0 9 1 89 11 10 10 -914096085 11 11 1 12 15 12 20 13 13 2077092859 14 14 1 15 1 115 12 16 16 0.677254 17 17 0.678106775246139 -
tests/Makefile.am
r4559b34 r92538ab 28 28 DEBUG_FLAGS=-debug -g -O0 29 29 30 quick_test=avl_test operators numericConstants expression enum array typeof cast raii/dtor-early-exit raii/init_once attributes 30 quick_test=avl_test operators numericConstants expression enum array typeof cast raii/dtor-early-exit raii/init_once attributes meta/dumpable 31 31 32 32 concurrent= … … 66 66 PRETTY_PATH=mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} && 67 67 68 .PHONY: list .validate 69 .INTERMEDIATE: .validate .validate.cfa 68 .PHONY: list .validate .test_makeflags 69 .INTERMEDIATE: .validate .validate.cfa .test_makeflags 70 70 EXTRA_PROGRAMS = avl_test linkonce .dummy_hack # build but do not install 71 71 EXTRA_DIST = test.py \ … … 123 123 @+${TEST_PY} --list ${concurrent} 124 124 125 .test_makeflags: 126 @echo "${MAKEFLAGS}" 127 125 128 .validate: .validate.cfa 126 129 $(CFACOMPILE) .validate.cfa -fsyntax-only -Wall -Wextra -Werror -
tests/PRNG.cfa
r4559b34 r92538ab 8 8 // Created On : Wed Dec 29 09:38:12 2021 9 9 // Last Modified By : Peter A. Buhr 10 // Last Modified On : Fri Feb 11 08:16:43202211 // Update Count : 3 2810 // Last Modified On : Sat Apr 9 15:21:14 2022 11 // Update Count : 344 12 12 // 13 13 … … 20 20 #include <malloc.h> // malloc_stats 21 21 #include <locale.h> // setlocale 22 23 // FIX ME: spurious characters appear in output 24 Duration default_preemption() { return 0; } 22 #include <mutex_stmt.hfa> 25 23 26 24 #ifdef TIME // use -O2 -nodebug … … 50 48 } // for 51 49 double std = sqrt( sum / BUCKETS ); 52 sout | "trials" | TRIALS | "buckets" | BUCKETS53 54 50 mutex( sout ) sout | "trials" | TRIALS | "buckets" | BUCKETS 51 | "min" | min | "max" | max 52 | "avg" | wd(0,1, avg) | "std" | wd(0,1, std) | "rstd" | wd(0,1, (avg == 0 ? 0.0 : std / avg * 100)) | "%"; 55 53 } // avgstd 56 54 55 57 56 uint32_t seed = 1009; 58 59 57 60 58 thread T1 {}; … … 94 92 unsigned int * buckets = calloc( BUCKETS ); // too big for task stack 95 93 for ( TRIALS ) { 96 buckets[prng( (thread$ &)th ) % BUCKETS] += 1; // concurrent94 buckets[prng( th ) % BUCKETS] += 1; // concurrent 97 95 } // for 98 96 avgstd( buckets ); -
tests/collections/.expect/string-api-coverage.txt
r4559b34 r92538ab 1 1 hello hello hello 2 3 hello 2 4 true false 3 5 true false -
tests/collections/.expect/string-gc.txt
r4559b34 r92538ab 38 38 x from 5 to 15 39 39 y from 5 to 15 40 ======================== fillNoCompact 41 about to expand, a = aaa 42 expanded, a = aaa 43 about to expand, a = aaa 44 expanded, a = aaa 45 about to expand, a = aaa 46 expanded, a = aaa 47 about to expand, a = aaa 48 expanded, a = aaa 49 about to expand, a = aaa 50 expanded, a = aaa -
tests/collections/.expect/vector-err-pass-perm-it-byval.txt
r4559b34 r92538ab 1 error: Unique best alternative includes deleted identifier in Generated Cast of:1 collections/vector-demo.cfa:95:1 error: Unique best alternative includes deleted identifier in Generated Cast of: 2 2 Application of 3 3 Deleted Expression -
tests/collections/string-api-coverage.cfa
r4559b34 r92538ab 1 1 #include <containers/string.hfa> 2 #include <string_sharectx.hfa> 2 3 3 4 void assertWellFormedHandleList( int maxLen ) { // with(HeapArea) … … 25 26 26 27 int main () { 28 29 #ifdef STRING_SHARING_OFF 30 string_sharectx c = { NO_SHARING }; 31 #endif 32 27 33 string s = "hello"; 28 34 string s2 = "hello"; … … 31 37 32 38 // IO operator, x2 33 sout | s | s | s; 39 sout | s | s | s; // hello hello hello 40 41 // empty ctor then assign 42 string sxx; 43 sout | sxx; // (blank line) 44 sxx = s; 45 sout | sxx; // hello 34 46 35 47 // Comparisons -
tests/collections/string-gc.cfa
r4559b34 r92538ab 2 2 3 3 size_t bytesRemaining() { 4 return DEBUG_string_bytes_avail_until_gc( DEBUG_string_heap );4 return DEBUG_string_bytes_avail_until_gc( DEBUG_string_heap() ); 5 5 } 6 6 7 7 size_t heapOffsetStart( string_res & s ) { 8 const char * startByte = DEBUG_string_heap_start( DEBUG_string_heap );8 const char * startByte = DEBUG_string_heap_start( DEBUG_string_heap() ); 9 9 assert( s.Handle.s >= startByte ); 10 10 return s.Handle.s - startByte; … … 120 120 } 121 121 122 void fillNoCompact() { 123 // show that allocating in a heap filled with mostly live strings (no collectable garbage) causes heap growth 124 125 sout | "======================== fillNoCompact"; 126 127 size_t lastTimeBytesAvail = bytesRemaining(); 128 assert( lastTimeBytesAvail >= 200 ); // starting this test with nontrivial room 129 130 // mostly fill the pad 131 string_res a = "aaa"; // will have to be moved 132 string_res z = "zzz"; 133 for (i; 5) { 134 while ( bytesRemaining() > 10 ) { 135 z += "."; 136 } 137 sout | "about to expand, a = " | a; 138 while ( bytesRemaining() <= 10 ) { 139 z += "."; 140 } 141 sout | "expanded, a = " | a; 142 143 // each growth gives more usable space than the last 144 assert( bytesRemaining() > lastTimeBytesAvail ); 145 lastTimeBytesAvail = bytesRemaining(); 146 } 147 } 148 122 149 int main() { 123 150 basicFillCompact(); 124 151 fillCompact_withSharedEdits(); 152 fillNoCompact(); 125 153 } -
tests/collections/string-overwrite.cfa
r4559b34 r92538ab 1 1 #include <containers/string.hfa> 2 #include <string_sharectx.hfa> 2 3 3 4 /* … … 11 12 WE = witness end 12 13 13 The dest does:14 The test does: 14 15 starts with the entire string being, initially, the alphabet; prints this entire alphabet 15 16 sets up modifier and witness as ranges within it, and prints a visualization of those ranges … … 24 25 This API's convention has Start positions being inclusive and end positions being exclusive. 25 26 27 v Case number in output 26 28 With 1 equivalence class: 27 29 MS = ME = WS = WE 1 … … 118 120 struct { int ms; int me; int ws; int we; char *replaceWith; char *label; } cases[] = { 119 121 { 12, 14, 10, 20, "xxxxx", "warmup" }, 120 // { 12, 14, 12, 14, "xxxxx", "" }, // the bug that got me into this test (should be a dup with case 6)121 122 { 10, 10, 10, 10, "=====", "1" }, 122 123 { 10, 10, 10, 10, "==" , "" }, … … 223 224 { 12, 14, 10, 16, "=" , "" }, 224 225 { 12, 14, 10, 16, "" , "" }, 225 /*226 { , , , , "=====", "NN" },227 { "==" , "" },228 { "=" , "" },229 { "" , "" },230 */231 226 }; 232 227 for ( i; sizeof(cases)/sizeof(cases[0]) ) { … … 238 233 239 234 240 // void f( string & s, string & toEdit ) {241 242 // sout | s | "|" | toEdit | "|";243 244 // s(14, 16) = "-";245 // sout | s | "|" | toEdit | "|";246 // }247 248 235 int main() { 236 237 #ifdef STRING_SHARING_OFF 238 string_sharectx c = { NO_SHARING }; 239 #endif 240 241 249 242 // 0 1 2 250 243 // 01234567890123456789012345 -
tests/concurrent/mutexstmt/.expect/locks.txt
r4559b34 r92538ab 3 3 Start Test: multi lock deadlock/mutual exclusion 4 4 End Test: multi lock deadlock/mutual exclusion 5 Start Test: single scoped lock mutual exclusion 6 End Test: single scoped lock mutual exclusion 7 Start Test: multi scoped lock deadlock/mutual exclusion 8 End Test: multi scoped lock deadlock/mutual exclusion 5 Start Test: multi polymorphic lock deadlock/mutual exclusion 6 End Test: multi polymorphic lock deadlock/mutual exclusion -
tests/concurrent/mutexstmt/locks.cfa
r4559b34 r92538ab 3 3 4 4 const unsigned int num_times = 10000; 5 6 Duration default_preemption() { return 0; } 5 7 6 8 single_acquisition_lock m1, m2, m3, m4, m5; … … 22 24 } 23 25 26 void refTest( single_acquisition_lock & m ) { 27 mutex ( m ) { 28 assert(!insideFlag); 29 insideFlag = true; 30 assert(insideFlag); 31 insideFlag = false; 32 } 33 } 34 24 35 thread T_Multi {}; 25 36 26 37 void main( T_Multi & this ) { 27 38 for (unsigned int i = 0; i < num_times; i++) { 39 refTest( m1 ); 28 40 mutex ( m1 ) { 29 41 assert(!insideFlag); … … 59 71 } 60 72 61 thread T_Mutex_Scoped {}; 73 single_acquisition_lock l1; 74 linear_backoff_then_block_lock l2; 75 owner_lock l3; 62 76 63 void main( T_Mutex_Scoped & this ) { 77 monitor monitor_t {}; 78 79 monitor_t l4; 80 81 thread T_Multi_Poly {}; 82 83 void main( T_Multi_Poly & this ) { 64 84 for (unsigned int i = 0; i < num_times; i++) { 65 { 66 scoped_lock(single_acquisition_lock) s{m1}; 67 count++; 68 } 69 { 70 scoped_lock(single_acquisition_lock) s{m1}; 85 refTest( l1 ); 86 mutex ( l1, l4 ) { 71 87 assert(!insideFlag); 72 88 insideFlag = true; … … 74 90 insideFlag = false; 75 91 } 76 } 77 } 78 79 thread T_Multi_Scoped {}; 80 81 void main( T_Multi_Scoped & this ) { 82 for (unsigned int i = 0; i < num_times; i++) { 83 { 84 scoped_lock(single_acquisition_lock) s{m1}; 92 mutex ( l1, l2, l3 ) { 85 93 assert(!insideFlag); 86 94 insideFlag = true; … … 88 96 insideFlag = false; 89 97 } 90 { 91 scoped_lock(single_acquisition_lock) s1{m1}; 92 scoped_lock(single_acquisition_lock) s2{m2}; 93 scoped_lock(single_acquisition_lock) s3{m3}; 94 scoped_lock(single_acquisition_lock) s4{m4}; 95 scoped_lock(single_acquisition_lock) s5{m5}; 98 mutex ( l3, l1, l4 ) { 96 99 assert(!insideFlag); 97 100 insideFlag = true; … … 99 102 insideFlag = false; 100 103 } 101 { 102 scoped_lock(single_acquisition_lock) s1{m1}; 103 scoped_lock(single_acquisition_lock) s3{m3}; 104 assert(!insideFlag); 105 insideFlag = true; 106 assert(insideFlag); 107 insideFlag = false; 108 } 109 { 110 scoped_lock(single_acquisition_lock) s1{m1}; 111 scoped_lock(single_acquisition_lock) s2{m2}; 112 scoped_lock(single_acquisition_lock) s4{m4}; 113 assert(!insideFlag); 114 insideFlag = true; 115 assert(insideFlag); 116 insideFlag = false; 117 } 118 { 119 scoped_lock(single_acquisition_lock) s1{m1}; 120 scoped_lock(single_acquisition_lock) s3{m3}; 121 scoped_lock(single_acquisition_lock) s4{m4}; 122 scoped_lock(single_acquisition_lock) s5{m5}; 104 mutex ( l1, l2, l4 ) { 123 105 assert(!insideFlag); 124 106 insideFlag = true; … … 131 113 int num_tasks = 10; 132 114 int main() { 133 processor p[ 10];115 processor p[num_tasks - 1]; 134 116 135 117 printf("Start Test: single lock mutual exclusion\n"); 136 118 { 137 T_Mutex t[ 10];119 T_Mutex t[num_tasks]; 138 120 } 139 121 assert(count == num_tasks * num_times); … … 141 123 printf("Start Test: multi lock deadlock/mutual exclusion\n"); 142 124 { 143 T_Multi t[ 10];125 T_Multi t[num_tasks]; 144 126 } 145 127 printf("End Test: multi lock deadlock/mutual exclusion\n"); 146 147 count = 0; 148 printf("Start Test: single scoped lock mutual exclusion\n"); 128 printf("Start Test: multi polymorphic lock deadlock/mutual exclusion\n"); 149 129 { 150 T_Mu tex_Scoped t[10];130 T_Multi_Poly t[num_tasks]; 151 131 } 152 assert(count == num_tasks * num_times); 153 printf("End Test: single scoped lock mutual exclusion\n"); 154 printf("Start Test: multi scoped lock deadlock/mutual exclusion\n"); 155 { 156 T_Multi_Scoped t[10]; 157 } 158 printf("End Test: multi scoped lock deadlock/mutual exclusion\n"); 132 printf("End Test: multi polymorphic lock deadlock/mutual exclusion\n"); 159 133 } -
tests/designations.cfa
r4559b34 r92538ab 10 10 // Created On : Thu Jun 29 15:26:36 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 27 11:46:35 201713 // Update Count : 312 // Last Modified On : Mon Mar 28 22:41:55 2022 13 // Update Count : 15 14 14 // 15 15 … … 18 18 // is used for the designation syntax 19 19 #ifdef __cforall 20 #define DES : 20 #define _ : 21 #define AT @ 21 22 #else 22 int printf(const char *, ...); 23 #define DES = 23 int printf( const char *, ...); 24 #define _ = 25 #define AT 24 26 #endif 25 27 26 28 const int indentAmt = 2; 27 void indent( int level) {28 for ( int i = 0; i < level; ++i) {29 printf( " ");29 void indent( int level ) { 30 for ( int i = 0; i < level; ++i ) { 31 printf( " " ); 30 32 } 31 33 } … … 36 38 int * ptr; 37 39 }; 38 void printA( struct A a, int level) {39 indent( level);40 printf( "(A){ %d %d %p }\n", a.x, a.y, a.ptr);40 void printA( struct A a, int level ) { 41 indent( level ); 42 printf( "(A){ %d %d %p }\n", a.x, a.y, a.ptr ); 41 43 } 42 44 … … 45 47 struct A a0, a1; 46 48 }; 47 void printB( struct B b, int level) {48 indent( level);49 printf( "(B){\n");50 printA( b.a0, level+indentAmt);51 printA( b.a1, level+indentAmt);52 indent( level);53 printf( "}\n");49 void printB( struct B b, int level ) { 50 indent( level ); 51 printf( "(B){\n" ); 52 printA( b.a0, level+indentAmt ); 53 printA( b.a1, level+indentAmt ); 54 indent( level ); 55 printf( "}\n" ); 54 56 } 55 57 … … 59 61 struct B b; 60 62 }; 61 void printC( struct C c, int level) {62 indent( level);63 printf( "(C){\n");64 indent( level+indentAmt);65 printf( "(int[]{ %d %d %d }\n", c.arr[0], c.arr[1], c.arr[2]);66 printB( c.b, level+indentAmt);67 indent( level);68 printf( "}\n");63 void printC( struct C c, int level ) { 64 indent( level ); 65 printf( "(C){\n" ); 66 indent( level+indentAmt ); 67 printf( "(int[]{ %d %d %d }\n", c.arr[0], c.arr[1], c.arr[2]); 68 printB( c.b, level+indentAmt ); 69 indent( level ); 70 printf( "}\n" ); 69 71 } 70 72 … … 75 77 }; 76 78 }; 77 void printD( struct D d, int level) {78 indent( level);79 printf( "(D){ %d }\n", d.x);79 void printD( struct D d, int level ) { 80 indent( level); 81 printf( "(D ){ %d }\n", d.x ); 80 82 } 81 83 … … 99 101 } m; 100 102 }; 101 struct Fred s1 @= { .m.j :3 };102 struct Fred s2 @= { .i : { [2] :2 } };103 struct Fred s1 AT= { .m.j _ 3 }; 104 struct Fred s2 AT= { .i _ { [2] _ 2 } }; 103 105 104 106 int main() { 105 107 // simple designation case - starting from beginning of structure, leaves ptr default-initialized (zero) 106 108 struct A y0 = { 107 .x DES2,108 .y DES3109 .x _ 2, 110 .y _ 3 109 111 }; 110 112 … … 117 119 // use designation to move to member y, leaving x default-initialized (zero) 118 120 struct A y2 = { 119 .y DES3,121 .y _ 3, 120 122 0 121 123 }; … … 127 129 #endif 128 130 129 printf( "=====A=====\n");130 printA( y0, 0);131 printA( y1, 0);132 printA( y2, 0);133 printf( "=====A=====\n\n");131 printf( "=====A=====\n" ); 132 printA( y0, 0 ); 133 printA( y1, 0 ); 134 printA( y2, 0 ); 135 printf( "=====A=====\n\n" ); 134 136 135 137 // initialize only first element (z0.a.x), leaving everything else default-initialized (zero), no nested curly-braces … … 140 142 { 3 }, // z1.a0 141 143 { 4 }, // z1.a1 142 .a0 DES{ 5 }, // z1.a0144 .a0 _ { 5 }, // z1.a0 143 145 { 6 }, // z1.a1 144 .a0.y DES2, // z1.a0.y146 .a0.y _ 2, // z1.a0.y 145 147 0, // z1.a0.ptr 146 148 }; … … 170 172 }; 171 173 172 printf( "=====B=====\n");173 printB( z0, 0);174 printB( z1, 0);175 printB( z2, 0);176 printB( z3, 0);177 printB( z5, 0);178 printB( z6, 0);179 printf( "=====B=====\n\n");174 printf( "=====B=====\n" ); 175 printB( z0, 0 ); 176 printB( z1, 0 ); 177 printB( z2, 0 ); 178 printB( z3, 0 ); 179 printB( z5, 0 ); 180 printB( z6, 0 ); 181 printf( "=====B=====\n\n" ); 180 182 181 183 // TODO: what about extra things in a nested init? are empty structs skipped?? … … 188 190 }; 189 191 190 printf( "=====C=====\n");191 printC( c1, 0);192 printf( "=====C=====\n\n");192 printf( "=====C=====\n" ); 193 printC( c1, 0 ); 194 printf( "=====C=====\n\n" ); 193 195 194 196 #if ERROR … … 213 215 #endif 214 216 // array designation 215 int i[2] = { [1] :3 };217 int i[2] = { [1] _ 3 }; 216 218 // allowed to have 'too many' initialized lists - essentially they are ignored. 217 219 int i1 = { 3 }; … … 219 221 // doesn't work yet. 220 222 // designate unnamed object's members 221 // struct D d = { .x DES3 };223 // struct D d = { .x _ 3 }; 222 224 #if ERROR 223 struct D d1 = { .y DES3 };225 struct D d1 = { .y _ 3 }; 224 226 #endif 225 227 … … 241 243 // move cursor to e4.b.a0.x and initialize until e3.b.a1.ptr inclusive 242 244 union E e3 = { 243 .b.a0.x DES2, 3, 0, 5, 6, 0244 }; 245 246 printf( "=====E=====\n");247 printA( e0.a, 0);248 printA( e1.a, 0);249 printA( e2.a, 0);250 printB( e3.b, 0);251 printf( "=====E=====\n\n");245 .b.a0.x _ 2, 3, 0, 5, 6, 0 246 }; 247 248 printf( "=====E=====\n" ); 249 printA( e0.a, 0 ); 250 printA( e1.a, 0 ); 251 printA( e2.a, 0 ); 252 printB( e3.b, 0 ); 253 printf( "=====E=====\n\n" ); 252 254 253 255 // special case of initialization: char[] can be initialized with a string literal 254 256 const char * str0 = "hello"; 255 257 char str1[] = "hello"; 256 const char c1[] = "abc"; 257 const char c2[] = { 'a', 'b', 'c' }; 258 const char c3[][2] = { { 'a', 'b' }, { 'c', 'd'}, { 'c', 'd'} }; 258 const char c2[] = "abc"; 259 const char c3[] = { 'a', 'b', 'c' }; 260 const char c4[][2] = { { 'a', 'b' }, { 'c', 'd'}, { 'c', 'd'} }; 261 262 // more cases 263 264 // int widths[] = { [3 ... 9] _ 1, [10 ... 99] _ 2, [100] _ 3 }; 265 // int widths[] = { [3 ~ 9] _ 1, [10 ~ 99] _ 2, [100] _ 3 }; 266 struct point { int x, y; }; 267 struct point p = { .y _ 5, .x _ 7 }; 268 union foo { int i; double d; }; 269 union foo f = { .d _ 4 }; 270 int v1, v2, v4; 271 int w[6] = { [1] _ v1, v2, [4] _ v4 }; 272 int whitespace[256] = { [' '] _ 1, ['\t'] _ 1, ['\v'] _ 1, ['\f'] _ 1, ['\n'] _ 1, ['\r'] _ 1 }; 273 struct point ptarray[10] = { [2].y _ 34, [2].x _ 35, [0].x _ 36 }; 259 274 } 260 275 -
tests/errors/.expect/scope.txt
r4559b34 r92538ab 4 4 double 5 5 ... returning 6 _retval_butThisIsAnError:double7 ... with attributes:8 Attribute with name: unused6 double 7 with body 8 Compound Statement: 9 9 10 ... with body11 CompoundStmt12 -
tests/io/io-acquire.cfa
r4559b34 r92538ab 10 10 // Created On : Mon Mar 1 18:40:09 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 14 09:13:18202213 // Update Count : 7 412 // Last Modified On : Sat Apr 9 15:22:03 2022 13 // Update Count : 76 14 14 // 15 15 … … 17 17 #include <thread.hfa> 18 18 #include <mutex_stmt.hfa> 19 20 Duration default_preemption() { return 0; }21 19 22 20 thread T {}; -
tests/io/many_read.cfa
r4559b34 r92538ab 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // many_read.cfa -- Make sure that multiple concurrent reads tomess up.7 // many_read.cfa -- Make sure that multiple concurrent reads don't mess up. 8 8 // 9 9 // Author : Thierry Delisle -
tests/meta/dumpable.cfa
r4559b34 r92538ab 14 14 // 15 15 16 #include <errno.h> 16 17 #include <limits.h> 17 #include < errno.h>18 #include <string.h> 18 19 19 20 #include <fstream.hfa> 20 21 21 22 extern "C" { 23 #include <fcntl.h> 24 #include <unistd.h> 22 25 #include <sys/prctl.h> 23 26 #include <sys/resource.h> 24 27 #include <sys/statvfs.h> 25 #include <unistd.h> 28 #include <sys/stat.h> 29 #include <sys/types.h> 26 30 } 27 31 … … 72 76 } 73 77 74 if((buf.f_bsize * buf.f_bavail) < 536870912) { 75 serr | "Available diskspace is less than ~500Mb: " | (buf.f_bsize * buf.f_bavail); 78 uint64_t avail = buf.f_bavail; 79 avail *= buf.f_bsize; 80 if(avail < 536870912_l64u) { 81 serr | "Available diskspace is less than ~500Mb: " | avail; 76 82 } 77 83 … … 100 106 } 101 107 108 void check_core_pattern() { 109 int ret; 110 int cp = open("/proc/sys/kernel/core_pattern", 0, O_RDONLY); 111 if(cp < 0) { 112 perror("open(/proc/sys/kernel/core_pattern, O_RDONLY) error"); 113 return; 114 } 115 116 try { 117 const char * expected = "core\n"; 118 const int sz = sizeof("core\n"); 119 char buf[512]; 120 ret = read(cp, buf, 512); 121 if(ret < 0) { 122 perror("first core pattern read error"); 123 return; 124 } 125 ret = strncmp(expected, buf, sz - 1); 126 if(ret != 0) { 127 serr | "/proc/sys/kernel/core_pattern does not contain 'core', was:" | nl | nl | buf | nl 128 | "Test script expect cores files to be dumped with name 'core' in current working directory." | nl 129 | "Apport is not supported, it should be deactivated in /etc/default/apport for the test suite to work with core dumps."; 130 131 return; 132 } 133 } 134 finally { 135 ret = close(cp); 136 if(ret < 0) perror("close(/proc/sys/kernel/core_pattern) error"); 137 } 138 139 } 140 102 141 int main() { 103 142 check_ulimit(); … … 111 150 check_dumpflag(); 112 151 152 check_core_pattern(); 153 113 154 sout | "Done"; 114 155 } -
tests/pybin/settings.py
r4559b34 r92538ab 155 155 global generating 156 156 global make 157 global make_jobfds 157 158 global output_width 158 159 global timeout … … 168 169 generating = options.regenerate_expected 169 170 make = ['make'] 171 make_jobfds = [] 170 172 output_width = 24 171 173 timeout = Timeouts(options.timeout, options.global_timeout) … … 177 179 os.putenv('DISTCC_LOG', os.path.join(BUILDDIR, 'distcc_error.log')) 178 180 179 def update_make_cmd(f orce, jobs):181 def update_make_cmd(flags): 180 182 global make 181 182 make = ['make'] if not force else ['make', "-j%i" % jobs] 183 make = ['make', *flags] 184 185 def update_make_fds(r, w): 186 global make_jobfds 187 make_jobfds = (r, w) 183 188 184 189 def validate(): … … 187 192 global distcc 188 193 distcc = "DISTCC_CFA_PATH=~/.cfadistcc/%s/cfa" % tools.config_hash() 189 errf = os.path.join(BUILDDIR, ".validate.err") 190 make_ret, out = tools.make( ".validate", error_file = errf, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL ) 194 make_ret, out, err = tools.make( ".validate", output_file=subprocess.PIPE, error=subprocess.PIPE ) 191 195 if make_ret != 0: 192 with open (errf, "r") as myfile:193 error=myfile.read()194 196 print("ERROR: Invalid configuration %s:%s" % (arch.string, debug.string), file=sys.stderr) 195 print(" verify returned : \n%s" % error, file=sys.stderr) 196 tools.rm(errf) 197 print(" verify returned : \n%s" % err, file=sys.stderr) 197 198 sys.exit(1) 198 199 tools.rm(errf)200 199 201 200 def prep_output(tests): -
tests/pybin/tools.py
r4559b34 r92538ab 23 23 24 24 # helper functions to run terminal commands 25 def sh(*cmd, timeout = False, output_file = None, input_file = None, input_text = None, error = subprocess.STDOUT, ignore_dry_run = False ):25 def sh(*cmd, timeout = False, output_file = None, input_file = None, input_text = None, error = subprocess.STDOUT, ignore_dry_run = False, pass_fds = []): 26 26 try: 27 27 cmd = list(cmd) … … 65 65 **({'input' : bytes(input_text, encoding='utf-8')} if input_text else {'stdin' : input_file}), 66 66 stdout = output_file, 67 stderr = error 67 stderr = error, 68 pass_fds = pass_fds 68 69 ) as proc: 69 70 70 71 try: 71 out, _= proc.communicate(72 out, errout = proc.communicate( 72 73 timeout = settings.timeout.single if timeout else None 73 74 ) 74 75 75 return proc.returncode, out.decode("latin-1") if out else None 76 return proc.returncode, out.decode("latin-1") if out else None, errout.decode("latin-1") if errout else None 76 77 except subprocess.TimeoutExpired: 77 78 if settings.timeout2gdb: 78 79 print("Process {} timeout".format(proc.pid)) 79 80 proc.communicate() 80 return 124, str(None) 81 return 124, str(None), "Subprocess Timeout 2 gdb" 81 82 else: 82 83 proc.send_signal(signal.SIGABRT) 83 84 proc.communicate() 84 return 124, str(None) 85 return 124, str(None), "Subprocess Timeout 2 gdb" 85 86 86 87 except Exception as ex: … … 105 106 return (False, "No file") 106 107 107 code, out = sh("file", fname, output_file=subprocess.PIPE)108 code, out, err = sh("file", fname, output_file=subprocess.PIPE) 108 109 if code != 0: 109 return (False, "'file EXPECT' failed with code {} ".format(code))110 return (False, "'file EXPECT' failed with code {} '{}'".format(code, err)) 110 111 111 112 match = re.search(".*: (.*)", out) … … 190 191 ] 191 192 cmd = [s for s in cmd if s] 192 return sh(*cmd, output_file=output_file, error=error )193 return sh(*cmd, output_file=output_file, error=error, pass_fds=settings.make_jobfds) 193 194 194 195 def make_recon(target): … … 241 242 # move a file 242 243 def mv(source, dest): 243 ret, _ = sh("mv", source, dest)244 ret, _, _ = sh("mv", source, dest) 244 245 return ret 245 246 246 247 # cat one file into the other 247 248 def cat(source, dest): 248 ret, _ = sh("cat", source, output_file=dest)249 ret, _, _ = sh("cat", source, output_file=dest) 249 250 return ret 250 251 … … 289 290 # system 290 291 ################################################################################ 292 def jobserver_version(): 293 make_ret, out, err = sh('make', '.test_makeflags', '-j2', output_file=subprocess.PIPE, error=subprocess.PIPE) 294 if make_ret != 0: 295 print("ERROR: cannot find Makefile jobserver version", file=sys.stderr) 296 print(" test returned : {} '{}'".format(make_ret, err), file=sys.stderr) 297 sys.exit(1) 298 299 re_jobs = re.search("--jobserver-(auth|fds)", out) 300 if not re_jobs: 301 print("ERROR: cannot find Makefile jobserver version", file=sys.stderr) 302 print(" MAKEFLAGS are : '{}'".format(out), file=sys.stderr) 303 sys.exit(1) 304 305 return "--jobserver-{}".format(re_jobs.group(1)) 306 307 def prep_recursive_make(N): 308 if N < 2: 309 return [] 310 311 # create the pipe 312 (r, w) = os.pipe() 313 314 # feel it with N-1 tokens, (Why N-1 and not N, I don't know it's in the manpage for make) 315 os.write(w, b'+' * (N - 1)); 316 317 # prep the flags for make 318 make_flags = ["-j{}".format(N), "--jobserver-auth={},{}".format(r, w)] 319 320 # tell make about the pipes 321 os.environ["MAKEFLAGS"] = os.environ["MFLAGS"] = " ".join(make_flags) 322 323 # make sure pass the pipes to our children 324 settings.update_make_fds(r, w) 325 326 return make_flags 327 328 def prep_unlimited_recursive_make(): 329 # prep the flags for make 330 make_flags = ["-j"] 331 332 # tell make about the pipes 333 os.environ["MAKEFLAGS"] = os.environ["MFLAGS"] = "-j" 334 335 return make_flags 336 337 338 def eval_hardware(): 339 # we can create as many things as we want 340 # how much hardware do we have? 341 if settings.distribute: 342 # remote hardware is allowed 343 # how much do we have? 344 ret, jstr, _ = sh("distcc", "-j", output_file=subprocess.PIPE, ignore_dry_run=True) 345 return int(jstr.strip()) if ret == 0 else multiprocessing.cpu_count() 346 else: 347 # remote isn't allowed, use local cpus 348 return multiprocessing.cpu_count() 349 291 350 # count number of jobs to create 292 def job_count( options , tests):351 def job_count( options ): 293 352 # check if the user already passed in a number of jobs for multi-threading 294 if not options.jobs: 295 make_flags = os.environ.get('MAKEFLAGS') 296 force = bool(make_flags) 297 make_jobs_fds = re.search("--jobserver-(auth|fds)=\s*([0-9]+),([0-9]+)", make_flags) if make_flags else None 298 if make_jobs_fds : 299 tokens = os.read(int(make_jobs_fds.group(2)), 1024) 300 options.jobs = len(tokens) 301 os.write(int(make_jobs_fds.group(3)), tokens) 302 else : 303 if settings.distribute: 304 ret, jstr = sh("distcc", "-j", output_file=subprocess.PIPE, ignore_dry_run=True) 305 if ret == 0: 306 options.jobs = int(jstr.strip()) 307 else : 308 options.jobs = multiprocessing.cpu_count() 309 else: 310 options.jobs = multiprocessing.cpu_count() 353 make_env = os.environ.get('MAKEFLAGS') 354 make_flags = make_env.split() if make_env else None 355 jobstr = jobserver_version() 356 357 if options.jobs and make_flags: 358 print('WARNING: -j options should not be specified when called form Make', file=sys.stderr) 359 360 # Top level make is calling the shots, just follow 361 if make_flags: 362 # do we have -j and --jobserver-... 363 jobopt = None 364 exists_fds = None 365 for f in make_flags: 366 jobopt = f if f.startswith("-j") else jobopt 367 exists_fds = f if f.startswith(jobstr) else exists_fds 368 369 # do we have limited parallelism? 370 if exists_fds : 371 try: 372 rfd, wfd = tuple(exists_fds.split('=')[1].split(',')) 373 except: 374 print("ERROR: jobserver has unrecoginzable format, was '{}'".format(exists_fds), file=sys.stderr) 375 sys.exit(1) 376 377 # read the token pipe to count number of available tokens and restore the pipe 378 # this assumes the test suite script isn't invoked in parellel with something else 379 tokens = os.read(int(rfd), 65536) 380 os.write(int(wfd), tokens) 381 382 # the number of tokens is off by one for obscure but well documented reason 383 # see man make for more details 384 options.jobs = len(tokens) + 1 385 386 # do we have unlimited parallelism? 387 elif jobopt and jobopt != "-j1": 388 # check that this actually make sense 389 if jobopt != "-j": 390 print("ERROR: -j option passed by make but no {}, was '{}'".format(jobstr, jobopt), file=sys.stderr) 391 sys.exit(1) 392 393 options.jobs = eval_hardware() 394 flags = prep_unlimited_recursive_make() 395 396 397 # then no parallelism 398 else: 399 options.jobs = 1 400 401 # keep all flags make passed along, except the weird 'w' which is about subdirectories 402 flags = [f for f in make_flags if f != 'w'] 403 404 # Arguments are calling the shots, fake the top level make 405 elif options.jobs : 406 407 # make sure we have a valid number of jobs that corresponds to user input 408 if options.jobs < 0 : 409 print('ERROR: Invalid number of jobs', file=sys.stderr) 410 sys.exit(1) 411 412 flags = prep_recursive_make(options.jobs) 413 414 # Arguments are calling the shots, fake the top level make, but 0 is a special case 415 elif options.jobs == 0: 416 options.jobs = eval_hardware() 417 flags = prep_unlimited_recursive_make() 418 419 # No one says to run in parallel, then don't 311 420 else : 312 force = True313 314 # make sure we have a valid number of jobs that corresponds to user input 315 if options.jobs <= 0 :316 print('ERROR: Invalid number of jobs', file=sys.stderr)317 sys.exit(1) 318 319 return min( options.jobs, len(tests) ), force421 options.jobs = 1 422 flags = [] 423 424 # Make sure we call make as expected 425 settings.update_make_cmd( flags ) 426 427 # return the job count 428 return options.jobs 320 429 321 430 # enable core dumps for all the test children … … 334 443 distcc_hash = os.path.join(settings.SRCDIR, '../tools/build/distcc_hash') 335 444 config = "%s-%s" % (settings.arch.target, settings.debug.path) 336 _, out = sh(distcc_hash, config, output_file=subprocess.PIPE, ignore_dry_run=True)445 _, out, _ = sh(distcc_hash, config, output_file=subprocess.PIPE, ignore_dry_run=True) 337 446 return out.strip() 338 447 … … 374 483 375 484 if not os.path.isfile(core): 376 return 1, "ERR No core dump (limit soft: {} hard: {})".format(*resource.getrlimit(resource.RLIMIT_CORE))485 return 1, "ERR No core dump, expected '{}' (limit soft: {} hard: {})".format(core, *resource.getrlimit(resource.RLIMIT_CORE)) 377 486 378 487 try: 379 return sh('gdb', '-n', path, core, '-batch', '-x', cmd, output_file=subprocess.PIPE) 488 ret, out, err = sh('gdb', '-n', path, core, '-batch', '-x', cmd, output_file=subprocess.PIPE) 489 if ret == 0: 490 return 0, out 491 else: 492 return 1, err 380 493 except: 381 494 return 1, "ERR Could not read core with gdb" -
tests/test.py
r4559b34 r92538ab 140 140 parser.add_argument('--regenerate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true') 141 141 parser.add_argument('--archive-errors', help='If called with a valid path, on test crashes the test script will copy the core dump and the executable to the specified path.', type=str, default='') 142 parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously ', type=int)142 parser.add_argument('-j', '--jobs', help='Number of tests to run simultaneously, 0 (default) for unlimited', nargs='?', const=0, type=int) 143 143 parser.add_argument('--list-comp', help='List all valide arguments', action='store_true') 144 144 parser.add_argument('--list-dist', help='List all tests for distribution', action='store_true') … … 195 195 # build, skipping to next test on error 196 196 with Timed() as comp_dur: 197 make_ret, _ = make( test.target(), output_file=subprocess.DEVNULL, error=out_file, error_file = err_file )197 make_ret, _, _ = make( test.target(), output_file=subprocess.DEVNULL, error=out_file, error_file = err_file ) 198 198 199 199 # ---------- … … 208 208 if settings.dry_run or is_exe(exe_file): 209 209 # run test 210 retcode, _ = sh(exe_file, output_file=out_file, input_file=in_file, timeout=True)210 retcode, _, _ = sh(exe_file, output_file=out_file, input_file=in_file, timeout=True) 211 211 else : 212 212 # simply cat the result into the output … … 226 226 else : 227 227 # fetch return code and error from the diff command 228 retcode, error = diff(cmp_file, out_file)228 retcode, error, _ = diff(cmp_file, out_file) 229 229 230 230 else: … … 366 366 print(os.path.relpath(t.expect(), settings.SRCDIR), end=' ') 367 367 print(os.path.relpath(t.input() , settings.SRCDIR), end=' ') 368 code, out = make_recon(t.target())368 code, out, err = make_recon(t.target()) 369 369 370 370 if code != 0: 371 print('ERROR: recond failed for test {} '.format(t.target()), file=sys.stderr)371 print('ERROR: recond failed for test {}: {} \'{}\''.format(t.target(), code, err), file=sys.stderr) 372 372 sys.exit(1) 373 373 … … 417 417 if is_empty(t.expect()): 418 418 print('WARNING: test "{}" has empty .expect file'.format(t.target()), file=sys.stderr) 419 420 options.jobs = job_count( options ) 419 421 420 422 # for each build configurations, run the test … … 430 432 local_tests = settings.ast.filter( tests ) 431 433 local_tests = settings.arch.filter( local_tests ) 432 options.jobs, forceJobs = job_count( options, local_tests )433 settings.update_make_cmd(forceJobs, options.jobs)434 434 435 435 # check the build configuration works 436 436 settings.validate() 437 jobs = min(options.jobs, len(local_tests)) 437 438 438 439 # print configuration … … 440 441 'Regenerating' if settings.generating else 'Running', 441 442 len(local_tests), 442 options.jobs,443 jobs, 443 444 settings.ast.string, 444 445 settings.arch.string, … … 450 451 451 452 # otherwise run all tests and make sure to return the correct error code 452 failed = run_tests(local_tests, options.jobs)453 failed = run_tests(local_tests, jobs) 453 454 if failed: 454 455 if not settings.continue_:
Note:
See TracChangeset
for help on using the changeset viewer.