summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-clock.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/test/test-clock.c b/src/test/test-clock.c
index 92c4f79b98..84f775e5bc 100644
--- a/src/test/test-clock.c
+++ b/src/test/test-clock.c
@@ -20,17 +20,18 @@
#include <unistd.h>
#include <fcntl.h>
-#include "macro.h"
+#include "clock-util.h"
+#include "fd-util.h"
#include "fileio.h"
#include "log.h"
-#include "clock-util.h"
+#include "macro.h"
static void test_clock_is_localtime(void) {
char adjtime[] = "/tmp/test-adjtime.XXXXXX";
- int fd;
- FILE* f;
+ int fd = -1;
+ _cleanup_fclose_ FILE* f = NULL;
- const struct scenario {
+ static const struct scenario {
const char* contents;
int expected_result;
} scenarios[] = {
@@ -55,10 +56,10 @@ static void test_clock_is_localtime(void) {
assert_se(clock_is_localtime("/nonexisting/adjtime") == 0);
fd = mkostemp_safe(adjtime, O_WRONLY|O_CLOEXEC);
- assert(fd > 0);
+ assert_se(fd >= 0);
log_info("adjtime test file: %s", adjtime);
f = fdopen(fd, "w");
- assert(f);
+ assert_se(f);
for (size_t i = 0; i < ELEMENTSOF(scenarios); ++i) {
log_info("scenario #%zu:, expected result %i", i, scenarios[i].expected_result);
@@ -81,10 +82,10 @@ static void test_clock_is_localtime_system(void) {
log_info("/etc/adjtime exists, clock_is_localtime() == %i", r);
/* if /etc/adjtime exists we expect some answer, no error or
* crash */
- assert(r == 0 || r == 1);
+ assert_se(r == 0 || r == 1);
} else
/* default is UTC if there is no /etc/adjtime */
- assert(r == 0);
+ assert_se(r == 0);
}
int main(int argc, char *argv[]) {