From 7fd690e53e597ddca650e1fad04721b61eba973b Mon Sep 17 00:00:00 2001 From: Zainab Olalekan Date: Tue, 1 Aug 2023 10:09:17 -0500 Subject: [PATCH] Fix libcom test failure on RTEMS --- modules/libcom/test/epicsStringTest.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/libcom/test/epicsStringTest.c b/modules/libcom/test/epicsStringTest.c index b5f744b37..18264cbae 100644 --- a/modules/libcom/test/epicsStringTest.c +++ b/modules/libcom/test/epicsStringTest.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "epicsUnitTest.h" #include "epicsString.h" @@ -198,10 +199,22 @@ void testStrTok(void) static void testEpicsStrPrintEscaped(void) { - const char *filename = "testEpicsStrPrintEscaped"; + const char *filename; + FILE *testFile; + FILE *readOnly; + + #ifdef __rtems__ + /* ensure there is a writable area */ + mkdir( "/tmp", S_IRWXU ); + filename = "/tmp/testEpicsStrPrintEscaped"; + #else + filename = "testEpicsStrPrintEscaped"; + #endif + + // Avoid printing to stdout by redirecting everything to a file - FILE *testFile = fopen(filename, "a"); - FILE *readOnly = fopen(filename, "r"); + testFile = fopen(filename, "a"); + readOnly = fopen(filename, "r"); testDiag("testEpicsStrPrintEscaped()");