From d1bc58f6a0c9650367eb1e5845232557fda67be4 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Wed, 14 Apr 2004 23:41:00 +0000 Subject: [PATCH] ICU-3499 Verify that the test file can be removed during testing. X-SVN-Rev: 14970 --- icu4c/source/extra/ustdio/ufile.c | 5 +++++ icu4c/source/test/iotest/filetst.c | 2 +- icu4c/source/test/iotest/iotest.cpp | 14 ++++++++++++++ icu4c/source/test/iotest/iotest.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/icu4c/source/extra/ustdio/ufile.c b/icu4c/source/extra/ustdio/ufile.c index 9542da62316..eaedab209cf 100644 --- a/icu4c/source/extra/ustdio/ufile.c +++ b/icu4c/source/extra/ustdio/ufile.c @@ -104,6 +104,11 @@ u_fopen(const char *filename, if (result) { result->fOwnFile = TRUE; } + else { + /* Something bad happened. + Maybe the converter couldn't be opened. */ + fclose(systemFile); + } return result; } diff --git a/icu4c/source/test/iotest/filetst.c b/icu4c/source/test/iotest/filetst.c index 0b2ed77ffbc..1bbaceb6216 100644 --- a/icu4c/source/test/iotest/filetst.c +++ b/icu4c/source/test/iotest/filetst.c @@ -20,7 +20,7 @@ #include -static char STANDARD_TEST_FILE[] = "iotest-c.txt"; +const char STANDARD_TEST_FILE[] = "iotest-c.txt"; static void TestFileFromICU(UFILE *myFile) { diff --git a/icu4c/source/test/iotest/iotest.cpp b/icu4c/source/test/iotest/iotest.cpp index fa1540e98b8..73b9cb60bf1 100644 --- a/icu4c/source/test/iotest/iotest.cpp +++ b/icu4c/source/test/iotest/iotest.cpp @@ -372,6 +372,20 @@ int main(int argc, char* argv[]) addAllTests(&root); nerrors = processArgs(root, argc, argv); +#if 1 + { + FILE* fileToRemove = fopen(STANDARD_TEST_FILE, "r"); + /* This should delete any temporary files. */ + if (fileToRemove) { + fclose(fileToRemove); + if (remove(STANDARD_TEST_FILE) != 0) { + /* Maybe someone didn't close the file correctly. */ + fprintf(stderr, "FAIL: Could not delete %s\n", STANDARD_TEST_FILE); + } + } + } +#endif + cleanUpTestTree(root); u_cleanup(); return nerrors; diff --git a/icu4c/source/test/iotest/iotest.h b/icu4c/source/test/iotest/iotest.h index 9d3cc7d39c3..8ae94bf3f37 100644 --- a/icu4c/source/test/iotest/iotest.h +++ b/icu4c/source/test/iotest/iotest.h @@ -26,6 +26,7 @@ addFileTest(TestNode** root); U_CDECL_BEGIN extern const UChar NEW_LINE[]; +extern const char STANDARD_TEST_FILE[]; U_CDECL_END #define STANDARD_TEST_NUM_RANGE 1000