Merge changes from 3.15 into 3.16

This commit is contained in:
Andrew Johnson
2018-05-12 22:39:37 -05:00
12 changed files with 403 additions and 181 deletions
+2 -2
View File
@@ -146,9 +146,9 @@ Note: Negative index numbers address from the end of the array, with C<-1> being
=item Square bracket notation C<[start:increment:end]> (shorthand)
The common square bracket notation with can be used in place of JSON.
The common square bracket notation which can be used in place of JSON.
Any parameter may be omitted (keeping the colons) to use the default value.
If only one colon is included, this means C<[start:end]> with a increment of 1.
If only one colon is included, this means C<[start:end]> with an increment of 1.
If only a single parameter is used C<[index]> the filter returns one element.
=item Start index C<"s">
+11
View File
@@ -96,6 +96,17 @@ testHarness_SRCS += analogMonitorTest_registerRecordDeviceDriver.cpp
TESTFILES += $(COMMON_DIR)/analogMonitorTest.dbd ../analogMonitorTest.db
TESTS += analogMonitorTest
TARGETS += $(COMMON_DIR)/scanEventTest.dbd
DBDDEPENDS_FILES += scanEventTest.dbd$(DEP)
scanEventTest_DBD += base.dbd
TESTPROD_HOST += scanEventTest
scanEventTest_SRCS += scanEventTest.c
scanEventTest_SRCS += scanEventTest_registerRecordDeviceDriver.cpp
testHarness_SRCS += scanEventTest.c
testHarness_SRCS += scanEventTest_registerRecordDeviceDriver.cpp
TESTFILES += $(COMMON_DIR)/scanEventTest.dbd ../scanEventTest.db
TESTS += scanEventTest
TARGETS += $(COMMON_DIR)/regressTest.dbd
DBDDEPENDS_FILES += regressTest.dbd$(DEP)
regressTest_DBD += base.dbd
+3
View File
@@ -20,6 +20,7 @@ int asTest(void);
int linkRetargetLinkTest(void);
int linkInitTest(void);
int asyncSoftTest(void);
int scanEventTest(void);
void epicsRunRecordTests(void)
{
@@ -41,5 +42,7 @@ void epicsRunRecordTests(void)
runTest(asyncSoftTest);
runTest(scanEventTest);
epicsExit(0); /* Trigger test harness */
}
+142
View File
@@ -0,0 +1,142 @@
/*************************************************************************\
* Copyright (c) 2018 Paul Scherrer Institut
* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/*
* Author: Dirk Zimoch <dirk.zimoch@psi.ch>
*/
#include <string.h>
#include "dbStaticLib.h"
#include "dbAccessDefs.h"
#include "dbUnitTest.h"
#include "testMain.h"
#include "osiFileName.h"
#include "epicsThread.h"
#include "dbScan.h"
void scanEventTest_registerRecordDeviceDriver(struct dbBase *);
/* test name to event number:
num = 0 is no event,
num > 0 is numeric event
num < 0 is string event (use same unique number for aliases)
*/
const struct {char* name; int num;} events[] = {
/* No events */
{NULL, 0},
{"", 0},
{" ", 0},
{"0", 0},
{"0.000000", 0},
{"-0.00000", 0},
{"0.9", 0},
/* Numeric events */
{"2", 2},
{"2.000000", 2},
{"2.5", 2},
{" 2.5 ", 2},
{"+0x02", 2},
{"3", 3},
/* Named events */
{"info 1", -1},
{" info 1 ", -1},
{"-0.9", -2},
{"-2", -3},
{"-2.000000", -4},
{"-2.5", -5},
{" -2.5 ", -5},
{"nan", -6},
{"NaN", -7},
{"-NAN", -8},
{"-inf", -9},
{"inf", -10},
};
MAIN(scanEventTest)
{
int i, e;
int aliases[512] ;
int expected_count[512];
#define INDX(i) 256-events[i].num
#define MAXEV 5
testPlan(NELEMENTS(events)*2+(MAXEV+1)*5);
memset(aliases, 0, sizeof(aliases));
memset(expected_count, 0, sizeof(expected_count));
if (dbReadDatabase(&pdbbase, "scanEventTest.dbd",
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
"../O.Common" OSI_PATH_LIST_SEPARATOR "O.Common", NULL))
testAbort("Database description 'scanEventTest.dbd' not found");
scanEventTest_registerRecordDeviceDriver(pdbbase);
for (i = 0; i < NELEMENTS(events); i++) {
char substitutions[256];
sprintf(substitutions, "N=%d,EVENT=%s", i, events[i].name);
if (dbReadDatabase(&pdbbase, "scanEventTest.db",
"." OSI_PATH_LIST_SEPARATOR "..", substitutions))
testAbort("Error reading test database 'scanEventTest.db'");
}
testIocInitOk();
testDiag("Test if eventNameToHandle() strips spaces and handles numeric events");
for (i = 0; i < NELEMENTS(events); i++) {
EVENTPVT pev = eventNameToHandle(events[i].name);
/* test that some names are not events (num=0) */
if (events[i].num == 0)
testOk(pev == NULL, "\"%s\" -> no event", events[i].name);
else
{
expected_count[INDX(i)]++; /* +1 for postEvent */
if (events[i].num > 0)
{
testOk(pev != NULL, "\"%s\" -> numeric event %d", events[i].name, events[i].num);
expected_count[INDX(i)]++; /* +1 for post_event */
}
else
{
/* test that some strings resolve the same event (num!=0) */
if (!aliases[INDX(i)])
{
aliases[INDX(i)] = i;
testOk(pev != NULL, "\"%s\" -> new named event", events[i].name);
}
else
{
testOk(pev == eventNameToHandle(events[aliases[INDX(i)]].name),
"\"%s\" alias for \"%s\"", events[i].name, events[aliases[INDX(i)]].name);
}
}
}
post_event(events[i].num); /* triggers numeric events only */
postEvent(pev);
}
testDiag("Check calculated numeric events (backward compatibility)");
for (e = 0; e <= MAXEV; e++) {
testdbPutFieldOk("eventnum", DBR_LONG, e);
testdbGetFieldEqual("e1", DBR_LONG, e);
testdbGetFieldEqual("e2", DBR_LONG, e);
testdbPutFieldOk("e3", DBR_LONG, e);
testdbPutFieldOk("e3.PROC", DBR_LONG, 1);
for (i = 0; i < NELEMENTS(events); i++)
if (e > 0 && e < 256 && events[i].num == e) { /* numeric events */
expected_count[INDX(i)]+=3; /* +1 for eventnum->e1, +1 for e2<-eventnum, +1 for e3 */
break;
}
}
/* Allow records to finish processing */
epicsThreadSleep(0.1);
testDiag("Check if events have been processed the expected number of times");
for (i = 0; i < NELEMENTS(events); i++) {
char pvname[100];
sprintf(pvname, "c%d", i);
testDiag("Event \"%s\" expected %d times", events[i].name, expected_count[INDX(i)]);
testdbGetFieldEqual(pvname, DBR_LONG, expected_count[INDX(i)]);
}
return testDone();
}
+16
View File
@@ -0,0 +1,16 @@
record(calc, "c$(N)") {
field(SCAN, "Event")
field(EVNT, "$(EVENT)")
field(CALC, "VAL+1")
}
record(dfanout, "eventnum") {
field(OUTA, "e1 PP")
field(FLNK, "e2")
}
record(event, "e1") {
}
record(event, "e2") {
field(INP, "eventnum")
}
record(event, "e3") {
}