tests: do not hardcode paths under /tmp
This is a classic case of insecure file creation, aka CWE-377 (albeit
"just" affecting developers, not users of libyang). This path is also
not available on Windows.
diff --git a/tests/utests/basic/test_inout.c b/tests/utests/basic/test_inout.c
index d2455fd..99af939 100644
--- a/tests/utests/basic/test_inout.c
+++ b/tests/utests/basic/test_inout.c
@@ -154,7 +154,7 @@
struct ly_out *out = NULL;
int fd1, fd2;
char buf[31] = {0};
- const char *filepath = "/tmp/libyang_test_output";
+ const char *filepath = TESTS_BIN "/libyang_test_output";
assert_int_not_equal(-1, fd1 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
assert_int_not_equal(-1, fd2 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
@@ -201,7 +201,7 @@
struct ly_out *out = NULL;
FILE *f1, *f2;
char buf[31] = {0};
- const char *filepath = "/tmp/libyang_test_output";
+ const char *filepath = TESTS_BIN "/libyang_test_output";
assert_int_not_equal(-1, f1 = fopen(filepath, "w"));
assert_int_not_equal(-1, f2 = fopen(filepath, "w"));
@@ -246,8 +246,8 @@
struct ly_out *out = NULL;
FILE *f1;
char buf[31] = {0};
- const char *fp1 = "/tmp/libyang_test_output";
- const char *fp2 = "/tmp/libyang_test_output2";
+ const char *fp1 = TESTS_BIN "/libyang_test_output";
+ const char *fp2 = TESTS_BIN "/libyang_test_output2";
/* manipulate with the handler */
assert_int_equal(LY_SUCCESS, ly_out_new_filepath(fp1, &out));
@@ -299,7 +299,7 @@
struct ly_out *out = NULL;
int fd1, fd2;
char buf[31] = {0};
- const char *filepath = "/tmp/libyang_test_output";
+ const char *filepath = TESTS_BIN "/libyang_test_output";
assert_int_not_equal(-1, fd1 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
assert_int_not_equal(-1, fd2 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));