Merged the db-test branch.

Also made additional changes:
* Simplified xRecord.c so it can run on vxWorks.
* Standard way to load DBD and DB files in tests

All test harnesses now run on vxWorks (but some tests still fail).
This commit is contained in:
Andrew Johnson
2012-07-02 11:03:55 -05:00
28 changed files with 654 additions and 306 deletions

View File

@@ -93,8 +93,10 @@ static db_field_log* filter(void* pvt, dbChannel *chan, db_field_log *pfl) {
}
}
}
if (drop) return NULL;
else return pfl;
if (drop) {
db_delete_field_log(pfl);
return NULL;
} else return pfl;
}
static void channelRegisterPre(dbChannel *chan, void *pvt,

View File

@@ -59,6 +59,8 @@ static void * allocPvt(void)
static void freePvt(void *pvt)
{
myStruct *my = (myStruct*) pvt;
db_delete_field_log(my->lastfl);
freeListFree(myStructFreeList, pvt);
}

View File

@@ -1,5 +1,5 @@
#*************************************************************************
# Copyright (c) 2006 UChicago Argonne LLC, as Operator of Argonne
# Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
# National Laboratory.
# Copyright (c) 2002 The Regents of the University of California, as
# Operator of Los Alamos National Laboratory.
@@ -10,30 +10,62 @@ TOP=../../../..
include $(TOP)/configure/CONFIG
PROD_LIBS += dbRecStd dbCore ca Com
PROD_LIBS = dbRecStd dbCore ca Com
TARGETS += $(COMMON_DIR)/tsTest.dbd
tsTest_DBD += xRecord.dbd
TESTPROD_HOST += tsTest
tsTest_SRCS += tsTest.c xRecord_registerRecordDeviceDriver.cpp
OBJS_IOC_vxWorks += tsTest
tsTest_SRCS += xRecord.c
tsTest_SRCS += tsTest.c
tsTest_SRCS += tsTest_registerRecordDeviceDriver.cpp
testHarness_SRCS += tsTest.c
testHarness_SRCS += tsTest_registerRecordDeviceDriver.cpp
TESTS += tsTest
TARGETS += $(COMMON_DIR)/dbndTest.dbd
dbndTest_DBD += xRecord.dbd
TESTPROD_HOST += dbndTest
dbndTest_SRCS += dbndTest.c xRecord_registerRecordDeviceDriver.cpp
OBJS_IOC_vxWorks += dbndTest
dbndTest_SRCS += xRecord.c
dbndTest_SRCS += dbndTest.c
dbndTest_SRCS += dbndTest_registerRecordDeviceDriver.cpp
testHarness_SRCS += dbndTest.c
testHarness_SRCS += dbndTest_registerRecordDeviceDriver.cpp
TESTS += dbndTest
TARGETS += $(COMMON_DIR)/arrTest.dbd
arrTest_DBD += arrRecord.dbd
TESTPROD_HOST += arrTest
arrTest_SRCS += arrTest.cpp arrRecord.c arrRecord_registerRecordDeviceDriver.cpp
OBJS_IOC_vxWorks += arrTest
arrTest_SRCS += arrRecord.c
arrTest_SRCS += arrTest.cpp
arrTest_SRCS += arrTest_registerRecordDeviceDriver.cpp
testHarness_SRCS += arrRecord.c
testHarness_SRCS += arrTest.cpp
testHarness_SRCS += arrTest_registerRecordDeviceDriver.cpp
TESTS += arrTest
TARGETS += $(COMMON_DIR)/syncTest.dbd
syncTest_DBD += xRecord.dbd
TESTPROD_HOST += syncTest
syncTest_SRCS += syncTest.c xRecord_registerRecordDeviceDriver.cpp
OBJS_IOC_vxWorks += syncTest
syncTest_SRCS += xRecord.c
syncTest_SRCS += syncTest.c
syncTest_SRCS += syncTest_registerRecordDeviceDriver.cpp
testHarness_SRCS += syncTest.c
testHarness_SRCS += syncTest_registerRecordDeviceDriver.cpp
TESTS += syncTest
# epicsRunFilterTests runs all the test programs in a known working order.
testHarness_SRCS += epicsRunFilterTests.c
testHarness_SRCS += xRecord.c
filterTestHarness_SRCS += $(testHarness_SRCS)
filterTestHarness_SRCS_RTEMS += rtemsTestHarness.c
PROD_vxWorks = filterTestHarness
PROD_RTEMS = filterTestHarness
TESTSPEC_vxWorks = filterTestHarness.munch; epicsRunFilterTests
TESTSPEC_RTEMS = filterTestHarness.boot; epicsRunFilterTests
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
include $(TOP)/configure/RULES

View File

@@ -28,6 +28,8 @@
#include "epicsStdio.h"
#include "envDefs.h"
#include "dbStaticLib.h"
#include "dbmf.h"
#include "registry.h"
#include "subRecord.h"
#include "dbAddr.h"
#include "dbAccess.h"
@@ -37,10 +39,11 @@
#include "dbChannel.h"
#include "epicsUnitTest.h"
#include "testMain.h"
#include "osiFileName.h"
#include "arrRecord.h"
extern "C" int arrRecord_registerRecordDeviceDriver(struct dbBase *pdbbase);
extern "C" int arrTest_registerRecordDeviceDriver(struct dbBase *pdbbase);
extern "C" void (*pvar_func_arrInitialize)(void);
#define CA_SERVER_PORT "65535"
@@ -293,6 +296,19 @@ static void check(short dbr_type) {
TEST5B(3, -8, -4, "both sides from-end");
}
static dbEventCtx evtctx;
static void arrTestCleanup(void* junk)
{
dbFreeBase(pdbbase);
registryFree();
pdbbase=0;
db_close_events(evtctx);
dbmfFreeChunks();
}
MAIN(arrTest)
{
const chFilterPlugin *plug;
@@ -304,21 +320,25 @@ MAIN(arrTest)
epicsEnvSet("EPICS_CA_SERVER_PORT", server_port);
if (dbReadDatabase(&pdbbase, "arrRecord.dbd",
"..:../../../../../dbd", NULL))
if (dbReadDatabase(&pdbbase, "arrTest.dbd",
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
"../O.Common", NULL))
testAbort("Database description not loaded");
(*pvar_func_arrInitialize)();
arrRecord_registerRecordDeviceDriver(pdbbase);
arrTest_registerRecordDeviceDriver(pdbbase);
registryFunctionAdd("exit", (REGISTRYFUNCTION) exitSubroutine);
if (dbReadDatabase(&pdbbase, "arrTest.db", "..", NULL))
if (dbReadDatabase(&pdbbase, "arrTest.db",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Test database not loaded");
epicsAtExit(&arrTestCleanup,NULL);
/* Start the IOC */
iocInit();
db_init_events();
evtctx = db_init_events();
epicsThreadSleep(0.2);
testOk(!!(plug = dbFindFilter(arr, strlen(arr))), "plugin arr registered correctly");
@@ -327,11 +347,5 @@ MAIN(arrTest)
check(DBR_DOUBLE);
check(DBR_STRING);
dbFreeBase(pdbbase);
return testDone();
epicsExit(EXIT_SUCCESS);
/*Note that the following statement will never be executed*/
return 0;
}

View File

@@ -16,10 +16,13 @@
#include "dbAccessDefs.h"
#include "db_field_log.h"
#include "dbCommon.h"
#include "registry.h"
#include "chfPlugin.h"
#include "epicsUnitTest.h"
#include "epicsTime.h"
#include "dbmf.h"
#include "testMain.h"
#include "osiFileName.h"
#define PATTERN 0x55
@@ -96,7 +99,7 @@ static void testHead (char* title) {
testDiag("--------------------------------------------------------");
}
void xRecord_registerRecordDeviceDriver(struct dbBase *);
void dbndTest_registerRecordDeviceDriver(struct dbBase *);
MAIN(dbndTest)
{
@@ -109,18 +112,22 @@ MAIN(dbndTest)
void *arg_out = NULL;
db_field_log *pfl2;
db_field_log fl1;
dbEventCtx evtctx;
testPlan(59);
db_init_events();
evtctx = db_init_events();
if (dbReadDatabase(&pdbbase, "xRecord.dbd", "..", NULL))
if (dbReadDatabase(&pdbbase, "dbndTest.dbd",
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
"../O.Common", NULL))
testAbort("Database description not loaded");
(*pvar_func_dbndInitialize)(); /* manually initialize plugin */
xRecord_registerRecordDeviceDriver(pdbbase);
dbndTest_registerRecordDeviceDriver(pdbbase);
if (dbReadDatabase(&pdbbase, "dbChannelTest.db", "..", NULL))
if (dbReadDatabase(&pdbbase, "xRecord.db",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Test database not loaded");
testOk(!!(plug = dbFindFilter(dbnd, strlen(dbnd))), "plugin dbnd registered correctly");
@@ -160,9 +167,13 @@ MAIN(dbndTest)
fl_setup(pch, pfl2);
mustPassOnce(pch, pfl2, "abs", 0., 0);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustPassOnce(pch, pfl2, "abs", 0., 1);
db_delete_field_log(pfl2);
dbChannelDelete(pch);
/* Delta = -1: pass any update */
@@ -192,11 +203,25 @@ MAIN(dbndTest)
fl_setup(pch, pfl2);
mustPassOnce(pch, pfl2, "abs", 3., 1);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustDrop(pch, pfl2, "abs", 3., 3);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustDrop(pch, pfl2, "abs", 3., 4);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustPassOnce(pch, pfl2, "abs", 3., 5);
db_delete_field_log(pfl2);
dbChannelDelete(pch);
/* Delta = relative */
@@ -211,25 +236,51 @@ MAIN(dbndTest)
fl_setup(pch, pfl2);
mustPassOnce(pch, pfl2, "rel", 50., 1);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustPassOnce(pch, pfl2, "rel", 50., 2);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustDrop(pch, pfl2, "rel", 50., 3);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustPassOnce(pch, pfl2, "rel", 50., 4);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustDrop(pch, pfl2, "rel", 50., 5);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustDrop(pch, pfl2, "rel", 50., 6);
pfl2 = db_create_read_log(pch);
testDiag("new field_log from record");
fl_setup(pch, pfl2);
mustPassOnce(pch, pfl2, "rel", 50., 7);
db_delete_field_log(pfl2);
dbChannelDelete(pch);
dbFreeBase(pdbbase);
registryFree();
pdbbase=0;
db_close_events(evtctx);
dbmfFreeChunks();
return testDone();
}
#define GEN_SIZE_OFFSET
#include "xRecord.h"
#include <recSup.h>
#include <epicsExport.h>
static rset xRSET;
epicsExportAddress(rset,xRSET);

View File

@@ -0,0 +1,33 @@
/*************************************************************************\
* Copyright (c) 2012 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* Run filter tests as a batch.
*/
#include "epicsUnitTest.h"
#include "epicsExit.h"
#include "dbmf.h"
int tsTest(void);
int dbndTest(void);
int syncTest(void);
int arrTest(void);
void epicsRunFilterTests(void)
{
testHarness();
runTest(tsTest);
runTest(dbndTest);
runTest(syncTest);
runTest(arrTest);
dbmfFreeChunks();
epicsExit(0); /* Trigger test harness */
}

View File

@@ -17,11 +17,14 @@
#include "db_field_log.h"
#include "dbCommon.h"
#include "dbChannel.h"
#include "registry.h"
#include "chfPlugin.h"
#include "dbmf.h"
#include "epicsUnitTest.h"
#include "epicsTime.h"
#include "dbState.h"
#include "testMain.h"
#include "osiFileName.h"
#define PATTERN 0x55
@@ -127,7 +130,7 @@ static void checkAndOpenChannel(dbChannel *pch, const chFilterPlugin *plug) {
checkCtxRead(pch, red);
}
void xRecord_registerRecordDeviceDriver(struct dbBase *);
void syncTest_registerRecordDeviceDriver(struct dbBase *);
MAIN(syncTest)
{
@@ -136,18 +139,22 @@ MAIN(syncTest)
char myname[] = "sync";
db_field_log *pfl[10];
int i;
dbEventCtx evtctx;
testPlan(0);
db_init_events();
evtctx = db_init_events();
if (dbReadDatabase(&pdbbase, "xRecord.dbd", "..", NULL))
if (dbReadDatabase(&pdbbase, "syncTest.dbd",
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
"../O.Common", NULL))
testAbort("Database description not loaded");
(*pvar_func_syncInitialize)(); /* manually initialize plugin */
xRecord_registerRecordDeviceDriver(pdbbase);
syncTest_registerRecordDeviceDriver(pdbbase);
if (dbReadDatabase(&pdbbase, "dbChannelTest.db", "..", NULL))
if (dbReadDatabase(&pdbbase, "xRecord.db",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Test database not loaded");
testOk(!!(plug = dbFindFilter(myname, strlen(myname))), "plugin %s registered correctly", myname);
@@ -194,6 +201,8 @@ MAIN(syncTest)
for (i = 0; i < 10; i++)
db_delete_field_log(pfl[i]);
dbChannelDelete(pch);
/* mode UNLESS */
testHead("Mode UNLESS (m='unless', s='red')");
@@ -225,6 +234,8 @@ MAIN(syncTest)
for (i = 0; i < 10; i++)
db_delete_field_log(pfl[i]);
dbChannelDelete(pch);
/* mode BEFORE */
testHead("Mode BEFORE (m='before', s='red')");
@@ -254,8 +265,9 @@ MAIN(syncTest)
mustDrop(pch, pfl[8], "state=FALSE, log8");
mustDrop(pch, pfl[9], "state=FALSE, log9");
for (i = 0; i < 10; i++)
db_delete_field_log(pfl[i]);
db_delete_field_log(pfl[2]);
dbChannelDelete(pch);
/* mode FIRST */
@@ -285,8 +297,10 @@ MAIN(syncTest)
mustDrop(pch, pfl[7], "state=FALSE, log7");
mustDrop(pch, pfl[8], "state=FALSE, log8");
for (i = 0; i < 10; i++)
db_delete_field_log(pfl[i]);
db_delete_field_log(pfl[3]);
db_delete_field_log(pfl[9]);
dbChannelDelete(pch);
/* mode LAST */
@@ -317,8 +331,9 @@ MAIN(syncTest)
mustDrop(pch, pfl[8], "state=FALSE, log8");
mustDrop(pch, pfl[9], "state=FALSE, log9");
for (i = 0; i < 10; i++)
db_delete_field_log(pfl[i]);
db_delete_field_log(pfl[5]);
dbChannelDelete(pch);
/* mode AFTER */
@@ -348,20 +363,17 @@ MAIN(syncTest)
mustDrop(pch, pfl[7], "state=FALSE, log7");
mustDrop(pch, pfl[8], "state=FALSE, log8");
for (i = 0; i < 10; i++)
db_delete_field_log(pfl[i]);
db_delete_field_log(pfl[6]);
db_delete_field_log(pfl[9]);
dbChannelDelete(pch);
dbFreeBase(pdbbase);
registryFree();
pdbbase=0;
db_close_events(evtctx);
dbmfFreeChunks();
return testDone();
}
#define GEN_SIZE_OFFSET
#include "xRecord.h"
#include <recSup.h>
#include <epicsExport.h>
static rset xRSET;
epicsExportAddress(rset,xRSET);

View File

@@ -16,8 +16,11 @@
#include "dbAccessDefs.h"
#include "chfPlugin.h"
#include "epicsUnitTest.h"
#include "registry.h"
#include "dbmf.h"
#include "epicsTime.h"
#include "testMain.h"
#include "osiFileName.h"
#define PATTERN 0x55
@@ -36,7 +39,7 @@ static int fl_equal_ex_ts(const db_field_log *pfl1, const db_field_log *pfl2) {
return fl_equal(&fl1, pfl2);
}
void xRecord_registerRecordDeviceDriver(struct dbBase *);
void tsTest_registerRecordDeviceDriver(struct dbBase *);
MAIN(tsTest)
{
@@ -50,18 +53,22 @@ MAIN(tsTest)
db_field_log fl1;
db_field_log *pfl2;
epicsTimeStamp stamp, now;
dbEventCtx evtctx;
testPlan(12);
db_init_events();
evtctx = db_init_events();
if (dbReadDatabase(&pdbbase, "xRecord.dbd", "..", NULL))
if (dbReadDatabase(&pdbbase, "tsTest.dbd",
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
"../O.Common", NULL))
testAbort("Database description not loaded");
(*pvar_func_tsInitialize)(); /* manually initialize plugin */
xRecord_registerRecordDeviceDriver(pdbbase);
tsTest_registerRecordDeviceDriver(pdbbase);
if (dbReadDatabase(&pdbbase, "dbChannelTest.db", "..", NULL))
if (dbReadDatabase(&pdbbase, "xRecord.db",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Test database not loaded");
testOk(!!(plug = dbFindFilter(ts, strlen(ts))), "plugin ts registered correctly");
@@ -92,6 +99,8 @@ MAIN(tsTest)
testOk(!!(pfl2 = db_create_read_log(pch)), "create field log from channel");
stamp = pfl2->time;
db_delete_field_log(pfl2);
pfl2 = dbChannelRunPreChain(pch, &fl1);
epicsTimeGetCurrent(&now);
testOk(epicsTimeDiffInSeconds(&pfl2->time, &stamp) > 0. &&
@@ -99,15 +108,12 @@ MAIN(tsTest)
dbChannelDelete(pch);
dbFreeBase(pdbbase);
registryFree();
pdbbase=0;
db_close_events(evtctx);
dbmfFreeChunks();
return testDone();
}
#define GEN_SIZE_OFFSET
#include "xRecord.h"
#include <recSup.h>
#include <epicsExport.h>
static rset xRSET;
epicsExportAddress(rset,xRSET);

View File

@@ -0,0 +1,25 @@
/*************************************************************************\
* Copyright (c) 2010 UChicago Argonne LLC, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2010 Brookhaven National Laboratory.
* Copyright (c) 2010 Helmholtz-Zentrum Berlin
* fuer Materialien und Energie GmbH.
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* Author: Andrew Johnson <anj@aps.anl.gov>
* Ralph Lange <Ralph.Lange@bessy.de>
*/
#include "dbAccessDefs.h"
#include <recSup.h>
#define GEN_SIZE_OFFSET
#include "xRecord.h"
#include <epicsExport.h>
static rset xRSET;
epicsExportAddress(rset,xRSET);