From 6750b1ced38bee579193d9f7096ad734dadd2ef1 Mon Sep 17 00:00:00 2001 From: cromize Date: Sun, 26 May 2019 21:38:21 +0200 Subject: [PATCH] add auto test for pthreads --- qira_tests/bin/thread_test | Bin 0 -> 8568 bytes qira_tests/test_qira_pthread.py | 18 ++++++++++++++++++ tests_manual/thread_test.c | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 qira_tests/bin/thread_test create mode 100644 qira_tests/test_qira_pthread.py diff --git a/qira_tests/bin/thread_test b/qira_tests/bin/thread_test new file mode 100755 index 0000000000000000000000000000000000000000..b137bbb0125ae9ce9d2af22c5a76949be5e5dc41 GIT binary patch literal 8568 zcmeHMZERat89t7a*6muy?b5Al2Q_1r+M;+#+NSA7w>XX4o5}s4O9~TfZyno7yg7Dd zUzar6N=4RcCUk@`jebaen8>uP1XyF9_uTh& zu5X+TB!2K?r*fY2KJUl*KKGo{&qksO%zUA3u2`1>Js zvm&!v&Dr{P8=$q*G=~=SG4BPEUt5h$xbbGT6OBTKai z4C+i7xgKMT;zuI+oo2t&>?f$io>AIIZKGc|^KR^fj*=kRQri2Pm7u(}NQ-kYYST(k z{5}Cc9x}FgZwRn@AD1^@zYKBx1!Wv=OQ(8UH{F&_G^SIT!cgN-TWe$Mrcgc`YSHbc z_+-0tcaJWK##_3I>fC@IailjNZFq3}+ocyj_oL%Kc zD%Q)u1*`Cb;Hudln}`3}Jp9kW2k~>K{UEBvZv-E78$&*UUp4zt@V8X4R~U!G)<7;9 zOHk)GDYL74mzhZBlKrW?mCSYT+Mdp4lHIZ1bkf#U)o=(ijzCsYiFkiDm7x;i6uVWK zX5Na$A28zs514(iR9YR*r7~8Z%BPdb!_dZuVrE||6HBLtQJ6`Nm z|kuW3h)-YyQP%CC-`2UU!Pi=k)&||EhfxmHn#%mO(jPsLs8J=g1OEcC=1pE>QTtWfoi+6lm z5oW4zn=!JjpK?7^pC!iVw)-JXE=7|k4g7hgE(X~{)j3WTd+P#1qCI4O;7T7XD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K9NFL}*LvR(jB? zVnk0^DKnPK#g3ZEjFmg8`f{8C~KgQdG2`EJXIAP|D1UU&iuD4moQ(sL!;5G#cUXloSt}U|cXTycv3{2NGlfuZ zA%#ctR6>PF8i?fwR48#YgLpPtIa_linaiiLnF_&#E|*Nl$boZ*)0PV9t_dL<>d!*7 zl0*1QvlvEMJ)EKB0MFZj1cHcUyV?`j_K-YEhz+LVs1wbG5V~81uy_WsAgZj=|DK}z z2$nX!opx&DjG){{Sgma(Pxw*%=o2CSa-I|nLg!4fuL{?UjMHDvor1TDA*0*B6Z}=& z0i=96p9)I-<=({GX*ud{qA-Dupy)L;0`x3%(AG z)4zO<xi@y_P?m11{x%?sS qIQq`enOEu~`v=W$sk_sEoHxE>uHaIx*e;vLzm>17Gh)c-_Ww6z4g)0s literal 0 HcmV?d00001 diff --git a/qira_tests/test_qira_pthread.py b/qira_tests/test_qira_pthread.py new file mode 100644 index 00000000..3531aca0 --- /dev/null +++ b/qira_tests/test_qira_pthread.py @@ -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) + diff --git a/tests_manual/thread_test.c b/tests_manual/thread_test.c index ccdec3e2..be56f853 100644 --- a/tests_manual/thread_test.c +++ b/tests_manual/thread_test.c @@ -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() {