Changeset f5a51db for tests


Ignore:
Timestamp:
Feb 8, 2022, 11:53:13 AM (4 years ago)
Author:
Michael Brooks <mlbrooks@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
cc7bbe6
Parents:
97c215f (diff), 1cf8a9f (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
tests
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/.expect/ctor-check.txt

    r97c215f rf5a51db  
    22?{}: function
    33... with parameters
    4   lvalue reference to instance of struct Empty with body
     4  this: lvalue reference to instance of struct Empty with body
    55... returning nothing
    66 with body
  • tests/concurrent/mutexstmt/.expect/locks.txt

    r97c215f rf5a51db  
    33Start Test: multi lock deadlock/mutual exclusion
    44End Test: multi lock deadlock/mutual exclusion
     5Start Test: single scoped lock mutual exclusion
     6End Test: single scoped lock mutual exclusion
     7Start Test: multi scoped lock deadlock/mutual exclusion
     8End Test: multi scoped lock deadlock/mutual exclusion
  • tests/concurrent/mutexstmt/locks.cfa

    r97c215f rf5a51db  
    5959}
    6060
     61thread T_Mutex_Scoped {};
    6162
     63void main( T_Mutex_Scoped & this ) {
     64        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};
     71                        assert(!insideFlag);
     72                        insideFlag = true;
     73                        assert(insideFlag);
     74                        insideFlag = false;
     75                }
     76        }
     77}
     78
     79thread T_Multi_Scoped {};
     80
     81void main( T_Multi_Scoped & this ) {
     82        for (unsigned int i = 0; i < num_times; i++) {
     83                {
     84                        scoped_lock(single_acquisition_lock) s{m1};
     85                        assert(!insideFlag);
     86                        insideFlag = true;
     87                        assert(insideFlag);
     88                        insideFlag = false;
     89                }
     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};
     96                        assert(!insideFlag);
     97                        insideFlag = true;
     98                        assert(insideFlag);
     99                        insideFlag = false;
     100                }
     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};
     123                        assert(!insideFlag);
     124                        insideFlag = true;
     125                        assert(insideFlag);
     126                        insideFlag = false;
     127                }
     128        }
     129}
     130
     131int num_tasks = 10;
    62132int main() {
    63133        processor p[10];
     
    67137                T_Mutex t[10];
    68138        }
     139        assert(count == num_tasks * num_times);
    69140        printf("End Test: single lock mutual exclusion\n");
    70141        printf("Start Test: multi lock deadlock/mutual exclusion\n");
     
    73144        }
    74145        printf("End Test: multi lock deadlock/mutual exclusion\n");
     146       
     147        count = 0;
     148        printf("Start Test: single scoped lock mutual exclusion\n");
     149        {
     150                T_Mutex_Scoped t[10];
     151        }
     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");     
    75159}
  • tests/concurrent/preempt.cfa

    r97c215f rf5a51db  
     1#include <clock.hfa>
     2#include <fstream.hfa>
    13#include <kernel.hfa>
    24#include <thread.hfa>
     
    2123extern void __cfaabi_check_preemption();
    2224
    23 static volatile int counter = 0;
     25static struct {
     26        volatile int counter;
     27        volatile Time prev;
     28        Duration durations[6];
     29} globals;
    2430
    2531thread worker_t {
    2632        int value;
     33        unsigned long long spin;
    2734};
    2835
    2936void ?{}( worker_t & this, int value ) {
    3037        this.value = value;
     38        this.spin = 0;
    3139}
    3240
    3341void main(worker_t & this) {
    34         while(TEST(counter < N)) {
     42        while(TEST(globals.counter < N)) {
     43                if(this.spin > 50_000_000_000) abort | "Worker" | this.value | "has been spinning too long! (" | this.spin | ")";
    3544                __cfaabi_check_preemption();
    36                 if( (counter % 7) == this.value ) {
     45                if( (globals.counter % 7) == this.value ) {
    3746                        __cfaabi_check_preemption();
    38                         int next = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
     47                        #if !defined(TEST_LONG)
     48                                Time now = timeHiRes();
     49                                Duration diff = now - globals.prev;
     50                                globals.prev = now;
     51                        #endif
     52                        int next = __atomic_add_fetch( &globals.counter, 1, __ATOMIC_SEQ_CST );
    3953                        __cfaabi_check_preemption();
    40                         if( (next % 100) == 0 ) printf("%d\n", (int)next);
     54                        if( (next % 100) == 0 ) {
     55                                #if !defined(TEST_LONG)
     56                                        unsigned idx = next / 100;
     57                                        if (idx >= 6) abort | "Idx from next is invalid: " | idx | "vs" | next;
     58                                        globals.durations[idx] = diff;
     59                                        if(diff > 12`s) serr | "Duration suspiciously large:" | diff;
     60                                #endif
     61                                printf("%d\n", (int)next);
     62
     63                        }
    4164                        __cfaabi_check_preemption();
     65                        this.spin = 0;
    4266                }
    4367                __cfaabi_check_preemption();
    4468                KICK_WATCHDOG;
     69                this.spin++;
    4570        }
    4671}
     
    4873int main(int argc, char* argv[]) {
    4974        processor p;
     75        globals.counter = 0;
     76        globals.durations[0] = 0;
     77        globals.durations[1] = 0;
     78        globals.durations[2] = 0;
     79        globals.durations[3] = 0;
     80        globals.durations[4] = 0;
     81        globals.durations[5] = 0;
    5082        {
     83                globals.prev = timeHiRes();
    5184                worker_t w0 = 0;
    5285                worker_t w1 = 1;
  • tests/include/.expect/includes.nast.txt

    r97c215f rf5a51db  
    1 include/includes.cfa:154:25: warning: Compiled
     1include/includes.cfa:153:25: warning: Compiled
  • tests/include/includes.cfa

    r97c215f rf5a51db  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jun  5 10:06:46 2021
    13 // Update Count     : 751
     12// Last Modified On : Thu Feb  3 22:06:07 2022
     13// Update Count     : 774
    1414//
    1515
     
    1818#endif // __CFA__
    1919
     20#if 1
    2021//#define _GNU_SOURCE
    2122#include <aio.h>
     
    4041#include <errno.h>
    4142#include <error.h>
    42 //#include <eti.h>                                                                              // may not be installed, comes with ncurses
     43//#include <eti.h>                                                                              // may not be installed, comes with ncurses
    4344#include <execinfo.h>
    4445#include <expat.h>
     
    4950#include <fmtmsg.h>
    5051#include <fnmatch.h>
    51 //#include <form.h>                                                                             // may not be installed, comes with ncurses
     52//#include <form.h>                                                                             // may not be installed, comes with ncurses
    5253#include <fstab.h>
    5354#include <fts.h>
     
    7778#include <mcheck.h>
    7879#include <memory.h>
    79 //#include <menu.h>                                                                             // may not be installed, comes with ncurses
     80//#include <menu.h>                                                                             // may not be installed, comes with ncurses
    8081#include <mntent.h>
    8182#include <monetary.h>
    8283#include <mqueue.h>
    83 //#include <ncurses_dll.h>                                                                      // may not be installed, comes with ncurses
     84//#include <ncurses_dll.h>                                                              // may not be installed, comes with ncurses
    8485#include <netdb.h>
    8586#include <nl_types.h>
    8687#include <nss.h>
    8788#include <obstack.h>
    88 //#include <panel.h>                                                                            // may not be installed, comes with ncurses
     89//#include <panel.h>                                                                            // may not be installed, comes with ncurses
    8990#include <paths.h>
    9091#include <poll.h>
     
    117118#include <syslog.h>
    118119#include <tar.h>
    119 //#include <term.h>                                                                             // may not be installed, comes with ncurses
    120 //#include <termcap.h>                                                                          // may not be installed, comes with ncurses
     120//#include <term.h>                                                                             // may not be installed, comes with ncurses
     121//#include <termcap.h>                                                                  // may not be installed, comes with ncurses
    121122#include <termio.h>
    122123#include <termios.h>
     
    130131#include <ucontext.h>
    131132#include <ulimit.h>
    132 //#include <unctrl.h>                                                                           // may not be installed, comes with ncurses
     133//#include <unctrl.h>                                                                           // may not be installed, comes with ncurses
    133134#include <unistd.h>
    134135#include <utime.h>
     
    143144#include <wctype.h>
    144145#include <wordexp.h>
    145 
    146 #if 0
    147146#endif // 0
    148147
     
    151150#endif // __CFA__
    152151
    153 int main( int argc, char const *argv[] ) {
    154     #pragma GCC warning "Compiled"                      // force non-empty .expect file, NO TABS!!!
     152int main( int argc, char const * argv[] ) {
     153    #pragma GCC warning "Compiled"                                                      // force non-empty .expect file, NO TABS!!!
    155154}
    156155
Note: See TracChangeset for help on using the changeset viewer.