From 01d7392a6acd6d077df52e2eaebd80576690cb36 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 9 Mar 2017 22:11:55 +0000 Subject: replace tmpnam with something more suitable for the test files --- test/nsoption.c | 17 ++++++++++++++--- test/urldbtest.c | 20 ++++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/nsoption.c b/test/nsoption.c index 3b75ca750..5874c94b6 100644 --- a/test/nsoption.c +++ b/test/nsoption.c @@ -39,6 +39,17 @@ const char *test_choices_all_path = "test/data/Choices-all"; const char *test_choices_full_path = "test/data/Choices-full"; const char *test_choices_missing_path = "test/data/Choices-missing"; +/** + * generate test output filenames + */ +static char *testnam(char *out) +{ + static int count = 0; + static char name[64]; + snprintf(name, 64, "/tmp/nsoptiontest%d", count); + count++; + return name; +} static nserror gui_options_init_defaults(struct nsoption_s *defaults) { @@ -160,7 +171,7 @@ START_TEST(nsoption_session_test) nsoption_set_colour(sys_colour_ActiveBorder, 0x00d0000d); /* write options out */ - outnam = tmpnam(NULL); + outnam = testnam(NULL); res = nsoption_write(outnam, NULL, NULL); ck_assert_int_eq(res, NSERROR_OK); @@ -300,7 +311,7 @@ START_TEST(nsoption_dump_test) res = nsoption_read(test_choices_path, NULL); ck_assert_int_eq(res, NSERROR_OK); - outnam = tmpnam(NULL); + outnam = testnam(NULL); fp = fopen(outnam, "w"); res = nsoption_dump(fp, NULL); @@ -325,7 +336,7 @@ START_TEST(nsoption_write_test) res = nsoption_read(test_choices_path, NULL); ck_assert_int_eq(res, NSERROR_OK); - outnam = tmpnam(NULL); + outnam = testnam(NULL); res = nsoption_write(outnam, NULL, NULL); ck_assert_int_eq(res, NSERROR_OK); diff --git a/test/urldbtest.c b/test/urldbtest.c index 117216517..555ca96b6 100644 --- a/test/urldbtest.c +++ b/test/urldbtest.c @@ -65,6 +65,18 @@ const char *wikipedia_url = "http://www.wikipedia.org/"; struct netsurf_table *guit = NULL; +/** + * generate test output filenames + */ +static char *testnam(char *out) +{ + static int count = 0; + static char name[64]; + snprintf(name, 64, "/tmp/urldbtest%d", count); + count++; + return name; +} + /** * compare two files contents */ @@ -443,7 +455,7 @@ START_TEST(urldb_session_test) urldb_load_cookies(test_cookies_path); /* write database out */ - outnam = tmpnam(NULL); + outnam = testnam(NULL); res = urldb_save(outnam); ck_assert_int_eq(res, NSERROR_OK); @@ -454,7 +466,7 @@ START_TEST(urldb_session_test) unlink(outnam); /* write cookies out */ - outnam = tmpnam(NULL); + outnam = testnam(NULL); urldb_save_cookies(outnam); /* check for the correct answer */ @@ -500,7 +512,7 @@ START_TEST(urldb_session_add_test) nsurl_unref(url); /* write database out */ - outnam = tmpnam(NULL); + outnam = testnam(NULL); res = urldb_save(outnam); ck_assert_int_eq(res, NSERROR_OK); @@ -508,7 +520,7 @@ START_TEST(urldb_session_add_test) unlink(outnam); /* write cookies out */ - outnam = tmpnam(NULL); + outnam = testnam(NULL); urldb_save_cookies(outnam); /* remove test output */ -- cgit v1.2.3