From 1d430e1bfd401aca279a61a1cab812f59990c8c9 Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Tue, 31 Mar 2020 11:54:42 +0200 Subject: [PATCH] example: add simple test to check correct linkage - needs to be 3.14 compatible - fixes #27 --- exampleApp/Makefile | 5 +++ exampleApp/test/Makefile | 30 ++++++++++++++++++ exampleApp/test/exampleTest.c | 58 +++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 exampleApp/test/Makefile create mode 100644 exampleApp/test/exampleTest.c diff --git a/exampleApp/Makefile b/exampleApp/Makefile index 10e0126..4b0056c 100644 --- a/exampleApp/Makefile +++ b/exampleApp/Makefile @@ -4,5 +4,10 @@ DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *src*)) DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Src*)) DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *db*)) DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *Db*)) + +DIRS := $(DIRS) test + +test_DEPEND_DIRS += src + include $(TOP)/configure/RULES_DIRS diff --git a/exampleApp/test/Makefile b/exampleApp/test/Makefile new file mode 100644 index 0000000..06bb494 --- /dev/null +++ b/exampleApp/test/Makefile @@ -0,0 +1,30 @@ +#************************************************************************* +# Copyright (c) 2020 ITER Organization. +# EPICS BASE is distributed subject to a Software License Agreement found +# in the file LICENSE that is included with this distribution. +#************************************************************************* +CURDIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) +TOP = ../.. + +include $(TOP)/configure/CONFIG + +# use the new RSET definition +USR_CPPFLAGS += -DUSE_TYPED_RSET + +DBD = exampleTest.dbd +exampleTest_DBD += example.dbd + +PROD_LIBS += exampleSupport +ifneq ($(SNCSEQ),) + PROD_LIBS += seq pv +endif +PROD_LIBS += $(EPICS_BASE_IOC_LIBS) + +TESTPROD_HOST += exampleTest +exampleTest_SRCS += exampleTest.c +exampleTest_SRCS += exampleTest_registerRecordDeviceDriver.cpp +TESTS += exampleTest + +TESTSCRIPTS_HOST += $(TESTS:%=%.t) + +include $(TOP)/configure/RULES diff --git a/exampleApp/test/exampleTest.c b/exampleApp/test/exampleTest.c new file mode 100644 index 0000000..c4fa6ee --- /dev/null +++ b/exampleApp/test/exampleTest.c @@ -0,0 +1,58 @@ +/*************************************************************************\ +* Copyright (c) 2020 ITER Organization. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Author: Ralph Lange + */ + +#include + +#include +#include + +#include +#include +#include + +void exampleTest_registerRecordDeviceDriver(struct dbBase *); + +static dbCommon *prec; + +/* from Base 3.15 dbUnitTest.c */ +static +dbCommon* testdbRecordPtr(const char* pv) +{ + DBADDR addr; + + if (dbNameToAddr(pv, &addr)) + testAbort("Missing record \"%s\"", pv); + + return addr.precord; +} + +static void testOnce(void) +{ + testDiag("check that tests work"); + + dbReadDatabase(&pdbbase, "example.dbd", "../../../dbd", NULL); + exampleTest_registerRecordDeviceDriver(pdbbase); + dbReadDatabase(&pdbbase, "dbExample1.db", "../../../db", "user=test"); + + testDiag("Searching for records from example application"); + + prec = testdbRecordPtr("test:xxxExample"); + testOk((prec != NULL), "record test:xxxExample"); + + prec = testdbRecordPtr("test:aiExample"); + testOk((prec != NULL), "record test:aiExample"); +} + +MAIN(exampleTest) +{ + testPlan(2); + testOnce(); + return testDone(); +}