summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bfstd.c5
-rw-r--r--tests/main.c14
-rw-r--r--tests/xtime.c10
-rw-r--r--tests/xtouch.c2
4 files changed, 18 insertions, 13 deletions
diff --git a/tests/bfstd.c b/tests/bfstd.c
index 4d0ec23..0ded5de 100644
--- a/tests/bfstd.c
+++ b/tests/bfstd.c
@@ -43,11 +43,6 @@ static bool check_wordesc(const char *str, const char *exp, enum wesc_flags flag
bool check_bfstd(void) {
bool ret = true;
- // Try to set a UTF-8 locale
- if (!setlocale(LC_ALL, "C.UTF-8")) {
- setlocale(LC_ALL, "");
- }
-
// From man 3p basename
ret &= check_base_dir("usr", ".", "usr");
ret &= check_base_dir("usr/", ".", "usr");
diff --git a/tests/main.c b/tests/main.c
index e69fe35..38438b2 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -11,9 +11,11 @@
#include "../src/config.h"
#include "../src/diag.h"
#include <errno.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <time.h>
/**
* Test context.
@@ -90,6 +92,18 @@ static void run_test(struct test_ctx *ctx, const char *test, test_fn *fn) {
}
int main(int argc, char *argv[]) {
+ // Try to set a UTF-8 locale
+ if (!setlocale(LC_ALL, "C.UTF-8")) {
+ setlocale(LC_ALL, "");
+ }
+
+ // Run tests in UTC
+ if (setenv("TZ", "UTC0", true) != 0) {
+ perror("setenv()");
+ return EXIT_FAILURE;
+ }
+ tzset();
+
struct test_ctx ctx;
if (test_init(&ctx, argc, argv) != 0) {
goto done;
diff --git a/tests/xtime.c b/tests/xtime.c
index f853428..2609c1c 100644
--- a/tests/xtime.c
+++ b/tests/xtime.c
@@ -81,8 +81,8 @@ static bool check_xgetdate(void) {
/** Check one xmktime() result. */
static bool check_one_xmktime(time_t expected) {
struct tm tm;
- if (xlocaltime(&expected, &tm) != 0) {
- bfs_diag("xlocaltime(%jd): %s", (intmax_t)expected, xstrerror(errno));
+ if (!localtime_r(&expected, &tm)) {
+ bfs_diag("localtime_r(%jd): %s", (intmax_t)expected, xstrerror(errno));
return false;
}
@@ -145,12 +145,6 @@ static bool check_xtimegm(void) {
}
bool check_xtime(void) {
- if (setenv("TZ", "UTC0", true) != 0) {
- perror("setenv()");
- return false;
- }
- tzset();
-
bool ret = true;
ret &= check_xgetdate();
ret &= check_xmktime();
diff --git a/tests/xtouch.c b/tests/xtouch.c
index 6099128..8c5c5f3 100644
--- a/tests/xtouch.c
+++ b/tests/xtouch.c
@@ -157,6 +157,8 @@ done:
}
int main(int argc, char *argv[]) {
+ tzset();
+
mode_t mask = umask(0);
struct args args = {