Various fixes for vxWorks

Provide a separate dbd file for each test.
Don't require a writable filesystem.
Simplfy xRecord.c again.
This commit is contained in:
Andrew Johnson
2012-06-29 10:09:56 -05:00
parent 2fd6004827
commit bde52418b9
10 changed files with 107 additions and 176 deletions
+35 -28
View File
@@ -10,8 +10,8 @@ TOP=../../../..
include $(TOP)/configure/CONFIG
PROD_vxWorks += dbTestHarness
PROD_RTEMS += dbTestHarness
PROD_vxWorks += dbTestHarness chfPluginTest
PROD_RTEMS += dbTestHarness chfPluginTest
PROD_LIBS = dbCore ca Com
@@ -20,6 +20,36 @@ callbackTest_SRCS += callbackTest.c
dbTestHarness_SRCS += callbackTest.c
TESTS += callbackTest
TESTPROD_HOST += dbStateTest
dbStateTest_SRCS += dbStateTest.c
dbTestHarness_SRCS += dbStateTest.c
TESTS += dbStateTest
TESTPROD_HOST += dbChannelTest
dbChannelTest_SRCS += xRecord.c
dbChannelTest_SRCS += dbChannelTest.c
dbChannelTest_SRCS += dbChannelTest_registerRecordDeviceDriver.cpp
dbTestHarness_SRCS += xRecord.c
dbTestHarness_SRCS += dbChannelTest.c
dbTestHarness_SRCS += dbChannelTest_registerRecordDeviceDriver.cpp
TESTS += dbChannelTest
TESTPROD_HOST += chfPluginTest
chfPluginTest_SRCS += xRecord.c
chfPluginTest_SRCS += chfPluginTest.c
chfPluginTest_SRCS += chfPluginTest_registerRecordDeviceDriver.cpp
dbTestHarness_SRCS += chfPluginTest.c
dbTestHarness_SRCS += chfPluginTest_registerRecordDeviceDriver.cpp
TESTS += chfPluginTest
TESTPROD_HOST += arrShorthandTest
arrShorthandTest_SRCS += xRecord.c
arrShorthandTest_SRCS += arrShorthandTest.c
arrShorthandTest_SRCS += arrShorthandTest_registerRecordDeviceDriver.cpp
dbTestHarness_SRCS += arrShorthandTest.c
dbTestHarness_SRCS += arrShorthandTest_registerRecordDeviceDriver.cpp
TESTS += arrShorthandTest
dbTestHarness_SRCS += epicsRunDbTests.c
dbTestHarness_SRCS_RTEMS = rtemsTestHarness.c
@@ -27,32 +57,9 @@ dbTestHarness_SRCS_RTEMS = rtemsTestHarness.c
TESTSPEC_vxWorks = dbTestHarness.munch; epicsRunDbTests
TESTSPEC_RTEMS = dbTestHarness.boot; epicsRunDbTests
TESTPROD_HOST += dbChannelTest
dbChannelTest_SRCS += dbChannelTest.c xRecord.c
dbTestHarness_SRCS += dbChannelTest.c
OBJS_IOC_vxWorks += dbChannelTest
TESTS += dbChannelTest
TESTPROD_HOST += chfPluginTest
chfPluginTest_SRCS += chfPluginTest.c xRecord.c
dbTestHarness_SRCS += chfPluginTest.c
OBJS_IOC_vxWorks += chfPluginTest
TESTS += chfPluginTest
TESTPROD_HOST += arrShorthandTest
arrShorthandTest_SRCS += arrShorthandTest.c xRecord.c
dbTestHarness_SRCS += arrShorthandTest.c
OBJS_IOC_vxWorks += arrShorthandTest
TESTS += arrShorthandTest
TESTPROD_HOST += dbStateTest
dbStateTest_SRCS += dbStateTest.c
dbTestHarness_SRCS += dbStateTest.c
OBJS_IOC_vxWorks += dbStateTest
TESTS += dbStateTest
dbTestHarness_SRCS += xRecord.c
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
include $(TOP)/configure/RULES
# xRecord$(OBJ): $(COMMON_DIR)/xRecord.h
xRecord$(DEP): $(COMMON_DIR)/xRecord.h
+11 -7
View File
@@ -24,6 +24,7 @@
#include "registry.h"
#include "epicsUnitTest.h"
#include "testMain.h"
#include "osiFileName.h"
typedef struct myStruct {
epicsInt32 start;
@@ -76,21 +77,24 @@ static void testHead (char* title) {
testDiag("--------------------------------------------------------");
}
int loadTestDB(DBBASE **ppbase);
void arrShorthandTest_registerRecordDeviceDriver(struct dbBase *);
MAIN(arrShorthandTest)
{
dbChannel *pch;
testPlan(28);
testPlan(26);
db_init_events();
testHead("Set up database");
if(loadTestDB(&pdbbase))
return testDone();
if (dbReadDatabase(&pdbbase, "arrShorthandTest.dbd",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Database description not loaded");
testOk(!!pdbbase, "pdbbase was set");
arrShorthandTest_registerRecordDeviceDriver(pdbbase);
if (dbReadDatabase(&pdbbase, "xRecord.db",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Test database not loaded");
testHead("Register plugin");
testOk(!chfPluginRegister("arr", &myPif, opts), "register fake arr plugin");
@@ -125,7 +129,7 @@ MAIN(arrShorthandTest)
dbFreeBase(pdbbase);
registryFree();
pdbbase=0;
pdbbase = NULL;
return testDone();
}
+1
View File
@@ -0,0 +1 @@
include "xRecord.dbd"
+12 -7
View File
@@ -18,6 +18,7 @@
#include "registry.h"
#include "epicsUnitTest.h"
#include "testMain.h"
#include "osiFileName.h"
#define PATTERN 0x55555555
#define TYPE_START 0xAAA
@@ -470,14 +471,14 @@ static void testHead (char* title) {
testDiag("--------------------------------------------------------");
}
int loadTestDB(DBBASE **ppbase);
void chfPluginTest_registerRecordDeviceDriver(struct dbBase *);
MAIN(chfPluginTest)
{
dbChannel *pch;
db_field_log *pfl;
testPlan(1353);
testPlan(1351);
db_init_events();
@@ -492,10 +493,14 @@ MAIN(chfPluginTest)
testOk(strcmp(chfPluginEnumString(colorEnum, 3, "-"), "-") == 0,
"Enum to string: invalid index");
testHead("Set up database");
if(loadTestDB(&pdbbase))
return testDone();
testOk(!!pdbbase, "pdbbase was set");
if (dbReadDatabase(&pdbbase, "chfPluginTest.dbd",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Database description not loaded");
chfPluginTest_registerRecordDeviceDriver(pdbbase);
if (dbReadDatabase(&pdbbase, "xRecord.db",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Test database not loaded");
testHead("Try to register buggy plugins");
testOk(!!chfPluginRegister("buggy", &myPif, brokenOpts1),
@@ -825,7 +830,7 @@ MAIN(chfPluginTest)
dbFreeBase(pdbbase);
registryFree();
pdbbase=0;
pdbbase = NULL;
return testDone();
}
+1
View File
@@ -0,0 +1 @@
include "xRecord.dbd"
+12 -7
View File
@@ -20,6 +20,7 @@
#include "recSup.h"
#include "epicsUnitTest.h"
#include "testMain.h"
#include "osiFileName.h"
/* Expected call bit definitions */
#define e_start 0x00000001
@@ -144,22 +145,26 @@ void c_close(chFilter *filter)
}
chFilterIf testIf =
{ p_start, p_abort, p_end, p_null, p_boolean, p_integer, p_double,
{ NULL, p_start, p_abort, p_end, p_null, p_boolean, p_integer, p_double,
p_string, p_start_map, p_map_key, p_end_map, p_start_array, p_end_array,
c_open, c_reg_pre, c_reg_post, c_report, c_close };
int loadTestDB(DBBASE **ppbase);
void dbChannelTest_registerRecordDeviceDriver(struct dbBase *);
MAIN(testDbChannel) /* dbChannelTest is an API routine... */
{
dbChannel *pch;
testPlan(68);
testPlan(66);
if(loadTestDB(&pdbbase))
return testDone();
if (dbReadDatabase(&pdbbase, "dbChannelTest.dbd",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Database description not loaded");
testOk(!!pdbbase, "pdbbase was set");
dbChannelTest_registerRecordDeviceDriver(pdbbase);
if (dbReadDatabase(&pdbbase, "xRecord.db",
"." OSI_PATH_LIST_SEPARATOR "..", NULL))
testAbort("Test database not loaded");
r = e = 0;
/* dbChannelTest() checks record and field names */
@@ -247,7 +252,7 @@ MAIN(testDbChannel) /* dbChannelTest is an API routine... */
dbFreeBase(pdbbase);
registryFree();
pdbbase=0;
pdbbase = NULL;
return testDone();
}
+1
View File
@@ -0,0 +1 @@
include "xRecord.dbd"
+20 -127
View File
@@ -1,132 +1,25 @@
#include <epicsStdio.h>
#include <string.h>
#include "epicsTypes.h"
#include "dbBase.h"
#include "devSup.h"
#include "registryCommon.h"
#include "registryRecordType.h"
#include "dbStaticLib.h"
#include "epicsUnitTest.h"
/*************************************************************************\
* 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.
\*************************************************************************/
/*
* Test database initialization
* Author: Andrew Johnson <anj@aps.anl.gov>
* Ralph Lange <Ralph.Lange@bessy.de>
*/
/* No actual record support code is provided */
#include "dbAccessDefs.h"
#include <recSup.h>
#define GEN_SIZE_OFFSET
#include "xRecord.h"
#include <epicsExport.h>
static rset xRSET;
/* the following would normally be found in xRecord.h */
typedef struct xRecord {
char name[61]; /* Record Name */
epicsInt32 val; /* Value */
} xRecord;
typedef enum {
xRecordNAME = 0,
xRecordVAL = 1
} xFieldIndex;
static int xRecordSizeOffset(dbRecordType *prt)
{
xRecord *prec = 0;
prt->papFldDes[xRecordNAME]->size = sizeof(prec->name);
prt->papFldDes[xRecordVAL]->size = sizeof(prec->val);
prt->papFldDes[xRecordNAME]->offset = (char *)&prec->name - (char *)prec;
prt->papFldDes[xRecordVAL]->offset = (char *)&prec->val - (char *)prec;
prt->rec_size = sizeof(*prec);
return 0;
}
/* the following would normally be found in xRecord_registerRecordDeviceDriver.cpp */
static const char * const recordTypeNames[] = {
"x"
};
static const recordTypeLocation rtl[] = {
{&xRSET, &xRecordSizeOffset}
};
/* the following wpuld normally be the contents of xRecord.dbd */
static const char xRecord_dbd[] =
"# This is a combined minimal DBD and DB file\n"
"\n"
"recordtype(x) {\n"
" field(NAME, DBF_STRING) {\n"
" prompt(\"Record Name\")\n"
" special(SPC_NOMOD)\n"
" size(61)\n"
" }\n"
" field(VAL, DBF_LONG) {\n"
" prompt(\"Value\")\n"
" }\n"
"}\n";
/* the following is a db file which loads a single record instance */
static const char recinst_db[] = "record(x, x) {}\n";
/* The remainder of this file is specific to the test database initialization */
static FILE* makefile(const char* contents)
{
size_t len=strlen(contents);
FILE *fp=epicsTempFile();
if(!fp) {
perror("epicsTempFile fails");
return NULL;
}
if(fwrite(contents, 1, len, fp)!=len){
perror("makefile fwrite failed");
goto fail;
}
if(fseek(fp, 0, SEEK_SET)!=0)
goto fail;
return fp;
fail:
fclose(fp);
return NULL;
}
int loadTestDB(DBBASE **ppbase)
{
FILE *fp=makefile(xRecord_dbd);
if(!fp) {
testFail("Failed to create temp xRecord.dbd");
return -1;
}
if(dbReadDatabaseFP(ppbase, fp, 0, 0)) {
testFail("Failed to load temp xRecord.dbd");
goto fail;
}
/* fp closed by dbReadDatabaseFP */
registerRecordTypes(*ppbase, NELEMENTS(rtl), recordTypeNames, rtl);
fp=makefile(recinst_db);
if(!fp) {
testFail("Failed to create temp xinst.db");
return -1;
}
if(dbReadDatabaseFP(ppbase, fp, 0, 0)) {
testFail("Failed to load temp xinst.db");
goto fail;
}
/* fp closed by dbReadDatabaseFP */
testPass("Loaded test database");
return 0;
fail:
fclose(fp);
return -1;
}
epicsExportAddress(rset,xRSET);
+2
View File
@@ -0,0 +1,2 @@
record(x, x) {}
+12
View File
@@ -0,0 +1,12 @@
# This is a combined minimal DBD and DB file
recordtype(x) {
field(NAME, DBF_STRING) {
prompt("Record Name")
special(SPC_NOMOD)
size(61)
}
field(VAL, DBF_LONG) {
prompt("Value")
}
}