From ee9a901efdc8fc3855e6cbf6ae0d67c9900d8872 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Sat, 17 Feb 2007 00:13:11 +0000 Subject: More robust pjlib file test: it shouldn't leave the file on the disk if the test fails git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@957 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib/src/pjlib-test/file.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pjlib/src/pjlib-test/file.c b/pjlib/src/pjlib-test/file.c index d22c3956..d884688a 100644 --- a/pjlib/src/pjlib-test/file.c +++ b/pjlib/src/pjlib-test/file.c @@ -28,7 +28,7 @@ static char buffer[11] = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd' }; -int file_test(void) +static int file_test_internal(void) { enum { FILE_MAX_AGE = 1000 }; pj_oshandle_t fd = 0; @@ -89,9 +89,9 @@ int file_test(void) if (stat.size != sizeof(buffer)) return -70; +#if INCLUDE_FILE_TIME_TEST /* Check file creation time >= start_time. */ if (!PJ_TIME_VAL_GTE(stat.ctime, start_time)) -#if INCLUDE_FILE_TIME_TEST return -80; /* Check file creation time is not much later. */ PJ_TIME_VAL_SUB(stat.ctime, start_time); @@ -206,6 +206,18 @@ int file_test(void) return PJ_SUCCESS; } + +int file_test(void) +{ + int rc = file_test_internal(); + + /* Delete test file if exists. */ + if (pj_file_exists(FILENAME)) + pj_file_delete(FILENAME); + + return rc; +} + #else int dummy_file_test; #endif -- cgit v1.2.3