From e9e28aef8c12cb30f360074a222f816dd8b5122b Mon Sep 17 00:00:00 2001 From: "benjamin.franksen" <benjamin.franksen@helmholtz-berlin.de> Date: Wed, 14 Mar 2012 00:15:48 +0000 Subject: [PATCH] added a test to demonstrate problem with efTestAndClear in safe mode This test was provided by Lewis Muir, it fails with seq-2.1.5. --- test/validate/Makefile | 1 + test/validate/monitorEvflag.db | 5 +++ test/validate/monitorEvflag.st | 63 ++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 test/validate/monitorEvflag.db create mode 100644 test/validate/monitorEvflag.st diff --git a/test/validate/Makefile b/test/validate/Makefile index 51c70d51..a2aadade 100644 --- a/test/validate/Makefile +++ b/test/validate/Makefile @@ -27,6 +27,7 @@ TESTPROD_HOST += syncq REGRESSION_TESTS_WITH_DB += bittypes REGRESSION_TESTS_WITH_DB += evflag +REGRESSION_TESTS_WITH_DB += monitorEvflag REGRESSION_TESTS_WITH_DB += pvGet REGRESSION_TESTS_WITH_DB += pvGetAsync REGRESSION_TESTS_WITH_DB += pvPutAsync diff --git a/test/validate/monitorEvflag.db b/test/validate/monitorEvflag.db new file mode 100644 index 00000000..6206b204 --- /dev/null +++ b/test/validate/monitorEvflag.db @@ -0,0 +1,5 @@ +record(longout,"requested") { + field(OUT,"actual PP MS") +} +record(longin,"actual") { +} diff --git a/test/validate/monitorEvflag.st b/test/validate/monitorEvflag.st new file mode 100644 index 00000000..cc0e0f05 --- /dev/null +++ b/test/validate/monitorEvflag.st @@ -0,0 +1,63 @@ +program monitorEvflagTest + +option +s; + +%%#include "../testSupport.h" +%%#include <stdio.h> + +#define NTESTS 100 +#define NCYCLESPERTEST 1000 +#define NCYCLES (NTESTS*NCYCLESPERTEST) + +int requested; +assign requested to "requested"; + +int actual; +assign actual to "actual"; +monitor actual; + +evflag actualChanged; +sync actual actualChanged; + +entry { + seq_test_init(NTESTS); +} + +ss monitorEvflagTest { + int cycleCount = 1; + int error = 0; + state init { + when (delay(1.0)) { + efClear(actualChanged); + } state makeRequest + } + state makeRequest { + when (error || cycleCount > NCYCLES) { + } exit + when (cycleCount <= NCYCLES) { + requested = cycleCount; + pvPut(requested); + } state waitForActualToEqualRequested + } + state waitForActualToEqualRequested { + when (efTestAndClear(actualChanged) /* && actual == requested */) { + if (actual != requested) { + testFail("requested(%d)!=actual(%d)", requested, actual); + testSkip((NCYCLES-cycleCount)/NCYCLESPERTEST, "failure"); + error = TRUE; + } else if (cycleCount % NCYCLESPERTEST == 0) { + testPass("requested(%d)==actual(%d)", requested, actual); + } + cycleCount++; + } state makeRequest + when (delay(1.0)) { + testFail("timeout in cycle %d/%d (requested=%d, actual=%d)", + cycleCount + 1, NCYCLES, requested, actual); + testSkip((NCYCLES-cycleCount)/NCYCLESPERTEST, "failure"); + } exit + } +} + +exit { + seq_test_done(); +} -- GitLab