From c3995a9d63fefcc0be6abf0ecd8e8c42995aed05 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Fri, 5 Oct 2018 17:00:35 +0200 Subject: [PATCH] added simple test case for epicsEnvUnset --- src/libCom/test/Makefile | 5 ++++ src/libCom/test/epicsEnvUnsetTest.c | 38 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/libCom/test/epicsEnvUnsetTest.c diff --git a/src/libCom/test/Makefile b/src/libCom/test/Makefile index 89eb87f6f..c80339317 100755 --- a/src/libCom/test/Makefile +++ b/src/libCom/test/Makefile @@ -62,6 +62,11 @@ epicsEnvTest_SRCS += epicsEnvTest.c testHarness_SRCS += epicsEnvTest.c TESTS += epicsEnvTest +TESTPROD_HOST += epicsEnvUnsetTest +epicsEnvUnsetTest_SRCS += epicsEnvUnsetTest.c +testHarness_SRCS += epicsEnvUnsetTest.c +TESTS += epicsEnvUnsetTest + TESTPROD_HOST += epicsErrlogTest epicsErrlogTest_SRCS += epicsErrlogTest.c testHarness_SRCS += epicsErrlogTest.c diff --git a/src/libCom/test/epicsEnvUnsetTest.c b/src/libCom/test/epicsEnvUnsetTest.c new file mode 100644 index 000000000..3697a4b80 --- /dev/null +++ b/src/libCom/test/epicsEnvUnsetTest.c @@ -0,0 +1,38 @@ +#include +#include +#include +#include + +#include "macLib.h" +#include "envDefs.h" +#include "errlog.h" +#include "epicsUnitTest.h" +#include "testMain.h" + +static void check(const char* variable, const char* expected) +{ + const char* value; + + value = getenv(variable); + if (!testOk((!expected && !value) || (expected && value && strcmp(expected, value) == 0), + "%s = \"%s\"", variable, value)) + { + testDiag("should have been \"%s\"", expected); + } +} + + +MAIN(epicsEnvUnsetTest) +{ + eltc(0); + testPlan(3); + + check("TEST_VAR_A",NULL); + epicsEnvSet("TEST_VAR_A","test value"); + check("TEST_VAR_A","test value"); + epicsEnvUnset("TEST_VAR_A"); + check("TEST_VAR_A",NULL); + + testDone(); + return 0; +}