- Timestamp:
- May 11, 2020, 1:53:29 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 504a7dc
- Parents:
- b7d6a36 (diff), a7b486b (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:
-
- 38 added
- 9 deleted
- 27 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
tests/.expect/alloc-ERROR.txt
rb7d6a36 r6a490b2 1 alloc.cfa:3 10:1 error: No reasonable alternatives for expression Applying untyped:1 alloc.cfa:362:1 error: No reasonable alternatives for expression Applying untyped: 2 2 Name: ?=? 3 3 ...to: 4 Name: p4 Name: ip 5 5 Applying untyped: 6 6 Name: realloc … … 19 19 20 20 21 alloc.cfa:3 11:1 error: No reasonable alternatives for expression Applying untyped:21 alloc.cfa:363:1 error: No reasonable alternatives for expression Applying untyped: 22 22 Name: ?=? 23 23 ...to: 24 Name: p 25 Applying untyped: 26 Name: alloc 27 ...to: 28 Name: stp 29 Applying untyped: 30 Name: ?*? 31 ...to: 32 Name: dim 33 Sizeof Expression on: Applying untyped: 34 Name: *? 35 ...to: 36 Name: stp 37 38 39 40 41 alloc.cfa:312:1 error: No reasonable alternatives for expression Applying untyped: 42 Name: ?=? 43 ...to: 44 Name: p 24 Name: ip 45 25 Applying untyped: 46 26 Name: memset … … 50 30 51 31 52 alloc.cfa:3 13:1 error: No reasonable alternatives for expression Applying untyped:32 alloc.cfa:364:1 error: No reasonable alternatives for expression Applying untyped: 53 33 Name: ?=? 54 34 ...to: 55 Name: p35 Name: ip 56 36 Applying untyped: 57 37 Name: memcpy -
tests/.expect/alloc.txt
rb7d6a36 r6a490b2 23 23 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0xefefefef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 24 24 25 CFA re sizearray alloc25 CFA realloc array alloc 26 26 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 27 CFA re sizearray alloc27 CFA realloc array alloc 28 28 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 29 CFA re sizearray alloc29 CFA realloc array alloc 30 30 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 31 CFA re size array alloc31 CFA realloc array alloc, fill 32 32 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 33 CFA re size array alloc33 CFA realloc array alloc, fill 34 34 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 35 CFA re sizearray alloc, fill35 CFA realloc array alloc, fill 36 36 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 37 37 -
tests/Makefile.am
rb7d6a36 r6a490b2 41 41 -quiet @CFA_FLAGS@ \ 42 42 -DIN_DIR="${abs_srcdir}/.in/" 43 44 AM_CFAFLAGS = -XCFA --deterministic-out 43 45 44 46 # get the desired cfa to test -
tests/Makefile.in
rb7d6a36 r6a490b2 408 408 -DIN_DIR="${abs_srcdir}/.in/" 409 409 410 AM_CFAFLAGS = -XCFA --deterministic-out 410 411 411 412 # get the desired cfa to test -
tests/alloc.cfa
rb7d6a36 r6a490b2 10 10 // Created On : Wed Feb 3 07:56:22 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 16 09:21:13 202013 // Update Count : 4 0512 // Last Modified On : Mon Apr 6 21:08:23 2020 13 // Update Count : 428 14 14 // 15 15 … … 28 28 size_t dim = 10; 29 29 char fill = '\xde'; 30 int * p, *p1;30 int * ip, * ip1; 31 31 32 32 // allocation, non-array types 33 33 34 p = (int *)malloc( sizeof(*p) ); // C malloc, type unsafe35 * p = 0xdeadbeef;36 printf( "C malloc %#x\n", * p );37 free( p );38 39 p = malloc();// CFA malloc, type safe40 * p = 0xdeadbeef;41 printf( "CFA malloc %#x\n", * p );42 free( p );43 44 p = alloc();// CFA alloc, type safe45 * p = 0xdeadbeef;46 printf( "CFA alloc %#x\n", * p );47 free( p );48 49 p = alloc_set( fill ); // CFA alloc, fill50 printf( "CFA alloc, fill %08x\n", * p );51 free( p );52 53 p = alloc_set( 3 );// CFA alloc, fill54 printf( "CFA alloc, fill %d\n", * p );55 free( p );34 ip = (int *)malloc( sizeof(*ip) ); // C malloc, type unsafe 35 *ip = 0xdeadbeef; 36 printf( "C malloc %#x\n", *ip ); 37 free( ip ); 38 39 ip = malloc(); // CFA malloc, type safe 40 *ip = 0xdeadbeef; 41 printf( "CFA malloc %#x\n", *ip ); 42 free( ip ); 43 44 ip = alloc(); // CFA alloc, type safe 45 *ip = 0xdeadbeef; 46 printf( "CFA alloc %#x\n", *ip ); 47 free( ip ); 48 49 ip = alloc_set( fill ); // CFA alloc, fill 50 printf( "CFA alloc, fill %08x\n", *ip ); 51 free( ip ); 52 53 ip = alloc_set( 3 ); // CFA alloc, fill 54 printf( "CFA alloc, fill %d\n", *ip ); 55 free( ip ); 56 56 57 57 … … 59 59 printf( "\n" ); 60 60 61 p = (int *)calloc( dim, sizeof( *p ) );// C array calloc, type unsafe61 ip = (int *)calloc( dim, sizeof( *ip ) ); // C array calloc, type unsafe 62 62 printf( "C array calloc, fill 0\n" ); 63 for ( i; dim ) { printf( "%#x ", p[i] ); }64 printf( "\n" ); 65 free( p );66 67 p = calloc( dim );// CFA array calloc, type safe63 for ( i; dim ) { printf( "%#x ", ip[i] ); } 64 printf( "\n" ); 65 free( ip ); 66 67 ip = calloc( dim ); // CFA array calloc, type safe 68 68 printf( "CFA array calloc, fill 0\n" ); 69 for ( i; dim ) { printf( "%#x ", p[i] ); }70 printf( "\n" ); 71 free( p );72 73 p = alloc( dim );// CFA array alloc, type safe74 for ( i; dim ) { p[i] = 0xdeadbeef; }69 for ( i; dim ) { printf( "%#x ", ip[i] ); } 70 printf( "\n" ); 71 free( ip ); 72 73 ip = alloc( dim ); // CFA array alloc, type safe 74 for ( i; dim ) { ip[i] = 0xdeadbeef; } 75 75 printf( "CFA array alloc, no fill\n" ); 76 for ( i; dim ) { printf( "%#x ", p[i] ); }77 printf( "\n" ); 78 free( p );79 80 p = alloc_set( 2 * dim, fill );// CFA array alloc, fill76 for ( i; dim ) { printf( "%#x ", ip[i] ); } 77 printf( "\n" ); 78 free( ip ); 79 80 ip = alloc_set( 2 * dim, fill ); // CFA array alloc, fill 81 81 printf( "CFA array alloc, fill %#hhx\n", fill ); 82 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }83 printf( "\n" ); 84 free( p );85 86 p = alloc_set( 2 * dim, 0xdeadbeef ); // CFA array alloc, fill82 for ( i; 2 * dim ) { printf( "%#x ", ip[i] ); } 83 printf( "\n" ); 84 free( ip ); 85 86 ip = alloc_set( 2 * dim, 0xdeadbeef ); // CFA array alloc, fill 87 87 printf( "CFA array alloc, fill %#hhx\n", 0xdeadbeef ); 88 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }89 printf( "\n" ); 90 // do not free 91 92 p1 = alloc_set( 2 * dim,p ); // CFA array alloc, fill88 for ( i; 2 * dim ) { printf( "%#x ", ip[i] ); } 89 printf( "\n" ); 90 // do not free 91 92 ip1 = alloc_set( 2 * dim, ip ); // CFA array alloc, fill 93 93 printf( "CFA array alloc, fill from array\n" ); 94 for ( i; 2 * dim ) { printf( "%#x %#x, ", p[i], p1[i] ); } 95 free( p1 ); 96 printf( "\n" ); 97 94 for ( i; 2 * dim ) { printf( "%#x %#x, ", ip[i], ip1[i] ); } 95 free( ip1 ); 96 printf( "\n" ); 97 98 99 // realloc, non-array types 100 printf( "\n" ); 101 102 ip = (int *)realloc( ip, dim * sizeof(*ip) ); // C realloc 103 printf( "C realloc\n" ); 104 for ( i; dim ) { printf( "%#x ", ip[i] ); } 105 printf( "\n" ); 106 // do not free 107 108 ip = realloc( ip, 2 * dim * sizeof(*ip) ); // CFA realloc 109 for ( i; dim ~ 2 * dim ) { ip[i] = 0x1010101; } 110 printf( "CFA realloc\n" ); 111 for ( i; 2 * dim ) { printf( "%#x ", ip[i] ); } 112 printf( "\n" ); 113 // do not free 114 115 116 // realloc, array types 117 printf( "\n" ); 118 119 ip = alloc( ip, dim ); // CFA realloc array alloc 120 for ( i; dim ) { ip[i] = 0xdeadbeef; } 121 printf( "CFA realloc array alloc\n" ); 122 for ( i; dim ) { printf( "%#x ", ip[i] ); } 123 printf( "\n" ); 124 // do not free 125 126 ip = alloc( ip, 2 * dim ); // CFA realloc array alloc 127 for ( i; dim ~ 2 * dim ) { ip[i] = 0x1010101; } // fill upper part 128 printf( "CFA realloc array alloc\n" ); 129 for ( i; 2 * dim ) { printf( "%#x ", ip[i] ); } 130 printf( "\n" ); 131 // do not free 132 133 ip = alloc( ip, dim ); // CFA realloc array alloc 134 printf( "CFA realloc array alloc\n" ); 135 for ( i; dim ) { printf( "%#x ", ip[i] ); } 136 printf( "\n" ); 137 // do not free 138 139 ip = alloc_set( ip, 3 * dim, fill ); // CFA realloc array alloc, fill 140 printf( "CFA realloc array alloc, fill\n" ); 141 for ( i; 3 * dim ) { printf( "%#x ", ip[i] ); } 142 printf( "\n" ); 143 // do not free 144 145 ip = alloc_set( ip, dim, fill ); // CFA realloc array alloc, fill 146 printf( "CFA realloc array alloc, fill\n" ); 147 for ( i; dim ) { printf( "%#x ", ip[i] ); } 148 printf( "\n" ); 149 // do not free 150 151 ip = alloc_set( ip, 3 * dim, fill ); // CFA realloc array alloc, fill 152 printf( "CFA realloc array alloc, fill\n" ); 153 for ( i; 3 * dim ) { printf( "%#x ", ip[i] ); } 154 printf( "\n" ); 155 // do not free 156 #if 0 // FIX ME 157 ip = alloc_set( ip, 5 * dim, 5 ); // CFA realloc array alloc, 5 158 printf( "CFA realloc array alloc, 5\n" ); 159 for ( i; 5 * dim ) { printf( "%#x ", ip[i] ); } 160 printf( "\n" ); 161 // do not free 162 163 ip = alloc_set( ip, dim, 5 ); // CFA realloc array alloc, 5 164 printf( "CFA realloc array alloc, 5\n" ); 165 for ( i; dim ) { printf( "%#x ", ip[i] ); } 166 printf( "\n" ); 167 // do not free 168 169 ip = alloc_set( ip, 5 * dim, 5 ); // CFA realloc array alloc, 5 170 printf( "CFA realloc array alloc, 5\n" ); 171 for ( i; 5 * dim ) { printf( "%#x ", ip[i] ); } 172 printf( "\n" ); 173 #endif // 0 174 free( ip ); 98 175 99 176 // resize, non-array types 100 printf( "\n" ); 101 102 p = (int *)realloc( p, dim * sizeof(*p) ); // C realloc103 printf( "C realloc\n" );104 for ( i; dim ) { printf( "%#x ", p[i] ); } 105 printf( "\n");106 // do not free107 108 p = realloc( p, 2 * dim * sizeof(*p) ); // CFA realloc109 for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; } 110 printf( "CFA realloc\n" );111 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 112 printf( "\n" );113 // do not free 177 178 struct S { 179 int a[5]; 180 }; 181 182 ip = alloc(); 183 *ip = 5; 184 double * dp = alloc( ip ); 185 *dp = 5.5; 186 S * sp = alloc( dp ); 187 *sp = (S){ {0, 1, 2, 3, 4} }; 188 ip = alloc( sp ); 189 *ip = 3; 190 free( ip ); 114 191 115 192 116 193 // resize, array types 117 printf( "\n" ); 118 119 p = alloc( p, dim ); // CFA resize array alloc 120 for ( i; dim ) { p[i] = 0xdeadbeef; } 121 printf( "CFA resize array alloc\n" ); 122 for ( i; dim ) { printf( "%#x ", p[i] ); } 123 printf( "\n" ); 124 // do not free 125 126 p = alloc( p, 2 * dim ); // CFA resize array alloc 127 for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; } // fill upper part 128 printf( "CFA resize array alloc\n" ); 129 for ( i; 2 * dim ) { printf( "%#x ", p[i] ); } 130 printf( "\n" ); 131 // do not free 132 133 p = alloc( p, dim ); // CFA resize array alloc 134 printf( "CFA resize array alloc\n" ); 135 for ( i; dim ) { printf( "%#x ", p[i] ); } 136 printf( "\n" ); 137 // do not free 138 139 p = alloc_set( p, 3 * dim, fill ); // CFA resize array alloc, fill 140 printf( "CFA resize array alloc\n" ); 141 for ( i; 3 * dim ) { printf( "%#x ", p[i] ); } 142 printf( "\n" ); 143 // do not free 144 145 p = alloc_set( p, dim, fill ); // CFA resize array alloc, fill 146 printf( "CFA resize array alloc\n" ); 147 for ( i; dim ) { printf( "%#x ", p[i] ); } 148 printf( "\n" ); 149 // do not free 150 151 p = alloc_set( p, 3 * dim, fill ); // CFA resize array alloc, fill 152 printf( "CFA resize array alloc, fill\n" ); 153 for ( i; 3 * dim ) { printf( "%#x ", p[i] );; } 154 printf( "\n" ); 155 free( p ); 194 195 ip = alloc( 5 ); 196 for ( i; 5 ) { ip[i] = 5; } 197 dp = alloc( ip, 5 ); 198 for ( i; 5 ) { dp[i] = 5.5; } 199 sp = alloc( dp, 5 ); 200 for ( i; 5 ) { sp[i] = (S){ {0, 1, 2, 3, 4} }; } 201 ip = alloc( sp, 3 ); 202 for ( i; 3 ) { ip[i] = 3; } 203 ip = alloc( ip, 7 ); 204 for ( i; 7 ) { ip[i] = 7; } 205 ip = alloc( ip, 7, false ); 206 for ( i; 7 ) { ip[i] = 7; } 207 free( ip ); 156 208 157 209 … … 168 220 free( stp ); 169 221 170 stp = &(*memalign( Alignment )){ 42, 42.5 }; 222 stp = &(*memalign( Alignment )){ 42, 42.5 }; // CFA memalign 171 223 assert( (uintptr_t)stp % Alignment == 0 ); 172 224 printf( "CFA memalign %d %g\n", stp->x, stp->y ); … … 300 352 free( fp - 1 ); 301 353 302 p = foo( bar( baz( malloc(), 0 ), 0 ), 0 );303 * p = 0xdeadbeef;304 printf( "CFA deep malloc %#x\n", * p );305 free( p );354 ip = foo( bar( baz( malloc(), 0 ), 0 ), 0 ); 355 *ip = 0xdeadbeef; 356 printf( "CFA deep malloc %#x\n", *ip ); 357 free( ip ); 306 358 307 359 #ifdef ERR1 308 360 stp = malloc(); 309 361 printf( "\nSHOULD FAIL\n" ); 310 p = realloc( stp, dim * sizeof( *stp ) ); 311 p = alloc( stp, dim * sizeof( *stp ) ); 312 p = memset( stp, 10 ); 313 p = memcpy( &st1, &st ); 362 ip = realloc( stp, dim * sizeof( *stp ) ); 363 ip = memset( stp, 10 ); 364 ip = memcpy( &st1, &st ); 314 365 #endif 315 366 } // main -
tests/concurrent/.expect/monitor.txt
rb7d6a36 r6a490b2 1 40000001 3000000 -
tests/concurrent/coroutineYield.cfa
rb7d6a36 r6a490b2 33 33 sout | "Coroutine 2"; 34 34 #endif 35 suspend ();35 suspend; 36 36 } 37 37 } -
tests/concurrent/monitor.cfa
rb7d6a36 r6a490b2 29 29 30 30 void main( MyThread & this ) { 31 for(int i = 0; i < 1_000_000; i++) {31 for(int i = 0; i < 750_000; i++) { 32 32 increment( global ); 33 33 } -
tests/concurrent/multi-monitor.cfa
rb7d6a36 r6a490b2 11 11 12 12 void increment( monitor_t & mutex p1, monitor_t & mutex p2, int & value ) { 13 assert(active_thread() == get_monitor(p1)->owner); 14 assert(active_thread() == get_monitor(p2)->owner); 13 15 value += 1; 16 assert(active_thread() == get_monitor(p1)->owner); 17 assert(active_thread() == get_monitor(p2)->owner); 14 18 } 15 19 -
tests/concurrent/signal/block.cfa
rb7d6a36 r6a490b2 33 33 34 34 monitor global_data_t { 35 thread_desc* last_thread;36 thread_desc* last_signaller;35 $thread * last_thread; 36 $thread * last_signaller; 37 37 }; 38 38 … … 82 82 if( !is_empty( cond ) ) { 83 83 84 thread_desc* next = front( cond );84 $thread * next = front( cond ); 85 85 86 86 if( ! signal_block( cond ) ) { -
tests/concurrent/suspend_then.cfa
rb7d6a36 r6a490b2 1 1 #include <fstream.hfa> 2 2 #include <kernel.hfa> 3 #include <monitor.hfa>4 3 #include <thread.hfa> 5 4 #include <time.hfa> … … 10 9 #include "long_tests.hfa" 11 10 12 #ifndef PREEMPTION_RATE13 #define PREEMPTION_RATE 10`ms14 #endif15 16 11 Duration default_preemption() { 17 return PREEMPTION_RATE;12 return 0; 18 13 } 19 14 … … 26 21 #if !defined(TEST_FOREVER) 27 22 static inline void print(const char * const text ) { 28 write( STD ERR_FILENO, text, strlen(text) );23 write( STDOUT_FILENO, text, strlen(text) ); 29 24 } 30 25 #else … … 32 27 #endif 33 28 34 coroutine Coroutine {};29 generator Coroutine { int i; }; 35 30 36 31 volatile bool done = false; … … 49 44 50 45 void main(Coroutine& this) { 51 suspend(); 52 for(int i = 0; TEST(i < N); i++) { 46 this.i = 0; 47 suspend; 48 for(;TEST(this.i < N); this.i++) { 53 49 54 print("C - Suspending ");55 void publish(){56 print("C - Publishing ");50 print("C - Suspending\n"); 51 suspend{ 52 print("C - Publishing\n"); 57 53 assert(!the_cor); 58 54 store( this ); 59 55 } 60 suspend_then(publish);61 56 assert(!the_cor); 62 print("C oroutine 2");57 print("C - Back\n"); 63 58 KICK_WATCHDOG; 64 59 yield(); 65 60 } 66 61 done = true; 67 suspend ();62 suspend; 68 63 } 69 64 … … 77 72 if(!mine) continue; 78 73 79 print("T - took ");74 print("T - took\n"); 80 75 resume(*mine); 81 print("T - back");82 76 } 83 77 } -
tests/coroutine/.expect/fmtLines.txt
rb7d6a36 r6a490b2 48 48 { // f or n ewli 49 49 ne c hara cter s su 50 spen d (); if ( fm51 t.ch != '\n' ) b reak52 ; / / ig nore new line53 } // for sout54 | f mt.c h; //55 prin t ch arac ter }56 // f or sou t | " "57 ; // prin t bl58 ock sepa rato r } //59 for sou t | nl;60 // p rint gro up s61 epar ator } / / fo r} /62 / ma invo id p rt( Form63 at & fmt , ch ar c h )64 { fmt .ch = ch ;65 res ume( fmt );} //66 prti nt m ain( ) { Form67 at f mt; char ch; for68 ( ; ; ) { s in | ch;69 // rea d on70 e ch arac ter if ( e71 of( sin ) ) brea k;72 // eof ? p rt(73 fmt, ch ); } // for}74 // main // L ocal Var75 iabl es: //// tab -wid76 th: 4 // // c ompi le-c77 omma nd: "cfa fmt Line78 s.cf a" / /// End: //50 spen d; i f ( fmt. 51 ch ! = '\ n' ) bre ak; 52 // igno re n ewli ne 53 } // f or so ut | 54 fmt .ch; / / pr 55 int char acte r } // 56 for s out | " "; 57 / / pr int bloc 58 k se para tor } / / fo 59 r s out | nl ; 60 // pri nt g roup sep 61 arat or } // for} // 62 main void prt ( Fo rmat 63 & f mt, char ch ) { 64 f mt.c h = ch; r 65 esum e( f mt ) ;} / / pr 66 tint mai n() { Fo rmat 67 fmt ; ch ar c h; f or ( 68 ;; ) { sin | c h; 69 // r ead one 70 char acte r if ( eof 71 ( si n ) ) br eak; 72 / / eo f ? prt ( fm 73 t, c h ); } / / fo r} / 74 / ma in// Loc al V aria 75 bles : // // t ab-w idth 76 : 4 //// com pile -com 77 mand : "c fa f mtLi nes. 78 cfa" /// / En d: / / -
tests/coroutine/.in/fmtLines.txt
rb7d6a36 r6a490b2 35 35 for ( fmt.b = 0; fmt.b < 4; fmt.b += 1 ) { // blocks of 4 characters 36 36 for ( ;; ) { // for newline characters 37 suspend ();37 suspend; 38 38 if ( fmt.ch != '\n' ) break; // ignore newline 39 39 } // for -
tests/coroutine/cntparens.cfa
rb7d6a36 r6a490b2 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 6 // 7 7 // cntparens.cfa -- match left/right parenthesis 8 // 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Apr 20 11:04:45 2019 … … 12 12 // Last Modified On : Sat Apr 20 11:06:21 2019 13 13 // Update Count : 1 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 26 26 void main( CntParens & cpns ) with( cpns ) { 27 27 for ( ; ch == '('; cnt += 1 ) { // left parenthesis 28 suspend ();28 suspend; 29 29 } 30 30 for ( ; ch == ')' && cnt > 1; cnt -= 1 ) { // right parenthesis 31 suspend ();31 suspend; 32 32 } 33 33 status = ch == ')' ? Match : Error; 34 34 } // main 35 35 36 36 void ?{}( CntParens & cpns ) with( cpns ) { status = Cont; cnt = 0; } 37 37 -
tests/coroutine/devicedriver.cfa
rb7d6a36 r6a490b2 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 3 // 4 4 // The contents of this file are covered under the licence agreement in the 5 5 // file "LICENCE" distributed with Cforall. 6 // 7 // devicedriver.cfa -- 8 // 6 // 7 // devicedriver.cfa -- 8 // 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Mar 16 15:30:34 2019 … … 12 12 // Last Modified On : Sat Apr 20 09:07:19 2019 13 13 // Update Count : 90 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 29 29 30 30 void checkCRC( Driver & d, unsigned int sum ) with( d ) { 31 suspend ();31 suspend; 32 32 unsigned short int crc = byte << 8; // sign extension over written 33 suspend ();33 suspend; 34 34 // prevent sign extension for signed char 35 35 status = (crc | (unsigned char)byte) == sum ? MSG : ECRC; … … 41 41 status = CONT; 42 42 unsigned int lnth = 0, sum = 0; 43 while ( byte != STX ) suspend ();43 while ( byte != STX ) suspend; 44 44 emsg: for () { 45 suspend ();45 suspend; 46 46 choose ( byte ) { // process byte 47 47 case STX: 48 status = ESTX; suspend (); continue msg;48 status = ESTX; suspend; continue msg; 49 49 case ETX: 50 50 break emsg; 51 51 case ESC: 52 suspend ();52 suspend; 53 53 } // choose 54 54 if ( lnth >= MaxMsg ) { // buffer full ? 55 status = ELNTH; suspend (); continue msg;55 status = ELNTH; suspend; continue msg; 56 56 } // if 57 57 msg[lnth++] = byte; … … 60 60 msg[lnth] = '\0'; // terminate string 61 61 checkCRC( d, sum ); // refactor CRC check 62 suspend ();62 suspend; 63 63 } // for 64 64 } // main -
tests/coroutine/fibonacci.cfa
rb7d6a36 r6a490b2 22 22 int fn1, fn2; // retained between resumes 23 23 fn = 0; fn1 = fn; // 1st case 24 suspend (); // restart last resume24 suspend; // restart last resume 25 25 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 26 suspend (); // restart last resume26 suspend; // restart last resume 27 27 for () { 28 28 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 29 suspend (); // restart last resume29 suspend; // restart last resume 30 30 } // for 31 31 } -
tests/coroutine/fibonacci_1.cfa
rb7d6a36 r6a490b2 12 12 // Last Modified On : Thu Mar 21 08:10:45 2019 13 13 // Update Count : 25 14 // 14 // 15 15 16 16 #include <fstream.hfa> … … 23 23 [fn1, fn] = [0, 1]; // precompute first two states 24 24 for () { 25 suspend (); // restart last resume25 suspend; // restart last resume 26 26 [fn1, fn] = [fn, fn1 + fn]; // general case 27 27 } // for -
tests/coroutine/fmtLines.cfa
rb7d6a36 r6a490b2 27 27 for ( b = 0; b < 4; b += 1 ) { // blocks of 4 characters 28 28 for () { // for newline characters 29 suspend ();29 suspend; 30 30 if ( ch != '\n' ) break; // ignore newline 31 31 } // for -
tests/coroutine/raii.cfa
rb7d6a36 r6a490b2 39 39 Raii raii = { "Coroutine" }; 40 40 sout | "Before Suspend"; 41 suspend ();41 suspend; 42 42 sout | "After Suspend"; 43 43 } -
tests/coroutine/runningTotal.cfa
rb7d6a36 r6a490b2 25 25 void update( RunTotal & rntl, int input ) with( rntl ) { // helper 26 26 total += input; // remember between activations 27 suspend (); // inactivate on stack27 suspend; // inactivate on stack 28 28 } 29 29 -
tests/coroutine/suspend_then.cfa
rb7d6a36 r6a490b2 15 15 16 16 #include <fstream.hfa> 17 #include <coroutine.hfa>18 17 19 void then() { 20 sout | "Then!"; 21 } 22 23 coroutine Fibonacci { int fn; }; // used for communication 18 generator Fibonacci { 19 int fn; // used for communication 20 int fn1, fn2; // retained between resumes 21 }; 24 22 25 23 void main( Fibonacci & fib ) with( fib ) { // called on first resume 26 int fn1, fn2; // retained between resumes27 24 fn = 0; fn1 = fn; // 1st case 28 suspend _then(then);// restart last resume25 suspend { sout | "Then!"; } // restart last resume 29 26 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 30 suspend _then(then);// restart last resume27 suspend { sout | "Then!"; } // restart last resume 31 28 for () { 32 29 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 33 suspend _then(then);// restart last resume30 suspend { sout | "Then!"; } // restart last resume 34 31 } // for 35 32 } -
tests/errors/.expect/completeType.txt
rb7d6a36 r6a490b2 27 27 void 28 28 ) 29 Environment: ( _83_4_DT )-> instance of struct A with body 0 (no widening)29 Environment: -> instance of struct A with body 0 (no widening) 30 30 31 31 … … 50 50 void 51 51 ) 52 Environment: ( _83_4_DT )-> instance of struct B with body 1 (no widening)52 Environment: -> instance of struct B with body 1 (no widening) 53 53 54 54 … … 127 127 void 128 128 ) 129 Environment: ( _102_0_T )-> instance of type T (not function type) (no widening)129 Environment: -> instance of type T (not function type) (no widening) 130 130 131 131 Could not satisfy assertion: 132 132 ?=?: pointer to function 133 133 ... with parameters 134 reference to instance of type _10 2_0_T (not function type)135 instance of type _10 2_0_T (not function type)134 reference to instance of type _104_0_T (not function type) 135 instance of type _104_0_T (not function type) 136 136 ... returning 137 _retval__operator_assign: instance of type _10 2_0_T (not function type)137 _retval__operator_assign: instance of type _104_0_T (not function type) 138 138 ... with attributes: 139 139 Attribute with name: unused -
tests/manipulatorsOutput1.cfa
rb7d6a36 r6a490b2 7 7 // Created On : Sat Jun 8 18:04:11 2019 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : Mon Jun 10 12:37:28 201910 // Update Count : 89 // Last Modified On : Fri May 1 11:51:44 2020 10 // Update Count : 9 11 11 // 12 12 … … 17 17 signed char sc = -12; 18 18 printf( "%hhd %2hhd %5.2hhd %-5.2hhd %hho %#hho %hhx %#hhx %#8hhx %#8.10hhx %#8.3hhX %+-8.3hhd %08hhd\n", sc, sc, sc, sc, sc, sc, sc, sc, sc, sc, sc, sc, sc ); 19 sout | sc | wd(2,sc) | wd(5,2,sc) | left(wd(5,2,sc)) | nobase(oct(sc)) | oct(sc) | nobase(hex(sc)) | hex(sc) | wd(8,hex(sc)) | wd(8,10,hex(sc)) | upcase(wd(8,3,hex(sc))) | left(sign(upcase(wd(8,3,sc)))) | pad0(wd(8,sc)); 19 sout | sc | wd(2,sc) | wd(5,2,sc) | left(wd(5,2,sc)) | nobase(oct(sc)) | oct(sc) | nonl; 20 sout | nobase(hex(sc)) | hex(sc) | wd(8,hex(sc)) | wd(8,10,hex(sc)) | upcase(wd(8,3,hex(sc))) | nonl; 21 sout | left(sign(upcase(wd(8,3,sc)))) | pad0(wd(8,sc)); 20 22 21 23 sout | "unsigned char"; 22 24 unsigned char usc = 12; 23 25 printf( "%hhu %2hhu %5.2hhu %-5.2hhu %hho %#hho %hhx %#hhx %#8hhx %#8.10hhx %#8.3hhX %-8.3hhu %08hhu\n", usc, usc, usc, usc, usc, usc, usc, usc, usc, usc, usc, usc, usc ); 24 sout | usc | wd(2,usc) | wd(5,2,usc) | left(wd(5,2,usc)) | nobase(oct(usc)) | oct(usc) | nobase(hex(usc)) | hex(usc) | wd(8,hex(usc)) | wd(8,10,hex(usc)) | upcase(wd(8,3,hex(usc))) | left(upcase(wd(8,3,usc))) | pad0(wd(8,usc)); 26 sout | usc | wd(2,usc) | wd(5,2,usc) | left(wd(5,2,usc)) | nobase(oct(usc)) | oct(usc) | nonl; 27 sout | nobase(hex(usc)) | hex(usc) | wd(8,hex(usc)) | wd(8,10,hex(usc)) | upcase(wd(8,3,hex(usc))) | nonl; 28 sout | left(upcase(wd(8,3,usc))) | pad0(wd(8,usc)); 25 29 26 30 sout | "signed short int"; 27 31 signed short int si = -12; 28 32 printf( "%hd %2hd %5.2hd %-5.2hd %ho %#ho %hx %#hx %#8hx %#8.10hx %#8.3hX %+-8.3hd %08hd\n", si, si, si, si, si, si, si, si, si, si, si, si, si ); 29 sout | si | wd(2,si) | wd(5,2,si) | left(wd(5,2,si)) | nobase(oct(si)) | oct(si) | nobase(hex(si)) | hex(si) | wd(8,hex(si)) | wd(8,10,hex(si)) | upcase(wd(8,3,hex(si))) | left(sign(upcase(wd(8,3,si)))) | pad0(wd(8,si)); 33 sout | si | wd(2,si) | wd(5,2,si) | left(wd(5,2,si)) | nobase(oct(si)) | oct(si) | nonl; 34 sout | nobase(hex(si)) | hex(si) | wd(8,hex(si)) | wd(8,10,hex(si)) | upcase(wd(8,3,hex(si))) | nonl; 35 sout | left(sign(upcase(wd(8,3,si)))) | pad0(wd(8,si)); 30 36 31 37 sout | "unsigned short int"; 32 38 unsigned short int usi = 12; 33 39 printf( "%hu %2hu %5.2hu %-5.2hu %ho %#ho %hx %#hx %#8hx %#8.10hx %#8.3hX %-8.3hu %08hu\n", usi, usi, usi, usi, usi, usi, usi, usi, usi, usi, usi, usi, usi ); 34 sout | usi | wd(2,usi) | wd(5,2,usi) | left(wd(5,2,usi)) | nobase(oct(usi)) | oct(usi) | nobase(hex(usi)) | hex(usi) | wd(8,hex(usi)) | wd(8,10,hex(usi)) | upcase(wd(8,3,hex(usi))) | left(upcase(wd(8,3,usi))) | pad0(wd(8,usi)); 40 sout | usi | wd(2,usi) | wd(5,2,usi) | left(wd(5,2,usi)) | nobase(oct(usi)) | oct(usi) | nonl; 41 sout | nobase(hex(usi)) | hex(usi) | wd(8,hex(usi)) | wd(8,10,hex(usi)) | upcase(wd(8,3,hex(usi))) | nonl; 42 sout | left(upcase(wd(8,3,usi))) | pad0(wd(8,usi)); 35 43 36 44 sout | "signed int"; 37 45 signed int i = -12; 38 46 printf( "%d %2d %5.2d %-5.2d %o %#o %x %#x %#8x %#8.10x %#8.3X %+-8.3d %08d\n", i, i, i, i, i, i, i, i, i, i, i, i, i ); 39 sout | i | wd(2,i) | wd(5,2,i) | left(wd(5,2,i)) | nobase(oct(i)) | oct(i) | nobase(hex(i)) | hex(i) | wd(8,hex(i)) | wd(8,10,hex(i)) | upcase(wd(8,3,hex(i))) | left(sign(upcase(wd(8,3,i)))) | pad0(wd(8,i)); 47 sout | i | wd(2,i) | wd(5,2,i) | left(wd(5,2,i)) | nobase(oct(i)) | oct(i) | nonl; 48 sout | nobase(hex(i)) | hex(i) | wd(8,hex(i)) | wd(8,10,hex(i)) | upcase(wd(8,3,hex(i))) | nonl; 49 sout | left(sign(upcase(wd(8,3,i)))) | pad0(wd(8,i)); 40 50 41 51 sout | "unsigned int"; 42 52 unsigned int ui = 12; 43 53 printf( "%u %2u %5.2u %-5.2u %o %#o %x %#x %#8x %#8.10x %#8.3X %-8.3u %08u\n", ui, ui, ui, ui, ui, ui, ui, ui, ui, ui, ui, ui, ui ); 44 sout | ui | wd(2,ui) | wd(5,2,ui) | left(wd(5,2,ui)) | nobase(oct(ui)) | oct(ui) | nobase(hex(ui)) | hex(ui) | wd(8,hex(ui)) | wd(8,10,hex(ui)) | upcase(wd(8,3,hex(ui))) | left(upcase(wd(8,3,ui))) | pad0(wd(8,ui)); 54 sout | ui | wd(2,ui) | wd(5,2,ui) | left(wd(5,2,ui)) | nobase(oct(ui)) | oct(ui) | nonl; 55 sout | nobase(hex(ui)) | hex(ui) | wd(8,hex(ui)) | wd(8,10,hex(ui)) | upcase(wd(8,3,hex(ui))) | nonl; 56 sout | left(upcase(wd(8,3,ui))) | pad0(wd(8,ui)); 45 57 46 58 sout | "signed long long int"; 47 59 signed long long int lli = -12; 48 60 printf( "%lld %2lld %5.2lld %-5.2lld %llo %#llo %llx %#llx %#8llx %#8.10llx %#8.3llX %+-8.3lld %08lld\n", lli, lli, lli, lli, lli, lli, lli, lli, lli, lli, lli, lli, lli ); 49 sout | lli | wd(2,lli) | wd(5,2,lli) | left(wd(5,2,lli)) | nobase(oct(lli)) | oct(lli) | nobase(hex(lli)) | hex(lli) | wd(8,hex(lli)) | wd(8,10,hex(lli)) | upcase(wd(8,3,hex(lli))) | left(sign(upcase(wd(8,3,lli)))) | pad0(wd(8,lli)); 61 sout | lli | wd(2,lli) | wd(5,2,lli) | left(wd(5,2,lli)) | nobase(oct(lli)) | oct(lli) | nonl; 62 sout | nobase(hex(lli)) | hex(lli) | wd(8,hex(lli)) | wd(8,10,hex(lli)) | upcase(wd(8,3,hex(lli))) | nonl; 63 sout | left(sign(upcase(wd(8,3,lli)))) | pad0(wd(8,lli)); 50 64 51 65 sout | "unsigned long long int"; 52 66 unsigned long long int ulli = 12; 53 67 printf( "%llu %2llu %5.2llu %-5.2llu %llo %#llo %llx %#llx %#8llx %#8.10llx %#8.3llX %-8.3llu %08llu\n", ulli, ulli, ulli, ulli, ulli, ulli, ulli, ulli, ulli, ulli, ulli, ulli, ulli ); 54 sout | ulli | wd(2,ulli) | wd(5,2,ulli) | left(wd(5,2,ulli)) | nobase(oct(ulli)) | oct(ulli) | nobase(hex(ulli)) | hex(ulli) | wd(8,hex(ulli)) | wd(8,10,hex(ulli)) | upcase(wd(8,3,hex(ulli))) | left(upcase(wd(8,3,ulli))) | pad0(wd(8,ulli)); 68 sout | ulli | wd(2,ulli) | wd(5,2,ulli) | left(wd(5,2,ulli)) | nobase(oct(ulli)) | oct(ulli) | nonl; 69 sout | nobase(hex(ulli)) | hex(ulli) | wd(8,hex(ulli)) | wd(8,10,hex(ulli)) | upcase(wd(8,3,hex(ulli))) | nonl; 70 sout | left(upcase(wd(8,3,ulli))) | pad0(wd(8,ulli)); 55 71 56 72 sout | nl | "binary integral"; 57 sout | bin(0) | bin(13) | upcase(bin(13)) | nobase(bin(13)) | left(wd(8,bin(13))) | wd(8,bin(13)) | pad0(left(wd(8,bin(13)))) | pad0(wd(8,bin(13))) | pad0(wd(8,10,bin(13))) | pad0(wd(8,6,bin(13))); 73 sout | bin(0) | bin(13) | upcase(bin(13)) | nobase(bin(13)) | left(wd(8,bin(13))) | wd(8,bin(13)) | nonl; 74 sout | pad0(left(wd(8,bin(13)))) | pad0(wd(8,bin(13))) | pad0(wd(8,10,bin(13))) | pad0(wd(8,6,bin(13))); 58 75 59 76 … … 62 79 printf( "%g %8g %#8g %g %8g %8.0g %#8.0g %8.2g %#8.2g %-8.2g %-8.2g %-#8.2g %-+8.2g %-+#8.2g %08.2g %8.2E %8.2a %#8.2A %#8.2e\n", 63 80 0.0,3.0F,3.0F, f, f, f, f, f, f, 3.0F, f, f, f, f, f, f, f, f, f ); 64 sout | 0.0 | wd(8, 3.0F) | nodp(wd(8, 3.0F)) | f | wd(8, f) | ws(8,0, f) | nodp(ws(8,0, f)) | ws(8,2, f) | nodp(ws(8,2, f)) | left(ws(8,2, 3.0F)) | left(ws(8,2, f)) | left(nodp(ws(8,2, f))) | left(sign(ws(8,2, f))) | left(sign(nodp(ws(8,2, f)))) | pad0(ws(8,2, f)) | upcase(wd(8,2, sci(f))) | wd(8,2, hex(f)) | upcase(wd(8,2, hex(f))) | nodp(wd(8,2, sci(f))); 81 sout | 0.0 | wd(8, 3.0F) | nodp(wd(8, 3.0F)) | f | wd(8, f) | ws(8,0, f) | nodp(ws(8,0, f)) | ws(8,2, f) | nodp(ws(8,2, f)) | nonl; 82 sout | left(ws(8,2, 3.0F)) | left(ws(8,2, f)) | left(nodp(ws(8,2, f))) | left(sign(ws(8,2, f))) | left(sign(nodp(ws(8,2, f)))) | nonl; 83 sout | pad0(ws(8,2, f)) | upcase(wd(8,2, sci(f))) | wd(8,2, hex(f)) | upcase(wd(8,2, hex(f))) | nodp(wd(8,2, sci(f))); 65 84 66 85 sout | "double"; … … 68 87 printf( "%g %#8f %g %8f %#8.0f %8.0f %8.2f %-8.2f %-+#8.2f %08.2F %8.2E %8.2a %8.2A %8.2e\n", 69 88 0.0, 3.0, d, d, d, d, d, d, d, d, d, d, d, d ); 70 sout | 0.0 | wd(8, 3.0) | d | wd(8, d) | nodp(wd(8,0, d)) | wd(8,0, d) | wd(8,2, d) | left(wd(8,2, d)) | left(sign(wd(8,2, d))) | pad0(upcase(wd(8,2, d))) | upcase(wd(8,2, sci(d))) | wd(8,2, hex(d)) | upcase(wd(8,2, hex(d))) | wd(8,2, sci(d)); 89 sout | 0.0 | wd(8, 3.0) | d | wd(8, d) | nodp(wd(8,0, d)) | wd(8,0, d) | wd(8,2, d) | nonl; 90 sout | left(wd(8,2, d)) | left(sign(wd(8,2, d))) | pad0(upcase(wd(8,2, d))) | upcase(wd(8,2, sci(d))) | wd(8,2, hex(d)) | upcase(wd(8,2, hex(d))) | wd(8,2, sci(d)); 71 91 72 92 sout | "long double"; … … 74 94 printf( "%Lg %#8Lf %Lg %8Lf %#8.0Lf %8.0Lf %8.2Lf %-8.2Lf %-+#8.2Lf %08.2LF %8.2LE %8.2La %8.2LA %8.2Le\n", 75 95 0.0L, 3.0L, ld, ld, ld, ld, ld, ld, ld, ld, ld, ld, ld, ld ); 76 sout | 0.0L | wd(8, 3.0L) | ld | wd(8, ld) | nodp(wd(8,0, ld)) | wd(8,0, ld) | wd(8,2, ld) | left(wd(8,2, ld)) | left(sign(wd(8,2, ld))) | pad0(upcase(wd(8,2, ld))) | upcase(wd(8,2, sci(ld))) | wd(8,2, hex(ld)) | upcase(wd(8,2, hex(ld))) | wd(8,2, sci(ld)); 96 sout | 0.0L | wd(8, 3.0L) | ld | wd(8, ld) | nodp(wd(8,0, ld)) | wd(8,0, ld) | wd(8,2, ld) | nonl; 97 sout | left(wd(8,2, ld)) | left(sign(wd(8,2, ld))) | pad0(upcase(wd(8,2, ld))) | upcase(wd(8,2, sci(ld))) | wd(8,2, hex(ld)) | upcase(wd(8,2, hex(ld))) | wd(8,2, sci(ld)); 77 98 78 99 … … 80 101 char c = 'a'; 81 102 printf( "%c %2c %5c %-5c %hho %#hho %hhx %#hhx %#8hhx %#8hhX %-8c %8c\n", c, c, c, c, c, c, c, c, c, c, c, c ); 82 sout | c | ' ' | wd(2,c) | wd(5,c) | left(wd(5,c)) | nobase(oct(c)) | oct(c) | nobase(hex(c)) | hex(c) | wd(8,hex(c)) | upcase(wd(8,hex(c))) | left(wd(8,c)) | wd(8,c); 103 sout | c | ' ' | wd(2,c) | wd(5,c) | left(wd(5,c)) | nobase(oct(c)) | oct(c) | nonl; 104 sout | nobase(hex(c)) | hex(c) | wd(8,hex(c)) | upcase(wd(8,hex(c))) | left(wd(8,c)) | wd(8,c); 83 105 84 106 sout | nl | "string"; -
tests/pybin/settings.py
rb7d6a36 r6a490b2 23 23 class Architecture: 24 24 KnownArchitectures = { 25 'x64' 26 'x86-64' 27 'x86_64' 28 'x86' 29 'aarch64' 30 'i386' 31 'i486' 32 'i686' 33 'Intel 80386' 34 'arm' 35 'ARM' 25 'x64' : 'x64', 26 'x86-64' : 'x64', 27 'x86_64' : 'x64', 28 'x86' : 'x86', 29 'aarch64' : 'arm', 30 'i386' : 'x86', 31 'i486' : 'x86', 32 'i686' : 'x86', 33 'Intel 80386' : 'x86', 34 'arm' : 'arm', 35 'ARM' : 'arm', 36 36 } 37 37 … … 77 77 print("updated to %s" % self.target) 78 78 79 def match(self, arch): 79 def filter(self, tests): 80 return [test for test in tests if not test.arch or self.target == test.arch] 80 81 return True if not arch else self.target == arch 81 82 82 @ classmethod83 def make_canonical( _,arch):83 @staticmethod 84 def make_canonical(arch): 84 85 return Architecture.KnownArchitectures[arch] 85 86 … … 104 105 self.total = Timeouts.check(tg) 105 106 106 @ classmethod107 def check( _,value):107 @staticmethod 108 def check(value): 108 109 if value < 1: 109 110 print("Timeouts must be at least 1 second", file=sys.stderr) … … 113 114 114 115 def init( options ): 116 global all_arch 117 global all_debug 118 global all_install 115 119 global arch 116 120 global archive 121 global continue_ 117 122 global debug 118 global distcc119 123 global dry_run 120 124 global generating … … 123 127 global output_width 124 128 global timeout 129 global timeout2gdb 125 130 126 arch = Architecture(options.arch) 131 all_arch = [Architecture(o) for o in list(dict.fromkeys(options.arch ))] if options.arch else [Architecture(None)] 132 all_debug = [Debug(o) for o in list(dict.fromkeys(options.debug ))] 133 all_install = [Install(o) for o in list(dict.fromkeys(options.install))] 127 134 archive = os.path.abspath(os.path.join(original_path, options.archive_errors)) if options.archive_errors else None 128 debug = Debug(options.debug)135 continue_ = options.continue_ 129 136 dry_run = options.dry_run # must be called before tools.config_hash() 130 distcc = "DISTCC_CFA_PATH=~/.cfadistcc/%s/cfa" % tools.config_hash()131 137 generating = options.regenerate_expected 132 install = Install(options.install)133 138 make = ['make'] 134 139 output_width = 24 135 140 timeout = Timeouts(options.timeout, options.global_timeout) 141 timeout2gdb = options.timeout_with_gdb 136 142 137 143 # if we distribute, distcc errors will fail tests, use log file for distcc … … 146 152 147 153 def validate(): 154 """Validate the current configuration and update globals""" 155 156 global distcc 157 distcc = "DISTCC_CFA_PATH=~/.cfadistcc/%s/cfa" % tools.config_hash() 148 158 errf = os.path.join(BUILDDIR, ".validate.err") 149 159 make_ret, out = tools.make( ".validate", error_file = errf, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL ) -
tests/pybin/test_run.py
rb7d6a36 r6a490b2 40 40 return os.path.normpath( os.path.join(settings.BUILDDIR, self.path, self.name) ) 41 41 42 @ classmethod43 def valid_name( _,name):42 @staticmethod 43 def valid_name(name): 44 44 return not name.endswith( ('.c', '.cc', '.cpp', '.cfa') ) 45 45 46 @ classmethod47 def from_target(_, target):46 @staticmethod 47 def new_target(target, arch): 48 48 test = Test() 49 49 test.name = os.path.basename(target) 50 50 test.path = os.path.relpath (os.path.dirname(target), settings.SRCDIR) 51 test.arch = settings.arch.target if settings.arch.cross_compileelse ''51 test.arch = arch.target if arch else '' 52 52 return test 53 53 … … 72 72 return text 73 73 74 @ classmethod75 def fmtDur( cls,duration ):74 @staticmethod 75 def fmtDur( duration ): 76 76 if duration : 77 77 hours, rem = divmod(duration, 3600) -
tests/pybin/tools.py
rb7d6a36 r6a490b2 75 75 return proc.returncode, out.decode("utf-8") if out else None 76 76 except subprocess.TimeoutExpired: 77 proc.send_signal(signal.SIGABRT) 78 proc.communicate() 79 return 124, str(None) 77 if settings.timeout2gdb: 78 print("Process {} timeout".format(proc.pid)) 79 proc.communicate() 80 return 124, str(None) 81 else: 82 proc.send_signal(signal.SIGABRT) 83 proc.communicate() 84 return 124, str(None) 80 85 81 86 except Exception as ex: … … 322 327 raise argparse.ArgumentTypeError(msg) 323 328 329 # Convert a function that converts a string to one that converts comma separated string. 330 def comma_separated(elements): 331 return lambda string: [elements(part) for part in string.split(',')] 332 324 333 def fancy_print(text): 325 334 column = which('column') -
tests/test.py
rb7d6a36 r6a490b2 6 6 7 7 import argparse 8 import itertools 8 9 import re 9 10 import sys … … 29 30 test.path = match.group(1) 30 31 test.arch = match.group(3)[1:] if match.group(3) else None 31 if settings.arch.match(test.arch): 32 expected.append(test) 32 expected.append(test) 33 33 34 34 path_walk( match_test ) … … 53 53 ] 54 54 55 # sort the test alphabetically for convenience 56 test_list.sort(key=lambda t: ('~' if t.arch else '') + t.target() + (t.arch if t.arch else '')) 57 55 58 return test_list 56 59 … … 64 67 for testname in options.tests : 65 68 testname = canonical_path( testname ) 69 # first check if this is a valid name to regenerate 66 70 if Test.valid_name(testname): 71 # this is a valid name, let's check if it already exists 67 72 found = [test for test in all_tests if canonical_path( test.target() ) == testname] 68 tests.append( found[0] if len(found) == 1 else Test.from_target(testname) ) 73 if not found: 74 # it's a new name, create it according to the name and specified architecture 75 if options.arch: 76 # user specified one or multiple architectures, assume the tests will have architecture specific results 77 tests.extend( [Test.new_target(testname, arch) for arch in settings.all_arch] ) 78 else: 79 # user didn't specify an architecture, just create a cross platform test 80 tests.append( Test.new_target( testname, None ) ) 81 elif len(found) == 1 and not found[0].arch: 82 # we found a single test, the user better be wanting to create a cross platform test 83 if options.arch: 84 print('ERROR: "%s", test has no specified architecture but --arch was specified, ignoring it' % testname, file=sys.stderr) 85 else: 86 tests.append( found[0] ) 87 else: 88 # this test is already cross platform, just add a test for each platform the user asked 89 tests.extend( [Test.new_target(testname, arch) for arch in settings.all_arch] ) 90 91 # print a warning if it users didn't ask for a specific architecture 92 if not options.arch: 93 print('WARNING: "%s", test has architecture specific expected files but --arch was not specified, regenerating only for current host' % testname, file=sys.stderr) 94 69 95 else : 70 96 print('ERROR: "%s", tests are not allowed to end with a C/C++/CFA extension, ignoring it' % testname, file=sys.stderr) … … 76 102 77 103 if test : 78 tests. append( test[0])104 tests.extend( test ) 79 105 else : 80 106 print('ERROR: No expected file for test %s, ignoring it' % testname, file=sys.stderr) … … 86 112 # create a parser with the arguments for the tests script 87 113 parser = argparse.ArgumentParser(description='Script which runs cforall tests') 88 parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='yes') 89 parser.add_argument('--install', help='Run all tests based on installed binaries or tree binaries', type=yes_no, default='no') 90 parser.add_argument('--arch', help='Test for specific architecture', type=str, default='') 114 parser.add_argument('--debug', help='Run all tests in debug or release', type=comma_separated(yes_no), default='yes') 115 parser.add_argument('--install', help='Run all tests based on installed binaries or tree binaries', type=comma_separated(yes_no), default='no') 116 parser.add_argument('--arch', help='Test for specific architecture', type=comma_separated(str), default=None) 117 parser.add_argument('--continue', help='When multiple specifications are passed (debug/install/arch), sets whether or not to continue if the last specification failed', type=yes_no, default='yes', dest='continue_') 91 118 parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=60) 92 119 parser.add_argument('--global-timeout', help='Maximum cumulative duration in seconds after the ALL tests are considered to have timed out', type=int, default=7200) 120 parser.add_argument('--timeout-with-gdb', help='Instead of killing the command when it times out, orphan it and print process id to allow gdb to attach', type=yes_no, default="no") 93 121 parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true') 94 122 parser.add_argument('--list', help='List all test available', action='store_true') … … 178 206 179 207 else: 180 with open (out_file, "r") as myfile: 181 error = myfile.read() 208 if os.stat(out_file).st_size < 1048576: 209 with open (out_file, "r") as myfile: 210 error = myfile.read() 211 else: 212 error = "Output log can't be read, file is bigger than 1MB, see {} for actual error\n".format(out_file) 182 213 183 214 ret, info = core_info(exe_file) … … 215 246 return False, "" 216 247 except Exception as ex: 217 print("Unexpected error in worker thread : %s" % ex, file=sys.stderr)248 print("Unexpected error in worker thread running {}: {}".format(t.target(), ex), file=sys.stderr) 218 249 sys.stderr.flush() 219 250 return False, "" … … 278 309 make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL) 279 310 280 return 1 if failed else 0311 return failed 281 312 282 313 … … 292 323 settings.init( options ) 293 324 294 # fetch the liest of all valid tests295 all_tests = list_tests( options.include, options.exclude )296 297 298 # if user wants all tests than no other treatement of the test list is required299 if options.all or options.list or options.list_comp or options.include :300 tests = all_tests301 302 #otherwise we need to validate that the test list that was entered is valid303 else :304 tests = valid_tests( options )305 306 # make sure we have at least some test to run307 if not tests :308 print('ERROR: No valid test to run', file=sys.stderr)309 sys.exit(1)310 311 312 # sort the test alphabetically for convenience313 tests.sort(key=lambda t: (t.arch if t.arch else '') + t.target())314 315 325 # users may want to simply list the tests 316 326 if options.list_comp : 317 print("-h --help --debug --dry-run --list --arch --all --regenerate-expected --archive-errors --install --timeout --global-timeout -j --jobs ", end='') 327 # fetch the liest of all valid tests 328 tests = list_tests( None, None ) 329 330 # print the possible options 331 print("-h --help --debug --dry-run --list --arch --all --regenerate-expected --archive-errors --install --timeout --global-timeout --timeout-with-gdb -j --jobs -I --include -E --exclude --continue ", end='') 318 332 print(" ".join(map(lambda t: "%s" % (t.target()), tests))) 319 333 320 334 elif options.list : 321 print("Listing for %s:%s"% (settings.arch.string, settings.debug.string)) 335 # fetch the liest of all valid tests 336 tests = list_tests( options.include, options.exclude ) 337 338 # print the available tests 322 339 fancy_print("\n".join(map(lambda t: t.toString(), tests))) 323 340 324 341 else : 325 # check the build configuration works 342 # fetch the liest of all valid tests 343 all_tests = list_tests( options.include, options.exclude ) 344 345 # if user wants all tests than no other treatement of the test list is required 346 if options.all or options.include : 347 tests = all_tests 348 349 #otherwise we need to validate that the test list that was entered is valid 350 else : 351 tests = valid_tests( options ) 352 353 # make sure we have at least some test to run 354 if not tests : 355 print('ERROR: No valid test to run', file=sys.stderr) 356 sys.exit(1) 357 358 # prep invariants 326 359 settings.prep_output(tests) 327 settings.validate() 328 329 options.jobs, forceJobs = job_count( options, tests ) 330 settings.update_make_cmd(forceJobs, options.jobs) 331 332 print('%s %i tests on %i cores (%s:%s)' % ( 333 'Regenerating' if settings.generating else 'Running', 334 len(tests), 335 options.jobs, 336 settings.arch.string, 337 settings.debug.string 338 )) 339 340 # otherwise run all tests and make sure to return the correct error code 341 sys.exit( run_tests(tests, options.jobs) ) 360 failed = 0 361 362 # for each build configurations, run the test 363 for arch, debug, install in itertools.product(settings.all_arch, settings.all_debug, settings.all_install): 364 settings.arch = arch 365 settings.debug = debug 366 settings.install = install 367 368 # filter out the tests for a different architecture 369 # tests are the same across debug/install 370 local_tests = settings.arch.filter( tests ) 371 options.jobs, forceJobs = job_count( options, local_tests ) 372 settings.update_make_cmd(forceJobs, options.jobs) 373 374 # check the build configuration works 375 settings.validate() 376 377 # print configuration 378 print('%s %i tests on %i cores (%s:%s)' % ( 379 'Regenerating' if settings.generating else 'Running', 380 len(local_tests), 381 options.jobs, 382 settings.arch.string, 383 settings.debug.string 384 )) 385 386 # otherwise run all tests and make sure to return the correct error code 387 failed = run_tests(local_tests, options.jobs) 388 if failed: 389 result = 1 390 if not settings.continue_: 391 break 392 393 394 sys.exit( failed ) -
tests/vector.cfa
rb7d6a36 r6a490b2 14 14 // 15 15 16 #include <vector.hfa> 16 17 #include <fstream.hfa> 17 #include <vector.hfa>18 18 19 19 #undef assert … … 28 28 int main() { 29 29 vector( int ) iv; 30 31 assert( ((uintptr_t)&iv.storage.storage ) == (((uintptr_t)&iv)) ); 32 assert( ((uintptr_t)&iv.storage.capacity) == (((uintptr_t)&iv) + sizeof(void *)) ); 33 assert( ((uintptr_t)&iv.size ) == (((uintptr_t)&iv) + sizeof(void *) + sizeof(size_t)) ); 30 34 31 35 assert( empty( &iv ) );
Note: See TracChangeset
for help on using the changeset viewer.