dbScanTest: start with test of scanOnce3()

This commit is contained in:
Michael Davidsaver
2015-01-05 16:26:47 -05:00
parent d897c9b686
commit 6d7a0327e0
3 changed files with 81 additions and 0 deletions

View File

@@ -28,6 +28,12 @@ testHarness_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp
PROD_LIBS = dbTestIoc dbCore ca Com
TESTPROD_HOST += dbScanTest
dbScanTest_SRCS += dbScanTest.c
dbScanTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp
testHarness_SRCS += dbScanTest.c
TESTS += dbScanTest
TESTPROD_HOST += dbShutdownTest
dbShutdownTest_SRCS += dbShutdownTest.c
dbShutdownTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp

View File

@@ -0,0 +1,73 @@
/*************************************************************************\
* Copyright (c) 2015 Brookhaven Science Assoc. as operator of Brookhaven
* National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* Author: Michael Davidsaver <mdavidsaver@bnl.gov>
*/
#include <string.h>
#include "dbScan.h"
#include "epicsEvent.h"
#include "dbUnitTest.h"
#include "testMain.h"
#include "dbAccess.h"
#include "errlog.h"
void dbTestIoc_registerRecordDeviceDriver(struct dbBase *);
static epicsEventId waiter;
static int called;
static dbCommon *prec;
static void onceComp(void *junk, dbCommon *prec)
{
testOk1(junk==(void*)&waiter);
testOk1(strcmp(prec->name, "reca")==0);
called = 1;
epicsEventMustTrigger(waiter);
}
static void testOnce(void)
{
testDiag("check scanOnce3() callback");
waiter = epicsEventMustCreate(epicsEventError);
testdbPrepare();
testdbReadDatabase("dbTestIoc.dbd", NULL, NULL);
dbTestIoc_registerRecordDeviceDriver(pdbbase);
testdbReadDatabase("dbLockTest.db", NULL, NULL);
eltc(0);
testIocInitOk();
eltc(1);
prec = testdbRecordPtr("reca");
testDiag("scanOnce %s", prec->name);
scanOnce3(prec, onceComp, &waiter);
testDiag("Waiting");
epicsEventMustWait(waiter);
testOk1(called==1);
if(!called)
testSkip(2, "callback failed to run");
testIocShutdownOk();
testdbCleanup();
epicsEventDestroy(waiter);
}
MAIN(dbScanTest)
{
testPlan(3);
testOnce();
return testDone();
}

View File

@@ -22,6 +22,7 @@ int callbackParallelTest(void);
int dbStateTest(void);
int dbCaStatsTest(void);
int dbShutdownTest(void);
int dbScanTest(void);
int scanIoTest(void);
int dbLockTest(void);
int dbPutLinkTest(void);
@@ -40,6 +41,7 @@ void epicsRunDbTests(void)
runTest(dbStateTest);
runTest(dbCaStatsTest);
runTest(dbShutdownTest);
runTest(dbScanTest);
runTest(scanIoTest);
runTest(dbLockTest);
runTest(dbPutLinkTest);