Adding test routines for longout record with OOPT field
This commit is contained in:
@@ -87,6 +87,13 @@ testHarness_SRCS += seqTest.c
|
||||
TESTFILES += ../seqTest.db
|
||||
TESTS += seqTest
|
||||
|
||||
TESTPROD_HOST += longoutTest
|
||||
longoutTest_SRCS += longoutTest.c
|
||||
longoutTest_SRCS += recTestIoc_registerRecordDeviceDriver.cpp
|
||||
testHarness_SRCS += longoutTest.c
|
||||
TESTFILES += ../longoutTest.db
|
||||
TESTS += longoutTest
|
||||
|
||||
TARGETS += $(COMMON_DIR)/asTestIoc.dbd
|
||||
DBDDEPENDS_FILES += asTestIoc.dbd$(DEP)
|
||||
asTestIoc_DBD += base.dbd
|
||||
|
||||
214
modules/database/test/std/rec/longoutTest.c
Normal file
214
modules/database/test/std/rec/longoutTest.c
Normal file
@@ -0,0 +1,214 @@
|
||||
/*************************************************************************\
|
||||
* Copyright (c) 2020 Joao Paulo Martins
|
||||
* EPICS BASE is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
\*************************************************************************/
|
||||
|
||||
#include "dbUnitTest.h"
|
||||
#include "testMain.h"
|
||||
#include "dbLock.h"
|
||||
#include "errlog.h"
|
||||
#include "dbAccess.h"
|
||||
#include "epicsMath.h"
|
||||
|
||||
#include "longoutRecord.h"
|
||||
|
||||
void recTestIoc_registerRecordDeviceDriver(struct dbBase *);
|
||||
|
||||
static void test_oopt_everytime(void){
|
||||
/* reset rec processing counter */
|
||||
testdbPutFieldOk("counter.VAL", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* write the same value two times */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
|
||||
/* write two times with different values*/
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 17);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 18);
|
||||
|
||||
/* Test if the counter was processed 4 times */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 4.0);
|
||||
|
||||
// number of tests = 6
|
||||
}
|
||||
|
||||
static void test_oopt_onchange(void){
|
||||
/* change OOPT to On Change */
|
||||
testdbPutFieldOk("longout_rec.OOPT", DBF_ENUM, longoutOOPT_On_Change);
|
||||
|
||||
/* reset rec processing counter */
|
||||
testdbPutFieldOk("counter.VAL", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* write the same value two times */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
|
||||
/* Test if the counter was processed only once */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 1.0);
|
||||
|
||||
/* write two times with different values*/
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 17);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 18);
|
||||
|
||||
/* Test if the counter was processed 1 + 2 times */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 3.0);
|
||||
|
||||
//number of tests 8
|
||||
}
|
||||
|
||||
static void test_oopt_whenzero(void){
|
||||
testdbPutFieldOk("longout_rec.OOPT", DBF_ENUM, longoutOOPT_When_Zero);
|
||||
|
||||
/* reset rec processing counter */
|
||||
testdbPutFieldOk("counter.VAL", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* write zero two times */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 0);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 0);
|
||||
|
||||
/* Test if the counter was processed twice */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 2.0);
|
||||
|
||||
/* write two times with non-zero values*/
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 17);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 18);
|
||||
|
||||
/* Test if the counter was still processed 2 times */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 2.0);
|
||||
|
||||
//number of tests 8
|
||||
}
|
||||
|
||||
static void test_oopt_whennonzero(void){
|
||||
testdbPutFieldOk("longout_rec.OOPT", DBF_ENUM, longoutOOPT_When_Non_zero);
|
||||
|
||||
/* reset rec processing counter */
|
||||
testdbPutFieldOk("counter.VAL", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* write zero two times */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 0);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 0);
|
||||
|
||||
/* Test if the counter was never processed */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* write two times with non-zero values*/
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 17);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 18);
|
||||
|
||||
/* Test if the counter was still processed 2 times */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 2.0);
|
||||
|
||||
//number of tests 8
|
||||
}
|
||||
|
||||
static void test_oopt_when_transition_zero(void){
|
||||
testdbPutFieldOk("longout_rec.OOPT", DBF_ENUM, longoutOOPT_Transition_To_Zero);
|
||||
|
||||
/* reset rec processing counter */
|
||||
testdbPutFieldOk("counter.VAL", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* write non-zero then zero */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 0);
|
||||
|
||||
/* Test if the counter was processed */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 1.0);
|
||||
|
||||
/* write another transition to zero */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 17);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 0);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 17);
|
||||
|
||||
/* Test if the counter was processed once more */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 2.0);
|
||||
|
||||
//number of tests 9
|
||||
}
|
||||
|
||||
static void test_oopt_when_transition_nonzero(void){
|
||||
testdbPutFieldOk("longout_rec.OOPT", DBF_ENUM, longoutOOPT_Transition_To_Non_zero);
|
||||
|
||||
/* write non-zero to start fresh */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
|
||||
/* reset rec processing counter */
|
||||
testdbPutFieldOk("counter.VAL", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* write non-zero then zero */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 17);
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 0);
|
||||
|
||||
/* Test if the counter was never processed */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* write a transition to non-zero */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 18);
|
||||
|
||||
/* Test if the counter was processed */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 1.0);
|
||||
|
||||
//number of tests 8
|
||||
}
|
||||
|
||||
static void test_changing_out_field(void){
|
||||
/* change OOPT to On Change */
|
||||
testdbPutFieldOk("longout_rec.OOPT", DBF_ENUM, longoutOOPT_On_Change);
|
||||
|
||||
/* write an initial value */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
|
||||
/* reset rec processing counter */
|
||||
testdbPutFieldOk("counter.VAL", DBF_DOUBLE, 0.0);
|
||||
testdbPutFieldOk("counter2.VAL", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* write the same value */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
|
||||
/* Test if the counter was never processed */
|
||||
testdbGetFieldEqual("counter", DBF_DOUBLE, 0.0);
|
||||
|
||||
/* change the OUT link to another counter */
|
||||
testdbPutFieldOk("longout_rec.OUT", DBF_STRING, "counter2.B PP");
|
||||
|
||||
/* write the same value */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
|
||||
/* Test if the counter was processed once */
|
||||
testdbGetFieldEqual("counter2", DBF_DOUBLE, 1.0);
|
||||
|
||||
/* write the same value */
|
||||
testdbPutFieldOk("longout_rec.VAL", DBF_LONG, 16);
|
||||
|
||||
/* Test if the counter was not processed again */
|
||||
testdbGetFieldEqual("counter2", DBF_DOUBLE, 1.0);
|
||||
}
|
||||
|
||||
MAIN(longoutTest) {
|
||||
|
||||
testPlan(6+8+8+8+9+8+11);
|
||||
|
||||
testdbPrepare();
|
||||
testdbReadDatabase("recTestIoc.dbd", NULL, NULL);
|
||||
recTestIoc_registerRecordDeviceDriver(pdbbase);
|
||||
|
||||
testdbReadDatabase("longoutTest.db", NULL, NULL);
|
||||
|
||||
eltc(0);
|
||||
testIocInitOk();
|
||||
eltc(1);
|
||||
|
||||
test_oopt_everytime();
|
||||
test_oopt_onchange();
|
||||
test_oopt_whenzero();
|
||||
test_oopt_whennonzero();
|
||||
test_oopt_when_transition_zero();
|
||||
test_oopt_when_transition_nonzero();
|
||||
test_changing_out_field();
|
||||
|
||||
testIocShutdownOk();
|
||||
testdbCleanup();
|
||||
|
||||
return testDone();
|
||||
}
|
||||
17
modules/database/test/std/rec/longoutTest.db
Normal file
17
modules/database/test/std/rec/longoutTest.db
Normal file
@@ -0,0 +1,17 @@
|
||||
record(calc, "counter") {
|
||||
field(INPA, "counter")
|
||||
field(CALC, "A+1")
|
||||
field(SCAN, "Passive")
|
||||
}
|
||||
|
||||
record(calc, "counter2") {
|
||||
field(INPA, "counter2")
|
||||
field(CALC, "A+1")
|
||||
field(SCAN, "Passive")
|
||||
}
|
||||
|
||||
record(longout, "longout_rec") {
|
||||
field(VAL, "0")
|
||||
field(OUT, "counter.B PP")
|
||||
field(PINI, "YES")
|
||||
}
|
||||
Reference in New Issue
Block a user