add auto test for pthreads

This commit is contained in:
cromize 2019-05-26 21:38:21 +02:00
parent 87701a9896
commit 6750b1ced3
3 changed files with 20 additions and 2 deletions

BIN
qira_tests/bin/thread_test Executable file

Binary file not shown.

View File

@ -0,0 +1,18 @@
import sys
sys.path.append("middleware/")
import qira_program
import time
import signal
def fail_handler():
raise Exception("** pthread_test timeout")
def test():
signal.signal(signal.SIGALRM, fail_handler)
signal.alarm(7)
print("\n** thread_test timeout set to 7 second")
program = qira_program.Program("qira_tests/bin/thread_test")
program.execqira(shouldfork=False)
time.sleep(1)

View File

@ -3,12 +3,12 @@
void start1() {
int i = 100;
while (1) { printf("t1 %d\n", i++); sleep(1); }
for (int i = 0; i < 2; i++) { printf("t1 %d\n", i); sleep(1); }
}
void start2() {
int i = 200;
while (1) { printf("t2 %d\n", i++); sleep(1); }
for (int i = 0; i < 2; i++) { printf("t2 %d\n", i); sleep(1); }
}
int main() {