diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index 2faf69083..301e85543 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -1,5 +1,4 @@ @@ -14,6 +13,14 @@ +

New test for environment variables

+ +

A new test program epicsEnvTest has been added to the libCom tests which +checks environment variable APIs. It was written to confirm that threads see +environment variable values that have been set in their parent thread. VxWorks +6.x boot images must be configured with ENV_VAR_USE_HOOKS set to FALSE for the +correct behaviour to occur (a test failure on VxWorks explains this).

+

Inclusion of <top>/cfg/* files refined

The way the build system includes files installed in the <top>/cfg/* diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index 0d6ab1487..e8e94a3e6 100644 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -37,6 +37,11 @@ epicsEllTest_SRCS += epicsEllTest.c testHarness_SRCS += epicsEllTest.c TESTS += epicsEllTest +TESTPROD_HOST += epicsEnvTest +epicsEnvTest_SRCS += epicsEnvTest.c +testHarness_SRCS += epicsEnvTest.c +TESTS += epicsEnvTest + TESTPROD_HOST += epicsErrlogTest epicsErrlogTest_SRCS += epicsErrlogTest.c testHarness_SRCS += epicsErrlogTest.c diff --git a/src/libCom/test/epicsEnvTest.c b/src/libCom/test/epicsEnvTest.c new file mode 100644 index 000000000..bbce4b749 --- /dev/null +++ b/src/libCom/test/epicsEnvTest.c @@ -0,0 +1,78 @@ +/*************************************************************************\ +* Copyright (c) 2013 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* epicsEnvTest.c */ + +/* Author: Andrew Johnson + * Date: 2013-12-13 + */ + +/* Check environment variable APIs. + * TODO: Add tests for envDefs.h routines. + * + * The thread test is needed on VxWorks 6.x, where the OS can be + * configured to maintain separate, totally independent sets + * of environment variables for each thread. This configuration + * is not supported by EPICS which expects child threads to at + * least inherit the partent thread's environment variables. + */ + +#include +#include + +#include "envDefs.h" +#include "epicsThread.h" +#include "epicsUnitTest.h" +#include "testMain.h" + +#define PARENT "Parent" +#define CHILD "Child" + +static void child(void *arg) +{ + const char *value = getenv(PARENT); + + if (!testOk(value && (strcmp(value, PARENT) == 0), + "Child thread sees parent environment values")) { +#ifdef vxWorks + testDiag("VxWorks image needs ENV_VAR_USE_HOOKS configured as FALSE"); +#else + testDiag("Check OS configuration, environment inheritance needed"); +#endif + } + + epicsEnvSet(CHILD, CHILD); +} + +MAIN(epicsEnvTest) +{ + unsigned int stackSize = epicsThreadGetStackSize(epicsThreadStackSmall); + const char *value; + + testPlan(3); + + epicsEnvSet(PARENT, PARENT); + + value = getenv(PARENT); + if (!testOk(value && (strcmp(value, PARENT) == 0), + "epicsEnvSet correctly modifies environment")) + testAbort("environment variables not working"); + + epicsThreadCreate("child", 50, stackSize, child, NULL); + epicsThreadSleep(0.1); + + value = getenv(CHILD); + if (value && (strcmp(value, CHILD) == 0)) + testDiag("Child and parent threads share a common environment"); + + value = getenv(PARENT); + testOk(value && (strcmp(value, PARENT) == 0), + "PARENT environment variable not modified"); + + testDone(); + return 0; +} + diff --git a/src/libCom/test/epicsRunLibComTests.c b/src/libCom/test/epicsRunLibComTests.c index 7a6da1e66..e49c10166 100644 --- a/src/libCom/test/epicsRunLibComTests.c +++ b/src/libCom/test/epicsRunLibComTests.c @@ -20,6 +20,7 @@ int epicsThreadTest(void); int epicsTimerTest(void); int epicsAlgorithm(void); int epicsEllTest(void); +int epicsEnvTest(void); int epicsErrlogTest(void); int epicsCalcTest(void); int epicsEventTest(void); @@ -60,6 +61,8 @@ void epicsRunLibComTests(void) runTest(epicsEllTest); + runTest(epicsEnvTest); + runTest(epicsErrlogTest); runTest(epicsCalcTest);