Fix export type of .LINK$ fields, add tests
This commit is contained in:
@@ -38,9 +38,6 @@
|
||||
#include "recSup.h"
|
||||
#include "special.h"
|
||||
|
||||
/* The following is defined in db_convert.h */
|
||||
extern unsigned short dbDBRnewToDBRold[DBR_ENUM+1];
|
||||
|
||||
typedef struct parseContext {
|
||||
dbChannel *chan;
|
||||
chFilter *filter;
|
||||
@@ -618,7 +615,7 @@ long dbChannelOpen(dbChannel *chan)
|
||||
/* Set up type probe */
|
||||
probe.type = dbfl_type_val;
|
||||
probe.ctx = dbfl_context_read;
|
||||
probe.field_type = dbChannelFieldType(chan);
|
||||
probe.field_type = dbChannelExportType(chan);
|
||||
probe.no_elements = dbChannelElements(chan);
|
||||
probe.field_size = dbChannelFieldSize(chan);
|
||||
p = probe;
|
||||
@@ -660,7 +657,6 @@ long dbChannelOpen(dbChannel *chan)
|
||||
chan->final_no_elements = probe.no_elements;
|
||||
chan->final_field_size = probe.field_size;
|
||||
chan->final_type = probe.field_type;
|
||||
chan->final_dbr_type = dbDBRnewToDBRold[mapDBFToDBR[probe.field_type]];
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -709,9 +705,9 @@ void dbChannelShow(dbChannel *chan, int level, const unsigned short indent)
|
||||
int post = ellCount(&chan->post_chain);
|
||||
|
||||
printf("%*schannel name: %s\n", indent, "", chan->name);
|
||||
/* FIXME: show field_type as text */
|
||||
printf("%*s field_type=%d (%dB), %ld element%s, %d filter%s", indent, "",
|
||||
chan->addr.field_type, chan->addr.field_size, elems, elems == 1 ? "" : "s",
|
||||
printf("%*s field_type=%s (%d bytes), dbr_type=%s, %ld element%s, %d filter%s", indent, "",
|
||||
dbGetFieldTypeString(chan->addr.field_type), chan->addr.field_size,
|
||||
dbGetFieldTypeString(chan->addr.dbr_field_type), elems, elems == 1 ? "" : "s",
|
||||
count, count == 1 ? "" : "s");
|
||||
if (count)
|
||||
printf(" (%d pre eventq, %d post eventq)\n", pre, post);
|
||||
@@ -720,9 +716,9 @@ void dbChannelShow(dbChannel *chan, int level, const unsigned short indent)
|
||||
if (level > 0)
|
||||
dbChannelFilterShow(chan, level - 1, indent + 2);
|
||||
if (count) {
|
||||
/* FIXME: show field_type as text */
|
||||
printf("%*s final field_type=%d (%dB), %ld element%s\n", indent, "",
|
||||
chan->final_type, chan->final_field_size, felems, felems == 1 ? "" : "s");
|
||||
printf("%*s final field_type=%s (%dB), %ld element%s\n", indent, "",
|
||||
dbGetFieldTypeString(chan->final_type), chan->final_field_size,
|
||||
felems, felems == 1 ? "" : "s");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ typedef struct dbChannel {
|
||||
long final_no_elements; /* final number of elements (arrays) */
|
||||
short final_field_size; /* final size of element */
|
||||
short final_type; /* final type of database field */
|
||||
short final_dbr_type; /* final field type as seen by database request */
|
||||
ELLLIST filters; /* list of filters as created from JSON */
|
||||
ELLLIST pre_chain; /* list of filters to be called pre-event-queue */
|
||||
ELLLIST post_chain; /* list of filters to be called post-event-queue */
|
||||
@@ -186,7 +185,7 @@ epicsShareFunc long dbChannelOpen(dbChannel *chan);
|
||||
#define dbChannelFinalFieldType(pChan) ((pChan)->final_type)
|
||||
|
||||
/* evaluates to short */
|
||||
#define dbChannelFinalExportType(pChan) ((pChan)->final_dbr_type)
|
||||
#define dbChannelFinalExportType(pChan) ((pChan)->final_type)
|
||||
|
||||
/* evaluates to short */
|
||||
#define dbChannelFinalFieldSize(pChan) ((pChan)->final_field_size)
|
||||
|
||||
@@ -119,13 +119,14 @@ struct dbChannel * dbChannel_create(const char *pname)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
chan->addr.dbr_field_type = dbDBRnewToDBRold[ftype];
|
||||
|
||||
if (dbChannelOpen(chan)) {
|
||||
dbChannelDelete(chan);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Convert final_type to CA's type mapping */
|
||||
chan->final_type = dbDBRnewToDBRold[chan->final_type];
|
||||
|
||||
return chan;
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ MAIN(testDbChannel) /* dbChannelTest is an API routine... */
|
||||
{
|
||||
dbChannel *pch;
|
||||
|
||||
testPlan(66);
|
||||
testPlan(76);
|
||||
|
||||
if (dbReadDatabase(&pdbbase, "dbTestIoc.dbd",
|
||||
"." OSI_PATH_LIST_SEPARATOR ".." OSI_PATH_LIST_SEPARATOR
|
||||
@@ -173,6 +173,7 @@ MAIN(testDbChannel) /* dbChannelTest is an API routine... */
|
||||
r = e = 0;
|
||||
/* dbChannelTest() checks record and field names */
|
||||
testOk1(!dbChannelTest("x.NAME"));
|
||||
testOk1(!dbChannelTest("x.INP"));
|
||||
testOk1(!dbChannelTest("x.VAL"));
|
||||
testOk1(!dbChannelTest("x."));
|
||||
testOk1(!dbChannelTest("x"));
|
||||
@@ -188,12 +189,22 @@ MAIN(testDbChannel) /* dbChannelTest is an API routine... */
|
||||
testOk1(!!(pch = dbChannelCreate("x.{}")));
|
||||
if (pch) dbChannelDelete(pch);
|
||||
testOk1(!!(pch = dbChannelCreate("x.VAL{}")));
|
||||
testOk1(pch && dbChannelElements(pch) == 1);
|
||||
if (pch) dbChannelDelete(pch);
|
||||
testOk1(!!(pch = dbChannelCreate("x.NAME$")));
|
||||
testOk1(pch && pch->addr.no_elements > 1);
|
||||
testOk1(pch && dbChannelFieldType(pch) == DBF_CHAR);
|
||||
testOk1(pch && dbChannelExportType(pch) == DBR_CHAR);
|
||||
testOk1(pch && dbChannelElements(pch) == PVNAME_STRINGSZ);
|
||||
if (pch) dbChannelDelete(pch);
|
||||
testOk1(!!(pch = dbChannelCreate("x.INP$")));
|
||||
testOk1(pch && dbChannelFieldType(pch) == DBF_INLINK);
|
||||
testOk1(pch && dbChannelExportType(pch) == DBR_CHAR);
|
||||
testOk1(pch && dbChannelElements(pch) > PVNAME_STRINGSZ);
|
||||
if (pch) dbChannelDelete(pch);
|
||||
testOk1(!!(pch = dbChannelCreate("x.NAME${}")));
|
||||
testOk1(pch && pch->addr.no_elements > 1);
|
||||
testOk1(pch && dbChannelFieldType(pch) == DBF_CHAR);
|
||||
testOk1(pch && dbChannelExportType(pch) == DBR_CHAR);
|
||||
testOk1(pch && dbChannelElements(pch) == PVNAME_STRINGSZ);
|
||||
if (pch) dbChannelDelete(pch);
|
||||
|
||||
/* dbChannelCreate() rejects bad PVs */
|
||||
|
||||
Reference in New Issue
Block a user