tests: core: add missing asserts for several function calls Several function calls to `p_stat` and `p_close` have no verification if they actually succeeded. As these functions _may_ fail and as we also want to make sure that we're not doing anything dumb, let's check them, too.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/tests/core/posix.c b/tests/core/posix.c
index a459b26..795be31 100644
--- a/tests/core/posix.c
+++ b/tests/core/posix.c
@@ -122,7 +122,7 @@ void test_core_posix__utimes(void)
cl_git_mkfile("foo", "Dummy file.");
cl_must_pass(p_utimes("foo", times));
- p_stat("foo", &st);
+ cl_must_pass(p_stat("foo", &st));
cl_assert_equal_i(1234567890, st.st_atime);
cl_assert_equal_i(1234567890, st.st_mtime);
@@ -135,9 +135,9 @@ void test_core_posix__utimes(void)
cl_must_pass(fd = p_open("foo", O_RDWR));
cl_must_pass(p_futimes(fd, times));
- p_close(fd);
+ cl_must_pass(p_close(fd));
- p_stat("foo", &st);
+ cl_must_pass(p_stat("foo", &st));
cl_assert_equal_i(1414141414, st.st_atime);
cl_assert_equal_i(1414141414, st.st_mtime);
@@ -148,11 +148,11 @@ void test_core_posix__utimes(void)
cl_must_pass(p_utimes("foo", NULL));
curtime = time(NULL);
- p_stat("foo", &st);
+ cl_must_pass(p_stat("foo", &st));
cl_assert((st.st_atime - curtime) < 5);
cl_assert((st.st_mtime - curtime) < 5);
- p_unlink("foo");
+ cl_must_pass(p_unlink("foo"));
}
static void try_set_locale(int category)