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 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'test/nsoption.c') 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); -- cgit v1.2.3