summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-02-17 00:13:11 +0000
committerBenny Prijono <bennylp@teluu.com>2007-02-17 00:13:11 +0000
commitee9a901efdc8fc3855e6cbf6ae0d67c9900d8872 (patch)
tree9d4768031c04b1a23a38062b1d84ef63012b162d
parentbb1175aaacddc3bf465fc8538093ab7e44f87349 (diff)
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
-rw-r--r--pjlib/src/pjlib-test/file.c16
1 files 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