From 28d4f50a80a3c299483b68f86ca66dc441721b54 Mon Sep 17 00:00:00 2001
From: "benjamin.franksen" <benjamin.franksen@helmholtz-berlin.de>
Date: Sun, 4 Mar 2012 21:03:34 +0000
Subject: [PATCH] run all tests on vxWorks with increased state set thread
 priority

---
 test/validate/array.st               |  3 +--
 test/validate/assign.st              |  3 +--
 test/validate/bittypes.st            |  3 +--
 test/validate/change.st              |  3 +--
 test/validate/commaOperator.st       |  3 +--
 test/validate/evflag.st              |  3 +--
 test/validate/local.st               |  3 +--
 test/validate/makeStCmd.pl           |  3 +++
 test/validate/opttVar.st             |  3 +--
 test/validate/pvGet.st               |  3 +--
 test/validate/pvPutAsync.st          |  3 +--
 test/validate/pvSync.st              |  3 +--
 test/validate/raceCommon.st          |  3 +--
 test/validate/reassign.st            |  3 +--
 test/validate/safeModeNotAssigned.st |  3 +--
 test/validate/safeMonitor.st         |  3 +--
 test/validate/testSupport.c          | 14 ++++++++++++--
 test/validate/testSupport.h          |  3 ++-
 test/validate/userfunc.st            |  3 +--
 19 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/test/validate/array.st b/test/validate/array.st
index 0ace97fc..cbd27c27 100644
--- a/test/validate/array.st
+++ b/test/validate/array.st
@@ -9,7 +9,7 @@ program arrayTest
 %%#include "../testSupport.h"
 
 entry {
-    testPlan(20);
+    seq_test_init(20);
 }
 
 ss array {
@@ -44,6 +44,5 @@ ss array {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/assign.st b/test/validate/assign.st
index 0265acad..28e31161 100644
--- a/test/validate/assign.st
+++ b/test/validate/assign.st
@@ -16,7 +16,7 @@ foreign pvStatERROR;
 #define NTESTS 3
 
 entry {
-    testPlan(NTESTS);
+    seq_test_init(NTESTS);
 }
 
 ss w {
@@ -46,6 +46,5 @@ ss r {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/bittypes.st b/test/validate/bittypes.st
index 86582f6d..f5048fe9 100644
--- a/test/validate/bittypes.st
+++ b/test/validate/bittypes.st
@@ -23,7 +23,7 @@ assign i32 to "ushort";
 assign ui32 to "ushort";
 
 entry {
-    testPlan(12);
+    seq_test_init(12);
 }
 
 ss test {
@@ -74,6 +74,5 @@ ss test {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/change.st b/test/validate/change.st
index 0bed670b..01246ae7 100644
--- a/test/validate/change.st
+++ b/test/validate/change.st
@@ -14,7 +14,7 @@ program changeTest
 #define MAX_TEST 50
 
 entry {
-    testPlan(MAX_TEST);
+    seq_test_init(MAX_TEST);
     /* uncomment for repeatability */
     /* srandom(12345); */
 }
@@ -72,6 +72,5 @@ ss main {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/commaOperator.st b/test/validate/commaOperator.st
index 09439b1e..e38ed81f 100644
--- a/test/validate/commaOperator.st
+++ b/test/validate/commaOperator.st
@@ -9,7 +9,7 @@ program commaOperatorTest
 %%#include "../testSupport.h"
 
 entry {
-    testPlan(4);
+    seq_test_init(4);
 }
 
 ss myss {
@@ -25,6 +25,5 @@ ss myss {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/evflag.st b/test/validate/evflag.st
index 2edb147e..d90f21b1 100644
--- a/test/validate/evflag.st
+++ b/test/validate/evflag.st
@@ -26,7 +26,7 @@ monitor anonymous;
 sync anonymous to ef_anonymous;
 
 entry {
-    testPlan(0);
+    seq_test_init(0);
     efClear(ef_named);
 }
 
@@ -74,6 +74,5 @@ ss write {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/local.st b/test/validate/local.st
index 390ab7ee..f894ec59 100644
--- a/test/validate/local.st
+++ b/test/validate/local.st
@@ -16,7 +16,7 @@ option +r;
 int i = 1;
 
 entry {
-    testPlan(5);
+    seq_test_init(5);
 }
 
 /* only state-set */
@@ -41,6 +41,5 @@ ss start {
 /* exit handler */
 exit {
     testOk(i==1, "global i==%d", i);
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/makeStCmd.pl b/test/validate/makeStCmd.pl
index 82277fb9..36b7210a 100644
--- a/test/validate/makeStCmd.pl
+++ b/test/validate/makeStCmd.pl
@@ -2,4 +2,7 @@ print "testHarness\n";
 foreach my $x (@ARGV) {
   print "run_seq_test \&${x}Test\n"
 }
+foreach my $x (@ARGV) {
+  print "run_seq_test \&${x}Test, 1\n"
+}
 print "epicsExit\n";
diff --git a/test/validate/opttVar.st b/test/validate/opttVar.st
index d34b46fa..1d488c91 100644
--- a/test/validate/opttVar.st
+++ b/test/validate/opttVar.st
@@ -23,7 +23,7 @@ monitor msg;
 syncq msg 40;
 
 entry {
-    testPlan(40);
+    seq_test_init(40);
 }
 
 ss low_high {
@@ -118,6 +118,5 @@ ss check {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/pvGet.st b/test/validate/pvGet.st
index a6623fa0..217a13b1 100644
--- a/test/validate/pvGet.st
+++ b/test/validate/pvGet.st
@@ -24,7 +24,7 @@ assign anon;
 evflag ef_read_named, ef_read_anon, ef_read_named_sync, ef_read_anon_sync;
 
 entry {
-    testPlan(MAX_GET*4*3);
+    seq_test_init(MAX_GET*4*3);
     mutex = epicsMutexMustCreate();
 }
 
@@ -205,6 +205,5 @@ ss write {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/pvPutAsync.st b/test/validate/pvPutAsync.st
index 518f08ad..296841fc 100644
--- a/test/validate/pvPutAsync.st
+++ b/test/validate/pvPutAsync.st
@@ -14,7 +14,7 @@ int x;
 assign x to "pvPutAsync1";
 
 entry {
-    testPlan(10);
+    seq_test_init(10);
 }
 
 ss test1 {
@@ -84,6 +84,5 @@ ss test2 {
 #endif
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/pvSync.st b/test/validate/pvSync.st
index e0efd319..6ec1136e 100644
--- a/test/validate/pvSync.st
+++ b/test/validate/pvSync.st
@@ -17,7 +17,7 @@ monitor x;
 evflag f;
 
 entry {
-    testPlan(5);
+    seq_test_init(5);
     pvSync(x,f);
 }
 
@@ -48,6 +48,5 @@ ss help {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/raceCommon.st b/test/validate/raceCommon.st
index a49dac14..34ef364c 100644
--- a/test/validate/raceCommon.st
+++ b/test/validate/raceCommon.st
@@ -21,7 +21,7 @@ foreign MAX_STRING_SIZE;
 #define MAX_TESTS 30
 
 entry {
-    testPlan(MAX_TESTS);
+    seq_test_init(MAX_TESTS);
     testDiag("This test will run for %d seconds...", MAX_TESTS);
 }
 
@@ -148,6 +148,5 @@ ss stop {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/reassign.st b/test/validate/reassign.st
index a25f01e6..9fe6e8d4 100644
--- a/test/validate/reassign.st
+++ b/test/validate/reassign.st
@@ -20,7 +20,7 @@ foreign pvStatOK;
 #define NTESTS 30
 
 entry {
-    testPlan(NTESTS);
+    seq_test_init(NTESTS);
 }
 
 ss reassign {
@@ -93,6 +93,5 @@ ss reassign {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/safeModeNotAssigned.st b/test/validate/safeModeNotAssigned.st
index 9063cf8e..0ba970a8 100644
--- a/test/validate/safeModeNotAssigned.st
+++ b/test/validate/safeModeNotAssigned.st
@@ -15,7 +15,7 @@ int v = 0;
 #define MAX_TEST 10
 
 entry {
-    testPlan(MAX_TEST*2);
+    seq_test_init(MAX_TEST*2);
 }
 
 ss ss1 {
@@ -48,6 +48,5 @@ ss ss2 {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/safeMonitor.st b/test/validate/safeMonitor.st
index 46b5d935..70116db9 100644
--- a/test/validate/safeMonitor.st
+++ b/test/validate/safeMonitor.st
@@ -19,7 +19,7 @@ sync cnt to ef_cnt;
 #define MAX_TEST 10
 
 entry {
-    testPlan(MAX_TEST);
+    seq_test_init(MAX_TEST);
 }
 
 ss read {
@@ -50,6 +50,5 @@ ss write {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
diff --git a/test/validate/testSupport.c b/test/validate/testSupport.c
index a609bf91..31166530 100644
--- a/test/validate/testSupport.c
+++ b/test/validate/testSupport.c
@@ -13,8 +13,8 @@ in the file LICENSE that is included with this distribution.
 #include "../testSupport.h"
 
 static epicsEventId this_test_done;
-
 static seqProgram *prog;
+int seq_test_raise_priority;
 
 static int doit(void)
 {
@@ -22,8 +22,9 @@ static int doit(void)
     return 0;
 }
 
-void run_seq_test(seqProgram *seqProg)
+void run_seq_test(seqProgram *seqProg, int raise_priority)
 {
+    seq_test_raise_priority = raise_priority;
     if (!this_test_done) {
         this_test_done = epicsEventMustCreate(epicsEventEmpty);
     }
@@ -32,8 +33,17 @@ void run_seq_test(seqProgram *seqProg)
     epicsEventWait(this_test_done);
 }
 
+void seq_test_init(int num_tests)
+{
+    testPlan(num_tests);
+    if (seq_test_raise_priority) {
+        epicsThreadSetPriority(epicsThreadGetIdSelf(), epicsThreadPriorityHigh);
+    }
+}
+
 void seq_test_done(void)
 {
+    testDone();
 #if defined(vxWorks)
     epicsEventSignal(this_test_done);
 #else
diff --git a/test/validate/testSupport.h b/test/validate/testSupport.h
index b8c58fa7..20cc0374 100644
--- a/test/validate/testSupport.h
+++ b/test/validate/testSupport.h
@@ -11,7 +11,8 @@ in the file LICENSE that is included with this distribution.
 #include "epicsMutex.h"
 #include "epicsUnitTest.h"
 
-void run_seq_test(seqProgram *seqProg);
+void run_seq_test(seqProgram *seqProg, int raise_priority);
+void seq_test_init(int num_tests);
 void seq_test_done(void);
 
 #endif /* INCtestSupport_h */
diff --git a/test/validate/userfunc.st b/test/validate/userfunc.st
index 312a1774..3ea7cb8d 100644
--- a/test/validate/userfunc.st
+++ b/test/validate/userfunc.st
@@ -26,7 +26,7 @@ monitor i;
 foreign pVar, ssId;
 
 entry {
-    testPlan(10);
+    seq_test_init(10);
 }
 
 ss myss {
@@ -43,6 +43,5 @@ ss myss {
 }
 
 exit {
-    testDone();
     seq_test_done();
 }
-- 
GitLab