75 lines
2.7 KiB
C
75 lines
2.7 KiB
C
/*************************************************************************\
|
|
* Copyright (c) 2025 Dirk Zimoch
|
|
* SPDX-License-Identifier: EPICS
|
|
* EPICS BASE is distributed subject to a Software License Agreement found
|
|
* in file LICENSE that is included with this distribution.
|
|
\*************************************************************************/
|
|
|
|
/* Compile and link test for epicsExport.h
|
|
*
|
|
*/
|
|
|
|
#include <epicsUnitTest.h>
|
|
#include <dbUnitTest.h>
|
|
#include <testMain.h>
|
|
#include <dbAccess.h>
|
|
#include <iocsh.h>
|
|
#include <epicsExport.h>
|
|
|
|
void epicsExportTestIoc_registerRecordDeviceDriver(struct dbBase *);
|
|
|
|
MAIN(epicsExportTest)
|
|
{
|
|
const iocshVarDef *var_i1, *var_i2;
|
|
|
|
testPlan(26);
|
|
testdbPrepare();
|
|
testdbReadDatabase("epicsExportTestIoc.dbd", 0, 0);
|
|
epicsExportTestIoc_registerRecordDeviceDriver(pdbbase);
|
|
|
|
testDiag("Testing if dsets and functions are found");
|
|
testdbReadDatabase("epicsExportTest.db", 0, 0);
|
|
testIocInitOk();
|
|
|
|
testDiag("Testing if dsets work correctly");
|
|
testdbGetFieldEqual("li1", DBF_LONG, -1);
|
|
testdbGetFieldEqual("li2", DBF_LONG, -2);
|
|
testdbPutFieldOk("li1.PROC", DBF_LONG, 1);
|
|
testdbPutFieldOk("li2.PROC", DBF_LONG, 1);
|
|
testdbGetFieldEqual("li1", DBF_LONG, 5);
|
|
testdbGetFieldEqual("li2", DBF_LONG, 5);
|
|
|
|
testDiag("Testing if functions work correctly");
|
|
testdbGetFieldEqual("asub1.A", DBF_LONG, 1);
|
|
testdbGetFieldEqual("asub1.B", DBF_LONG, -2);
|
|
testdbGetFieldEqual("asub2.A", DBF_LONG, 3);
|
|
testdbGetFieldEqual("asub2.B", DBF_LONG, -4);
|
|
testdbPutFieldOk("asub1.PROC", DBF_LONG, 1);
|
|
testdbPutFieldOk("asub2.PROC", DBF_LONG, 1);
|
|
testdbGetFieldEqual("asub1.A", DBF_LONG, 1);
|
|
testdbGetFieldEqual("asub1.B", DBF_LONG, 2);
|
|
testdbGetFieldEqual("asub2.A", DBF_LONG, 3);
|
|
testdbGetFieldEqual("asub2.B", DBF_LONG, 4);
|
|
|
|
testDiag("Testing if variable access works");
|
|
var_i1 = iocshFindVariable("i1");
|
|
var_i2 = iocshFindVariable("i2");
|
|
if (var_i1 && var_i2 && var_i1->type == iocshArgInt && var_i2->type == iocshArgInt) {
|
|
int *pi1 = (int*)(var_i1->pval);
|
|
int *pi2 = (int*)(var_i2->pval);
|
|
|
|
testOk(*pi1==2, "Variable i1 counted registrars: %d == 2", *pi1);
|
|
testOk(*pi2==2, "Variable i2 counted registrars: %d == 2", *pi2);
|
|
testDiag("Testing if variables are accessible from iocsh");
|
|
testOk(iocshCmd("var i1,4") == 0, "Setting i1 = 4 in iocsh");
|
|
testOk(iocshCmd("var i2,5") == 0, "Setting i2 = 5 in iocsh");
|
|
testOk(*pi1==4, "Variable i1: %d == 4", *pi1);
|
|
testOk(*pi2==5, "Variable i2: %d == 5", *pi2);
|
|
} else {
|
|
testFail("Cannot access variables i1, i2");
|
|
}
|
|
testIocShutdownOk();
|
|
testdbCleanup();
|
|
return testDone();
|
|
}
|