mirror of
https://github.com/geohot/qira
synced 2024-12-27 06:19:41 +03:00
add auto test for pthreads
This commit is contained in:
parent
87701a9896
commit
6750b1ced3
BIN
qira_tests/bin/thread_test
Executable file
BIN
qira_tests/bin/thread_test
Executable file
Binary file not shown.
18
qira_tests/test_qira_pthread.py
Normal file
18
qira_tests/test_qira_pthread.py
Normal 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)
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user