Merge branch '7.0' into add-simm-to-ao-records

This commit is contained in:
Ralph Lange
2022-05-11 10:47:12 -07:00
committed by GitHub
337 changed files with 4510 additions and 4034 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* Part of dbCaLinkTest, compiled seperately to avoid
* Part of dbCaLinkTest, compiled separately to avoid
* dbAccess.h vs. db_access.h conflicts
*/
+6 -13
View File
@@ -50,13 +50,6 @@ void dbTestIoc_registerRecordDeviceDriver(struct dbBase *);
static epicsEventId waitEvent;
static unsigned waitCounter;
static
void waitForUpdateN(DBLINK *plink, unsigned long n)
{
while(dbCaGetUpdateCount(plink)<n)
epicsThreadSleep(0.01);
}
static
void putLink(DBLINK *plink, short dbr, const void*buf, long nReq)
{
@@ -133,14 +126,14 @@ static void testNativeLink(void)
testOk1(psrclnk->type==CA_LINK);
waitForUpdateN(psrclnk, 1);
testdbCaWaitForUpdateCount(psrclnk, 1);
dbScanLock((dbCommon*)ptarg);
ptarg->val = 42;
db_post_events(ptarg, &ptarg->val, DBE_VALUE|DBE_ALARM|DBE_ARCHIVE);
dbScanUnlock((dbCommon*)ptarg);
waitForUpdateN(psrclnk, 2);
testdbCaWaitForUpdateCount(psrclnk, 2);
dbScanLock((dbCommon*)psrc);
/* local CA_LINK connects immediately */
@@ -218,14 +211,14 @@ static void testStringLink(void)
testOk1(psrclnk->type==CA_LINK);
waitForUpdateN(psrclnk, 1);
testdbCaWaitForUpdateCount(psrclnk, 1);
dbScanLock((dbCommon*)ptarg);
strcpy(ptarg->desc, "hello");
db_post_events(ptarg, &ptarg->desc, DBE_VALUE|DBE_ALARM|DBE_ARCHIVE);
dbScanUnlock((dbCommon*)ptarg);
waitForUpdateN(psrclnk, 2);
testdbCaWaitForUpdateCount(psrclnk, 2);
dbScanLock((dbCommon*)psrc);
/* local CA_LINK connects immediately */
@@ -400,7 +393,7 @@ static void testArrayLink(unsigned nsrc, unsigned ntarg)
testIocInitOk();
eltc(1);
waitForUpdateN(psrclnk, 1);
testdbCaWaitForUpdateCount(psrclnk, 1);
bufsrc = psrc->bptr;
buftarg= ptarg->bptr;
@@ -421,7 +414,7 @@ static void testArrayLink(unsigned nsrc, unsigned ntarg)
db_post_events(ptarg, &ptarg->val, DBE_VALUE|DBE_ALARM|DBE_ARCHIVE);
dbScanUnlock((dbCommon*)ptarg);
waitForUpdateN(psrclnk, 2);
testdbCaWaitForUpdateCount(psrclnk, 2);
dbScanLock((dbCommon*)psrc);
testDiag("fetch source.INP into source.BPTR");
+31 -1
View File
@@ -313,11 +313,39 @@ void testPutArr(void)
testdbGetArrFieldEqual("arr", DBR_LONG, 4, 3, buf);
}
static
void testPutSpecial(void)
{
const char val[] = "special";
const char inp[] = "special.INP";
const char sfx[] = "special.SFX";
testDiag("testPutSpecial()");
/* There are separate sets of calls to dbPutSpecial() in
* dbPut() and in dbPutFieldLink() so we need to check
* both regular fields and link fields.
*/
testdbPutFieldOk(val, DBR_LONG, 1);
testdbPutFieldOk(inp, DBR_STRING, "1.0");
testdbPutFieldOk(sfx, DBR_LONG, SFX_Before); /* Reject early */
testdbPutFieldFail(S_db_Blocked, val, DBR_LONG, 2);
testdbGetFieldEqual(val, DBR_LONG, 1); /* Wasn't modified */
testdbPutFieldFail(S_db_Blocked, inp, DBR_STRING, "2.0");
testdbGetFieldEqual(inp, DBR_STRING, "1.0"); /* Wasn't modified */
testdbPutFieldOk(sfx, DBR_LONG, SFX_After); /* Reject late */
testdbPutFieldFail(S_db_Blocked, val, DBR_LONG, 3);
testdbPutFieldFail(S_db_Blocked, inp, DBR_STRING, "3.0");
testdbPutFieldOk(sfx, DBR_LONG, SFX_None);
testdbPutFieldOk(val, DBR_LONG, 4);
testdbPutFieldOk(inp, DBR_STRING, "4.0");
}
void dbTestIoc_registerRecordDeviceDriver(struct dbBase *);
MAIN(dbPutGet)
{
testPlan(111);
testPlan(124);
testdbPrepare();
testdbMetaDoubleSizes();
@@ -343,6 +371,8 @@ MAIN(dbPutGet)
testPutArr();
testPutSpecial();
testIocShutdownOk();
testdbCleanup();
@@ -46,3 +46,5 @@ record(arr, "arr") {
}
record(x, "recmeta") {}
record(x, "special") {}
+2 -1
View File
@@ -61,6 +61,7 @@ static const struct testParseDataT {
TEST_PV_LINK(" world MSICP", "world", pvlOptMSI|pvlOptCP),
{"#C14 S145 @testing", {VME_IO, "testing", 0, "CS", {14, 145}}},
{"#C14 S0x1b @testing", {VME_IO, "testing", 0, "CS", {14, 0x1b}}},
{"#C14 S145", {VME_IO, "", 0, "CS", {14, 145}}},
{"#B11 C12 N13 A14 F15 @cparam", {CAMAC_IO, "cparam", 0, "BCNAF", {11, 12, 13, 14, 15}}},
{"#B11 C12 N13 A14 F15", {CAMAC_IO, "", 0, "BCNAF", {11, 12, 13, 14, 15}}},
@@ -700,7 +701,7 @@ void testTSEL(void)
MAIN(dbPutLinkTest)
{
testPlan(342);
testPlan(348);
testLinkParse();
testLinkFailParse();
testCADBSet();
+12 -1
View File
@@ -7,6 +7,7 @@
#include <string.h>
#include <errlog.h>
#include <osiFileName.h>
#include <dbAccess.h>
#include <dbStaticLib.h>
#include <dbStaticPvt.h>
@@ -294,12 +295,22 @@ void dbTestIoc_registerRecordDeviceDriver(struct dbBase *);
MAIN(dbStaticTest)
{
const char *ldir;
FILE *fp = NULL;
testPlan(310);
testdbPrepare();
testdbReadDatabase("dbTestIoc.dbd", NULL, NULL);
dbTestIoc_registerRecordDeviceDriver(pdbbase);
testdbReadDatabase("dbStaticTest.db", NULL, NULL);
dbPath(pdbbase,"." OSI_PATH_LIST_SEPARATOR "..");
if(!(ldir = dbOpenFile(pdbbase, "dbStaticTest.db", &fp))) {
testAbort("Unable to read dbStaticTest.db");
}
if(dbReadDatabaseFP(&pdbbase, fp, NULL, NULL)) {
testAbort("Unable to load %s%sdbStaticTest.db",
ldir, OSI_PATH_LIST_SEPARATOR);
}
testEntry("testrec.VAL");
testEntry("testalias.VAL");
+1 -1
View File
@@ -9,7 +9,7 @@
/*
* Lockset stress test.
*
* The test stratagy is for N threads to contend for M records.
* The test strategy is for N threads to contend for M records.
* Each thread will perform one of three operations:
* 1) Lock a single record.
* 2) Lock several records.
+1 -1
View File
@@ -95,7 +95,7 @@ long z_getval(struct link *plink, short dbrType, void *pbuffer,
return ret;
}
/* TODO: atomicly get value and alarm */
/* TODO: atomically get value and alarm */
static
long z_getalarm(const struct link *plink, epicsEnum16 *status,
epicsEnum16 *severity)
+14 -1
View File
@@ -76,6 +76,20 @@ static long process(struct dbCommon *pcommon)
return ret;
}
static long special(struct dbAddr *paddr, int after)
{
struct xRecord *prec = (struct xRecord *) paddr->precord;
if (dbGetFieldIndex(paddr) != xRecordVAL &&
dbGetFieldIndex(paddr) != xRecordINP) {
recGblRecordError(S_db_badField, prec, "x: special");
return S_db_badField;
}
if (prec->sfx == after) {
return S_db_Blocked;
}
return 0;
}
long get_units(struct dbAddr *paddr, char *units)
{
if(dbGetFieldIndex(paddr)==xRecordOTST) {
@@ -125,7 +139,6 @@ long get_alarm_double(struct dbAddr *paddr, struct dbr_alDouble *p)
#define report NULL
#define initialize NULL
#define special NULL
#define get_value NULL
#define cvt_dbaddr NULL
#define get_array_info NULL
+13
View File
@@ -1,9 +1,16 @@
# This is a minimal record definition
menu(xSFX) {
choice(SFX_Before, "Before")
choice(SFX_After, "After")
choice(SFX_None, "None")
}
recordtype(x) {
include "dbCommon.dbd"
field(VAL, DBF_LONG) {
prompt("Value")
special(SPC_MOD)
}
field(C8, DBF_CHAR) {
prompt("Char")
@@ -40,6 +47,7 @@ recordtype(x) {
}
field(INP, DBF_INLINK) {
prompt("Input Link")
special(SPC_MOD)
}
field(CLBK, DBF_NOACCESS) {
prompt("Processing callback")
@@ -50,4 +58,9 @@ recordtype(x) {
prompt("dbGet() options test")
special(SPC_NOMOD)
}
field(SFX, DBF_MENU) {
prompt("Special effects")
menu(xSFX)
initial("None")
}
}
@@ -13,6 +13,7 @@
#include <string.h>
#include "dbAccess.h"
#include "dbStaticLib.h"
#include "dbAccessDefs.h"
#include "db_field_log.h"
@@ -46,6 +47,7 @@ static void fl_setup(dbChannel *chan, db_field_log *pfl) {
pfl->stat = prec->stat;
pfl->sevr = prec->sevr;
pfl->time = prec->time;
pfl->mask = DBE_VALUE;
pfl->field_type = dbChannelFieldType(chan);
pfl->field_size = dbChannelFieldSize(chan);
pfl->no_elements = dbChannelElements(chan);
+9 -9
View File
@@ -37,9 +37,8 @@ TESTS += arrayOpTest
TESTPROD_HOST += recMiscTest
recMiscTest_SRCS += recMiscTest.c
ifeq (NO,$(STATIC_BUILD))
recMiscTest_CFLAGS += -DLINK_DYNAMIC
endif
recMiscTest_CFLAGS_NO = -DLINK_DYNAMIC
recMiscTest_CFLAGS += $(recMiscTest_CFLAGS_$(STATIC_BUILD))
recMiscTest_SRCS += recTestIoc_registerRecordDeviceDriver.cpp
testHarness_SRCS += recMiscTest.c
TESTFILES += ../recMiscTest.db
@@ -128,6 +127,8 @@ regressTest_SRCS += regressTest.c
regressTest_SRCS += regressTest_registerRecordDeviceDriver.cpp
TESTFILES += $(COMMON_DIR)/regressTest.dbd ../regressArray1.db ../regressHex.db ../regressLinkMS.db
TESTFILES += ../badCaLink.db
TESTFILES += ../regressLongCalc.db
TESTFILES += ../regressLinkSevr.db
TESTS += regressTest
TARGETS += $(COMMON_DIR)/simmTest.dbd
@@ -166,12 +167,11 @@ testHarness_SRCS += linkFilterTest.c
TESTFILES += ../linkFilterTest.db
TESTS += linkFilterTest
# dbHeader* is only a compile test
# no need to actually run
TESTPROD += dbHeaderTest
dbHeaderTest_SRCS += dbHeaderTest.cpp
TESTPROD += dbHeaderTestxx
dbHeaderTestxx_SRCS += dbHeaderTestxx.cpp
# These are compile-time tests, no need to link or run
TARGETS += dbHeaderTest$(OBJ)
TARGET_SRCS += dbHeaderTest.cpp
TARGETS += dbHeaderTestxx$(OBJ)
TARGET_SRCS += dbHeaderTestxx.cpp
ifeq ($(T_A),$(EPICS_HOST_ARCH))
# Host-only tests of softIoc/softIocPVA, caget and pvget (if present)
@@ -8,6 +8,8 @@
#include <string.h>
#define EPICS_DBCA_PRIVATE_API
#include "dbAccess.h"
#include "dbStaticLib.h"
#include "dbTest.h"
@@ -116,6 +118,8 @@ void checkAsyncOutput(const char *rec, dbCommon *async)
strcpy(proc, rec);
strcat(proc, ".PROC");
testdbCaWaitForConnect(dbGetDevLink(testdbRecordPtr(rec)));
testdbPutFieldOk(proc, DBF_CHAR, 1);
epicsEventWait(asyncEvent);
+1 -1
View File
@@ -6,7 +6,7 @@
\*************************************************************************/
/* This test includes all public headers from libCom and database modules
* to ensure they are all syntaxtically correct in both C and C++
* to ensure they are all syntactically correct in both C and C++
*/
#include <aaiRecord.h>
@@ -33,15 +33,16 @@
#include "epicsExport.h"
static
void testmbbioFields(const char* rec, unsigned int value)
void testmbbioFields(char dir, unsigned n, unsigned int value)
{
char field[40];
unsigned int i;
testdbGetFieldEqual(rec, DBF_ULONG, value);
sprintf(field,"d%c%d", dir, n);
testdbGetFieldEqual(field, DBF_ULONG, value);
for (i=0; i < 32; i++)
{
sprintf(field,"%s.B%X", rec, i);
sprintf(field,"d%c%d.B%X", dir, n, i);
testdbGetFieldEqual(field, DBF_ULONG, (value>>i)&1);
}
}
@@ -49,16 +50,14 @@ void testmbbioFields(const char* rec, unsigned int value)
static
void testmbbioRecords(unsigned int count, unsigned int value)
{
char rec[40];
unsigned int i;
for (i = 1; i <= count; i++)
{
sprintf(rec, "do%d", i);
testDiag(" ### %s ###", rec);
testmbbioFields(rec, value);
sprintf(rec, "di%d", i);
testmbbioFields(rec, value);
testDiag(" ### do%d ###", i);
testmbbioFields('o', i, value);
testDiag(" ### di%d ###", i);
testmbbioFields('i', i, value);
}
}
@@ -0,0 +1,18 @@
record(ai, "ai") {}
record(stringin, "si1") {
field(INP, "ai.SEVR")
field(FLNK, "li1")
}
record(longin, "li1") {
field(INP, "ai.SEVR")
field(FLNK, "si2")
}
record(stringin, "si2") {
field(INP, "ai.SEVR CA")
field(FLNK, "li2")
}
record(longin, "li2") {
field(INP, "ai.SEVR CA")
}
@@ -0,0 +1,5 @@
record(calc, "test_calc")
{
field(SCAN, "1 second")
field(CALC, "RNDM*100")
}
+74 -1
View File
@@ -5,6 +5,8 @@
* in file LICENSE that is included with this distribution.
\*************************************************************************/
#define EPICS_DBCA_PRIVATE_API
#include <dbUnitTest.h>
#include <testMain.h>
#include <dbAccess.h>
@@ -23,6 +25,8 @@ void regressTest_registerRecordDeviceDriver(struct dbBase *);
static
void startRegressTestIoc(const char *dbfile)
{
testDiag("Testing with %s", dbfile);
testdbPrepare();
testdbReadDatabase("regressTest.dbd", NULL, NULL);
regressTest_registerRecordDeviceDriver(pdbbase);
@@ -134,15 +138,84 @@ void testCADisconn(void)
testdbPutFieldFail(-1, "ai:disconn.PROC", DBF_LONG, 1);
testdbGetFieldEqual("ai:disconn.SEVR", DBF_LONG, INVALID_ALARM);
testdbGetFieldEqual("ai:disconn.STAT", DBF_LONG, LINK_ALARM);
testIocShutdownOk();
testdbCleanup();
}
/* https://github.com/epics-base/epics-base/issues/194 */
static
void testLongCalc(void)
{
const char small[] = "0.0000000000000000000000000000000000000001";
startRegressTestIoc("regressLongCalc.db");
testdbGetFieldEqual("test_calc.CALC", DBF_STRING, "RNDM*100");
testdbPutArrFieldOk("test_calc.CALC$", DBF_CHAR, 4, "300\0");
testdbGetFieldEqual("test_calc.CALC", DBF_STRING, "300");
testdbPutFieldOk("test_calc.PROC", DBF_LONG, 1);
testdbGetFieldEqual("test_calc", DBF_DOUBLE, 300.0);
testdbPutArrFieldOk("test_calc.CALC$", DBF_CHAR, sizeof(small), small);
testdbGetFieldEqual("test_calc.CALC", DBF_STRING, "0.0000000000000000000000000000000000000");
testdbPutFieldOk("test_calc.PROC", DBF_LONG, 1);
testdbGetFieldEqual("test_calc", DBF_DOUBLE, 1e-40);
testIocShutdownOk();
testdbCleanup();
}
/* https://github.com/epics-base/epics-base/issues/183 */
static
void testLinkSevr(void)
{
dbChannel *chan;
startRegressTestIoc("regressLinkSevr.db");
/* wait for CA links to connect and receive an initial update */
testdbCaWaitForUpdateCount(dbGetDevLink(testdbRecordPtr("si2")), 1);
testdbCaWaitForUpdateCount(dbGetDevLink(testdbRecordPtr("li2")), 1);
chan = dbChannelCreate("ai.SEVR");
if(!chan)
testAbort("Can't create channel for ai.SEVR");
testOk1(!dbChannelOpen(chan));
#define testType(FN, TYPE) testOk(FN(chan)==TYPE, #FN "() -> (%d) == " #TYPE " (%d)", FN(chan), TYPE)
testType(dbChannelExportType, DBF_ENUM);
testType(dbChannelFieldType, DBF_MENU);
testType(dbChannelFinalFieldType, DBF_ENUM);
#undef testType
dbChannelDelete(chan);
testdbGetFieldEqual("ai.SEVR", DBF_LONG, INVALID_ALARM);
testdbGetFieldEqual("ai.SEVR", DBF_STRING, "INVALID");
testdbPutFieldOk("si1.PROC", DBF_LONG, 1);
testdbGetFieldEqual("si1", DBF_STRING, "INVALID");
testdbGetFieldEqual("li1", DBF_LONG, INVALID_ALARM);
testTodoBegin("Not working");
testdbGetFieldEqual("si2", DBF_STRING, "INVALID");
testTodoEnd();
testdbGetFieldEqual("li2", DBF_LONG, INVALID_ALARM);
testIocShutdownOk();
testdbCleanup();
}
MAIN(regressTest)
{
testPlan(34);
testPlan(54);
testArrayLength1();
testHexConstantLinks();
testLinkMS();
testCADisconn();
testLongCalc();
testLinkSevr();
return testDone();
}
+16 -8
View File
@@ -8,8 +8,11 @@
#include <string.h>
#define EPICS_DBCA_PRIVATE_API
#include "dbAccess.h"
#include "dbStaticLib.h"
#include "dbCa.h"
#include "dbTest.h"
#include "dbUnitTest.h"
#include "epicsThread.h"
@@ -60,14 +63,17 @@ void testGroup0(void)
testDiag("============ Starting %s ============", EPICS_FUNCTION);
testdbPutFieldOk("source", DBR_LONG, 1);
/* The above put sends CA monitors to all of the CA links, but
* doesn't trigger record processing (the links are not CP/CPP).
* How could we wait until all of those monitors have arrived,
* instead of just waiting for an arbitrary time period?
*/
epicsThreadSleep(1.0); /* FIXME: Wait here? */
for (rec = records; *rec; rec++) {
DBLINK* plink = dbGetDevLink(testdbRecordPtr(*rec));
if(plink->type==CA_LINK)
testdbCaWaitForUpdateCount(plink, 1);
}
testdbPutFieldOk("source", DBR_LONG, 1);
for (rec = records; *rec; rec++) {
DBLINK* plink = dbGetDevLink(testdbRecordPtr(*rec));
if(plink->type==CA_LINK)
testdbCaWaitForUpdateCount(plink, 2);
if (strncmp(*rec, "lsi0", 4) != 0)
testdbGetFieldEqual(*rec, DBR_LONG, 0);
checkDtyp(*rec);
@@ -76,8 +82,10 @@ void testGroup0(void)
}
testdbPutFieldOk("source", DBR_LONG, 0);
epicsThreadSleep(1.0); /* FIXME: Wait here as above */
for (rec = records; *rec; rec++) {
DBLINK* plink = dbGetDevLink(testdbRecordPtr(*rec));
if(plink->type==CA_LINK)
testdbCaWaitForUpdateCount(plink, 3);
doProcess(*rec);
testdbGetFieldEqual(*rec, DBR_LONG, 0);
}