diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-10-23 10:50:38 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-10-26 12:56:53 +0200 |
commit | 75e7d50e261c42d3de9afc7ad7368308f45c1498 (patch) | |
tree | fa5e5c7cd5f41b8bc7510f0cdc11a10cfd3b0f02 /src | |
parent | Introduce fmkostemp_safe and use it in tests (diff) | |
download | systemd-75e7d50e261c42d3de9afc7ad7368308f45c1498.tar.xz systemd-75e7d50e261c42d3de9afc7ad7368308f45c1498.zip |
test: _cleanup_(unlink_tempfilep) in two more places
Diffstat (limited to '')
-rw-r--r-- | src/test/test-clock.c | 4 | ||||
-rw-r--r-- | src/test/test-env-util.c | 5 |
2 files changed, 3 insertions, 6 deletions
diff --git a/src/test/test-clock.c b/src/test/test-clock.c index 95ac8de91b..f5b9a72727 100644 --- a/src/test/test-clock.c +++ b/src/test/test-clock.c @@ -14,7 +14,7 @@ #include "macro.h" static void test_clock_is_localtime(void) { - char adjtime[] = "/tmp/test-adjtime.XXXXXX"; + _cleanup_(unlink_tempfilep) char adjtime[] = "/tmp/test-adjtime.XXXXXX"; _cleanup_fclose_ FILE* f = NULL; static const struct scenario { @@ -52,8 +52,6 @@ static void test_clock_is_localtime(void) { assert_se(write_string_stream(f, scenarios[i].contents, WRITE_STRING_FILE_AVOID_NEWLINE) == 0); assert_se(clock_is_localtime(adjtime) == scenarios[i].expected_result); } - - unlink(adjtime); } /* Test with the real /etc/adjtime */ diff --git a/src/test/test-env-util.c b/src/test/test-env-util.c index 0ab671b476..815fb340af 100644 --- a/src/test/test-env-util.c +++ b/src/test/test-env-util.c @@ -6,6 +6,7 @@ #include "env-util.h" #include "fd-util.h" #include "fileio.h" +#include "fs-util.h" #include "serialize.h" #include "string-util.h" #include "strv.h" @@ -321,7 +322,7 @@ static void test_deserialize_environment(void) { static void test_serialize_environment(void) { _cleanup_strv_free_ char **env = NULL, **env2 = NULL; - char fn[] = "/tmp/test-env-util.XXXXXXX"; + _cleanup_(unlink_tempfilep) char fn[] = "/tmp/test-env-util.XXXXXXX"; _cleanup_fclose_ FILE *f = NULL; int r; @@ -358,8 +359,6 @@ static void test_serialize_environment(void) { assert_se(feof(f)); assert_se(strv_equal(env, env2)); - - unlink(fn); } int main(int argc, char *argv[]) { |