Changeset 200fcb3 for tests/concurrent


Ignore:
Timestamp:
Dec 12, 2018, 9:16:12 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
5ebb1368
Parents:
3d99498
Message:

add auto newline to sout, change endl to nl

Location:
tests/concurrent
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/coroutineYield.c

    r3d99498 r200fcb3  
    2727        while(true) {
    2828                #if !defined(TEST_FOREVER)
    29                         sout | "Coroutine 1" | endl;
     29                        sout | "Coroutine 1";
    3030                #endif
    3131                yield();
    3232                #if !defined(TEST_FOREVER)
    33                         sout | "Coroutine 2" | endl;
     33                        sout | "Coroutine 2";
    3434                #endif
    3535                suspend();
     
    4242        for(int i = 0; TEST(i < N); i++) {
    4343                #if !defined(TEST_FOREVER)
    44                         sout | "Thread 1" | endl;
     44                        sout | "Thread 1";
    4545                #endif
    4646                resume(c);
    4747                #if !defined(TEST_FOREVER)
    48                         sout | "Thread 2" | endl;
     48                        sout | "Thread 2";
    4949                #endif
    5050                yield();
  • tests/concurrent/examples/boundedBufferEXT.c

    r3d99498 r200fcb3  
    88// Created On       : Wed Apr 18 22:52:12 2018
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Thu Aug 16 08:17:03 2018
    11 // Update Count     : 8
     10// Last Modified On : Tue Dec 11 21:55:02 2018
     11// Update Count     : 9
    1212//
    1313
     
    115115                sum += sums[i];
    116116        } // for
    117         sout | "total:" | sum | endl;
     117        sout | "total:" | sum;
    118118}
    119119
  • tests/concurrent/examples/boundedBufferINT.c

    r3d99498 r200fcb3  
    88// Created On       : Mon Oct 30 12:45:13 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Thu Aug 16 08:17:58 2018
    11 // Update Count     : 83
     10// Last Modified On : Tue Dec 11 21:55:45 2018
     11// Update Count     : 84
    1212//
    1313
     
    116116                sum += sums[i];
    117117        } // for
    118         sout | "total:" | sum | endl;
     118        sout | "total:" | sum;
    119119}
    120120
  • tests/concurrent/examples/datingService.c

    r3d99498 r200fcb3  
    88// Created On       : Mon Oct 30 12:56:20 2017
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Sun May 27 09:05:18 2018
    11 // Update Count     : 26
     10// Last Modified On : Tue Dec 11 21:55:34 2018
     11// Update Count     : 28
    1212//
    1313
     
    5858        yield( random( 100 ) );                                                         // don't all start at the same time
    5959        unsigned int partner = girl( TheExchange, id, ccode );
    60         sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode | endl;
     60        sout | "Girl:" | id | "is dating Boy at" | partner | "with ccode" | ccode;
    6161        girlck[id] = partner;
    6262} // Girl main
     
    6969
    7070thread Boy {
    71         DatingService &TheExchange;
     71        DatingService & TheExchange;
    7272        unsigned int id, ccode;
    7373}; // Boy
     
    7676        yield( random( 100 ) );                                                         // don't all start at the same time
    7777        unsigned int partner = boy( TheExchange, id, ccode );
    78         sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode | endl;
     78        sout | " Boy:" | id | "is dating Girl" | partner | "with ccode" | ccode;
    7979        boyck[id] = partner;
    8080} // Boy main
  • tests/concurrent/examples/matrixSum.c

    r3d99498 r200fcb3  
    1111// Created On       : Mon Oct  9 08:29:28 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Tue Nov  6 17:51:32 2018
    14 // Update Count     : 14
     13// Last Modified On : Tue Dec 11 21:54:55 2018
     14// Update Count     : 15
    1515//
    1616
     
    5454                total += subtotals[r];                                                  // total subtotals
    5555        } // for
    56         sout | total | endl;
     56        sout | total;
    5757}
    5858
  • tests/concurrent/examples/quickSort.c

    r3d99498 r200fcb3  
    99// Created On       : Wed Dec  6 12:15:52 2017
    1010// Last Modified By : Peter A. Buhr
    11 // Last Modified On : Thu Aug 16 08:17:41 2018
    12 // Update Count     : 163
     11// Last Modified On : Tue Dec  4 18:00:27 2018
     12// Update Count     : 167
    1313//
    1414
     
    8888
    8989void usage( char * argv[] ) {
    90         sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )" | endl;
     90        sout | "Usage:" | argv[0] | "( -s unsorted-file [ sorted-file ] | -t size (>= 0) [ depth (>= 0) ] )";
    9191        exit( EXIT_FAILURE );                                                           // TERMINATE!
    9292} // usage
     
    114114                                &sortedfile = new( (const char *)argv[2] ); // open the output file
    115115                                if ( fail( sortedfile ) ) {
    116                                         serr | "Error! Could not open sorted output file \"" | argv[2] | "\"" | endl;
     116                                        serr | "Error! Could not open sorted output file \"" | argv[2] | "\"";
    117117                                        usage( argv );
    118118                                } // if
     
    121121                                &unsortedfile = new( (const char *)argv[1] ); // open the input file
    122122                                if ( fail( unsortedfile ) ) {
    123                                         serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"" | endl;
     123                                        serr | "Error! Could not open unsorted input file \"" | argv[1] | "\"";
    124124                                        usage( argv );
    125125                                } // if
     
    127127                } // if
    128128        } // if
     129        sortedfile | nlOff;                                                                     // turn off auto newline
    129130
    130131        enum { ValuesPerLine = 22 };                                            // number of values printed per line
     
    137138                        for ( int counter = 0; counter < size; counter += 1 ) { // read unsorted numbers
    138139                                unsortedfile | values[counter];
    139                                 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | "  ";
     140                                if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | "  ";
    140141                                sortedfile | values[counter];
    141142                                if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' ';
    142143                        } // for
    143                         sortedfile | endl;
     144                        sortedfile | nl;
    144145                        if ( size > 0 ) {                                                       // values to sort ?
    145146                                Quicksort QS = { values, size - 1, 0 }; // sort values
    146147                        } // wait until sort tasks terminate
    147148                        for ( int counter = 0; counter < size; counter += 1 ) { // print sorted list
    148                                 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | endl | "  ";
     149                                if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | "  ";
    149150                                sortedfile | values[counter];
    150151                                if ( counter < size - 1 && (counter + 1) % ValuesPerLine != 0 ) sortedfile | ' ';
    151152                        } // for
    152                         sortedfile | endl | endl;
     153                        sortedfile | nl;
    153154
    154155                        delete( values );
  • tests/concurrent/monitor.c

    r3d99498 r200fcb3  
    4040                MyThread f[4];
    4141        }
    42         sout | global.value | endl;
     42        sout | global.value;
    4343}
  • tests/concurrent/multi-monitor.c

    r3d99498 r200fcb3  
    5252                }
    5353        }
    54         sout | global12 | global23 | global13 | endl;
     54        sout | global12 | global23 | global13;
    5555}
  • tests/concurrent/signal/block.c

    r3d99498 r200fcb3  
    5757
    5858        if(a.last_thread != a.last_signaller || b.last_thread != b.last_signaller ) {
    59                 sout | "ERROR Barging detected, expected" | a.last_signaller | b.last_signaller | "got" | a.last_thread | b.last_thread | endl;
     59                sout | "ERROR Barging detected, expected" | a.last_signaller | b.last_signaller | "got" | a.last_thread | b.last_thread;
    6060                abort();
    6161        }
     
    8585
    8686                if( ! signal_block( cond ) ) {
    87                         sout | "ERROR expected to be able to signal" | endl;
     87                        sout | "ERROR expected to be able to signal";
    8888                        abort();
    8989                }
     
    9292
    9393                if(a.last_thread != next || b.last_thread != next) {
    94                         sout | "ERROR Barging detected, expected" | next | "got" | a.last_thread | b.last_thread | endl;
     94                        sout | "ERROR Barging detected, expected" | next | "got" | a.last_thread | b.last_thread;
    9595                        abort();
    9696                }
     
    130130                Signaller s[4];
    131131                Barger b[13];
    132                 sout | "Starting waiters" | endl;
     132                sout | "Starting waiters";
    133133                {
    134134                        Waiter w[3];
    135135                }
    136                 sout | "Waiters done" | endl;
     136                sout | "Waiters done";
    137137                done = true;
    138138        }
  • tests/concurrent/signal/disjoint.c

    r3d99498 r200fcb3  
    6666        wait( cond );
    6767        if( d.state != SIGNAL ) {
    68                 sout | "ERROR barging!" | endl;
     68                sout | "ERROR barging!";
    6969        }
    7070
    7171        #if !defined(TEST_FOREVER)
    7272                d.counter++;
    73                 if( (d.counter % 1000) == 0 ) sout | d.counter | endl;
     73                if( (d.counter % 1000) == 0 ) sout | d.counter;
    7474        #endif
    7575
     
    9999        bool running = TEST(data.counter < N) && data.counter > 0;
    100100        if( data.state != SIGNAL && running ) {
    101                 sout | "ERROR Eager signal" | data.state | endl;
     101                sout | "ERROR Eager signal" | data.state;
    102102        }
    103103}
     
    124124                        Waiter w[4];
    125125                }
    126                 sout | "All waiter done" | endl;
     126                sout | "All waiter done";
    127127                all_done = true;
    128128        }
  • tests/concurrent/signal/wait.c

    r3d99498 r200fcb3  
    8383                                break;
    8484                        default:
    85                                 sout | "Something went wrong" | endl;
     85                                sout | "Something went wrong";
    8686                                abort();
    8787                }
     
    140140        waiter_left = 4;
    141141        processor p[2];
    142         sout | "Starting" | endl;
     142        sout | "Starting";
    143143        {
    144144                Signaler  e;
     
    150150                }
    151151        }
    152         sout | "Done" | endl;
     152        sout | "Done";
    153153}
  • tests/concurrent/thread.c

    r3d99498 r200fcb3  
    1212void main(First& this) {
    1313        for(int i = 0; i < 10; i++) {
    14                 sout | "First : Suspend No." | i + 1 | endl;
     14                sout | "First : Suspend No." | i + 1;
    1515                yield();
    1616        }
     
    2121        P(*this.lock);
    2222        for(int i = 0; i < 10; i++) {
    23                 sout | "Second : Suspend No." | i + 1 | endl;
     23                sout | "Second : Suspend No." | i + 1;
    2424                yield();
    2525        }
     
    2929int main(int argc, char* argv[]) {
    3030        semaphore lock = { 0 };
    31         sout | "User main begin" | endl;
     31        sout | "User main begin";
    3232        {
    3333                processor p;
     
    3737                }
    3838        }
    39         sout | "User main end" | endl;
     39        sout | "User main end";
    4040}
  • tests/concurrent/waitfor/barge.c

    r3d99498 r200fcb3  
    4848        yield(random( 10 ));
    4949        if( this.state != WAITFOR && !this.done && this.started ) {
    50                 serr | "Barging before caller detected" | endl;
     50                serr | "Barging before caller detected";
    5151        }
    5252
     
    6666                this.state = WAITFOR;
    6767                waitfor(do_call, this) {
    68                         sout | i | endl;
     68                        sout | i;
    6969                }
    7070
    7171                if( this.state != CALL ) {
    72                         serr | "Barging after caller detected" | endl;
     72                        serr | "Barging after caller detected";
    7373                }
    7474        }
     
    8383
    8484int main() {
    85         sout | "Starting" | endl;
     85        sout | "Starting";
    8686        {
    8787                barger_t bargers[17];
     
    8989                waiter_t waiters;
    9090        }
    91         sout | "Stopping" | endl;
     91        sout | "Stopping";
    9292}
  • tests/concurrent/waitfor/dtor.c

    r3d99498 r200fcb3  
    2929        switch(state) {
    3030                case CTOR  : break;
    31                 case MAIN  : if( this.state != CTOR  ) { serr | "ERROR Expected state to be CTOR"  | endl; abort(); } this.state = state; break;
    32                 case AFTER : if( this.state != MAIN  ) { serr | "ERROR Expected state to be MAIN"  | endl; abort(); } this.state = state; break;
    33                 case END   : if( this.state != AFTER ) { serr | "ERROR Expected state to be AFTER" | endl; abort(); } this.state = state; break;
    34                 case DTOR  : if( this.state != END   ) { serr | "ERROR Expected state to be END"   | endl; abort(); } this.state = state; break;
     31                case MAIN  : if( this.state != CTOR  ) { serr | "ERROR Expected state to be CTOR" ; abort(); } this.state = state; break;
     32                case AFTER : if( this.state != MAIN  ) { serr | "ERROR Expected state to be MAIN" ; abort(); } this.state = state; break;
     33                case END   : if( this.state != AFTER ) { serr | "ERROR Expected state to be AFTER"; abort(); } this.state = state; break;
     34                case DTOR  : if( this.state != END   ) { serr | "ERROR Expected state to be END"  ; abort(); } this.state = state; break;
    3535        }
    3636}
     
    5454
    5555int main() {
    56         sout | "Starting" | endl;
     56        sout | "Starting";
    5757        processor p;
    5858        for( int i = 0; i < N; i++ ){
     
    6060                yield( random( 100 ) );
    6161        }
    62         sout | "Stopping" | endl;
     62        sout | "Stopping";
    6363}
  • tests/concurrent/waitfor/else.c

    r3d99498 r200fcb3  
    1212void test( M & mutex m ) {
    1313        int i = 0;
    14         sout | "Starting" | endl;
     14        sout | "Starting";
    1515
    1616        when( false ) waitfor( notcalled, m );
    1717
    18         sout | "Step" | i++ | endl;
     18        sout | "Step" | i++;
    1919
    2020        waitfor( notcalled, m ); or else {
    21                 sout | "else called" | endl;
     21                sout | "else called";
    2222        }
    2323
    24         sout | "Step" | i++ | endl;
     24        sout | "Step" | i++;
    2525
    2626        when( true ) waitfor( notcalled, m ); or when( true ) else {
    27                 sout | "else called" | endl;
     27                sout | "else called";
    2828        }
    2929
    30         sout | "Step" | i++ | endl;
     30        sout | "Step" | i++;
    3131
    3232        when( false ) waitfor( notcalled, m ); or when( true ) else {
    33                 sout | "else called" | endl;
     33                sout | "else called";
    3434        }
    3535
    36         sout | "Step" | i++ | endl;
     36        sout | "Step" | i++;
    3737
    3838        when( false ) waitfor( notcalled, m ); or when( false ) else {
    39                 sout | "else called" | endl;
     39                sout | "else called";
    4040        }
    4141
    42         sout | "Done" | endl;
     42        sout | "Done";
    4343}
    4444
  • tests/concurrent/waitfor/recurse.c

    r3d99498 r200fcb3  
    9595        rand_yield();
    9696
    97         sout | "1st" | endl;
     97        sout | "1st" | nl;
    9898
    9999        return this.counter < N ? (state_t)this.actions[idx] : (state_t)STOP;
     
    123123                        case THIRD  : while( !global.ready ) { yield(); } this.state = call3( global, this.idx ); break;
    124124                        case LAST   : while( !global.ready ) { yield(); } this.state = call4( global, this.idx ); break;
    125                         case STOP   : serr | "This should not happen" | endl;
     125                        case STOP   : serr | "This should not happen" | nl;
    126126                }
    127127        }
     
    132132int main() {
    133133        srandom( time(NULL) );
    134         sout | "Starting" | endl;
     134        sout | nlOff;                                   // turn off auto newline
     135        sout | "Starting" | nl;
    135136        {
    136137                waiter_t waiters[4] = {
     
    142143                the_threads = waiters;
    143144        }
    144         sout | "Stopping" | endl;
     145        sout | "Stopping" | nl;
    145146}
  • tests/concurrent/waitfor/simple.c

    r3d99498 r200fcb3  
    3131
    3232void do_wait( global_t * mutex a ) {
    33         sout | "Waiting to accept" | endl;
     33        sout | "Waiting to accept";
    3434        yield( random( 10 ) );
    3535
    36         sout | "Accepting" | endl;
     36        sout | "Accepting";
    3737
    3838        __acceptable_t acceptable;
     
    4343        __waitfor_internal( 1, &acceptable );
    4444
    45         sout | "Accepted" | endl;
     45        sout | "Accepted";
    4646        yield( random( 10 ) );
    4747}
     
    5050        for( int i = 0; i < N; i++ ) {
    5151                do_wait( &globalA );
    52                 sout | i | endl;
     52                sout | i;
    5353        }
    5454
     
    7676        srandom( time( NULL ) );
    7777        printf("%p\n", &globalA);
    78         sout | "Starting" | endl;
     78        sout | "Starting";
    7979        {
    8080                Acceptor r;
     
    8282
    8383        }
    84         sout | "Done" | endl;
     84        sout | "Done";
    8585}
  • tests/concurrent/waitfor/statment.c

    r3d99498 r200fcb3  
    8484                case 7: return call7( m );
    8585                default :
    86                         serr | "Incorrect index" | index | endl;
     86                        serr | "Incorrect index" | index;
    8787                        abort();
    8888        }
     
    102102        while( !done ) {
    103103                   waitfor( get_index, this );
    104                 or waitfor( call1, this ) { sout | "Statement" | endl; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val | endl; } }
    105                 or waitfor( call2, this ) { sout | "Statement" | endl; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val | endl; } }
    106                 or waitfor( call3, this ) { sout | "Statement" | endl; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val | endl; } }
    107                 or waitfor( call4, this ) { sout | "Statement" | endl; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val | endl; } }
    108                 or waitfor( call5, this ) { sout | "Statement" | endl; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val | endl; } }
    109                 or waitfor( call6, this ) { sout | "Statement" | endl; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val | endl; } }
    110                 or waitfor( call7, this ) { sout | "Statement" | endl; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val | endl; } }
     104                or waitfor( call1, this ) { sout | "Statement"; if( this.last_val != 1 ) { serr | "Incorrect index: expected" | 1 | "got" | this.last_val; } }
     105                or waitfor( call2, this ) { sout | "Statement"; if( this.last_val != 2 ) { serr | "Incorrect index: expected" | 2 | "got" | this.last_val; } }
     106                or waitfor( call3, this ) { sout | "Statement"; if( this.last_val != 3 ) { serr | "Incorrect index: expected" | 3 | "got" | this.last_val; } }
     107                or waitfor( call4, this ) { sout | "Statement"; if( this.last_val != 4 ) { serr | "Incorrect index: expected" | 4 | "got" | this.last_val; } }
     108                or waitfor( call5, this ) { sout | "Statement"; if( this.last_val != 5 ) { serr | "Incorrect index: expected" | 5 | "got" | this.last_val; } }
     109                or waitfor( call6, this ) { sout | "Statement"; if( this.last_val != 6 ) { serr | "Incorrect index: expected" | 6 | "got" | this.last_val; } }
     110                or waitfor( call7, this ) { sout | "Statement"; if( this.last_val != 7 ) { serr | "Incorrect index: expected" | 7 | "got" | this.last_val; } }
    111111
    112112                done = true;
     
    128128int main() {
    129129        processor p[2];
    130         sout | "Starting" | endl;
     130        sout | "Starting";
    131131        {
    132132                caller c[7];
    133133                waiter w;
    134134        }
    135         sout | "Stopping" | endl;
     135        sout | "Stopping";
    136136}
  • tests/concurrent/waitfor/when.c

    r3d99498 r200fcb3  
    5858void arbiter( global_t & mutex this ) {
    5959        for( int i = 0; i < N; i++ ) {
    60                    when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call | endl; } }
    61                 or when( this.last_call == 1 ) waitfor( call2, this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call | endl; } }
    62                 or when( this.last_call == 2 ) waitfor( call3, this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call | endl; } }
    63                 or when( this.last_call == 3 ) waitfor( call4, this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call | endl; } }
    64                 or when( this.last_call == 4 ) waitfor( call5, this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call | endl; } }
    65                 or when( this.last_call == 5 ) waitfor( call6, this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call | endl; } }
     60                   when( this.last_call == 6 ) waitfor( call1, this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } }
     61                or when( this.last_call == 1 ) waitfor( call2, this ) { if( this.last_call != 2) { serr | "Expected last_call to be 2 got" | this.last_call; } }
     62                or when( this.last_call == 2 ) waitfor( call3, this ) { if( this.last_call != 3) { serr | "Expected last_call to be 3 got" | this.last_call; } }
     63                or when( this.last_call == 3 ) waitfor( call4, this ) { if( this.last_call != 4) { serr | "Expected last_call to be 4 got" | this.last_call; } }
     64                or when( this.last_call == 4 ) waitfor( call5, this ) { if( this.last_call != 5) { serr | "Expected last_call to be 5 got" | this.last_call; } }
     65                or when( this.last_call == 5 ) waitfor( call6, this ) { if( this.last_call != 6) { serr | "Expected last_call to be 6 got" | this.last_call; } }
    6666
    67                 sout | this.last_call | endl;
     67                sout | this.last_call;
    6868        }
    6969
     
    7878int main() {
    7979        srandom( time(NULL) );
    80         sout | "Starting" | endl;
     80        sout | "Starting";
    8181        {
    8282                arbiter_t arbiter;
     
    8484
    8585        }
    86         sout | "Stopping" | endl;
     86        sout | "Stopping";
    8787}
Note: See TracChangeset for help on using the changeset viewer.