Validate target record name when creating an alias

This fixes issue #312 by printing an error when a field is specified
This commit is contained in:
Emilio Perez
2023-07-22 08:29:09 -07:00
committed by Michael Davidsaver
parent f488765631
commit 500a57738b
5 changed files with 29 additions and 3 deletions
+18 -2
View File
@@ -291,6 +291,18 @@ static void testDbVerify(const char *record)
dbFinishEntry(&entry);
}
static void testWrongAliasRecord(const char *filename)
{
FILE *fp = NULL;
dbPath(pdbbase,"." OSI_PATH_LIST_SEPARATOR "..");
dbOpenFile(pdbbase, filename, &fp);
if(!fp) {
testAbort("Unable to read %s", filename);
}
testOk(dbReadDatabaseFP(&pdbbase, fp, NULL, NULL) != 0,
"Wrong alias record in %s is expected to fail", filename);
}
void dbTestIoc_registerRecordDeviceDriver(struct dbBase *);
MAIN(dbStaticTest)
@@ -298,13 +310,14 @@ MAIN(dbStaticTest)
const char *ldir;
FILE *fp = NULL;
testPlan(310);
testPlan(312);
testdbPrepare();
testdbReadDatabase("dbTestIoc.dbd", NULL, NULL);
dbTestIoc_registerRecordDeviceDriver(pdbbase);
dbPath(pdbbase,"." OSI_PATH_LIST_SEPARATOR "..");
if(!(ldir = dbOpenFile(pdbbase, "dbStaticTest.db", &fp))) {
ldir = dbOpenFile(pdbbase, "dbStaticTest.db", &fp);
if(!fp) {
testAbort("Unable to read dbStaticTest.db");
}
if(dbReadDatabaseFP(&pdbbase, fp, NULL, NULL)) {
@@ -312,6 +325,9 @@ MAIN(dbStaticTest)
ldir, OSI_PATH_LIST_SEPARATOR);
}
testWrongAliasRecord("dbStaticTestAlias1.db");
testWrongAliasRecord("dbStaticTestAlias2.db");
testEntry("testrec.VAL");
testEntry("testalias.VAL");
testEntry("testalias2.VAL");