#include "process-util.h"
#include "random-util.h"
#include "string-util.h"
+#include "tests.h"
#include "util.h"
typedef int (compress_t)(const void *src, uint64_t src_size, void *dst,
int main(int argc, char *argv[]) {
#if HAVE_XZ || HAVE_LZ4
const char *i;
- int r;
log_set_max_level(LOG_INFO);
+ log_parse_environment();
+ log_open();
if (argc >= 2) {
unsigned x;
assert_se(safe_atou(argv[1], &x) >= 0);
arg_duration = x * USEC_PER_SEC;
- } else {
- bool slow;
-
- r = getenv_bool("SYSTEMD_SLOW_TESTS");
- slow = r >= 0 ? r : SYSTEMD_SLOW_TESTS_DEFAULT;
-
- arg_duration = slow ? 2 * USEC_PER_SEC : USEC_PER_SEC / 50;
- }
+ } else
+ arg_duration = slow_tests_enabled() ?
+ 2 * USEC_PER_SEC : USEC_PER_SEC / 50;
if (argc == 3)
(void) safe_atozu(argv[2], &arg_start);
#include <util.h>
#include "alloc-util.h"
+#include "env-util.h"
#include "fileio.h"
#include "path-util.h"
#include "strv.h"
}
return env;
}
+
+bool slow_tests_enabled(void) {
+ int r;
+
+ r = getenv_bool("SYSTEMD_SLOW_TESTS");
+ if (r >= 0)
+ return r;
+
+ if (r != -ENXIO)
+ log_warning_errno(r, "Cannot parse $SYSTEMD_SLOW_TESTS, ignoring.");
+ return SYSTEMD_SLOW_TESTS_DEFAULT;
+}
char* setup_fake_runtime_dir(void);
const char* get_testdata_dir(void);
const char* get_catalog_dir(void);
+bool slow_tests_enabled(void);
/* SPDX-License-Identifier: LGPL-2.1+ */
#include "alloc-util.h"
-#include "env-util.h"
#include "hashmap.h"
#include "log.h"
#include "string-util.h"
#include "strv.h"
+#include "tests.h"
#include "util.h"
-static bool arg_slow = false;
-
void test_hashmap_funcs(void);
static void test_hashmap_replace(void) {
Hashmap *h;
unsigned i, j;
void *v, *k;
+ bool slow = slow_tests_enabled();
const struct {
const struct hash_ops *ops;
unsigned n_entries;
} tests[] = {
- { .ops = NULL, .n_entries = arg_slow ? 1 << 20 : 240 },
- { .ops = &crippled_hashmap_ops, .n_entries = arg_slow ? 1 << 14 : 140 },
+ { .ops = NULL, .n_entries = slow ? 1 << 20 : 240 },
+ { .ops = &crippled_hashmap_ops, .n_entries = slow ? 1 << 14 : 140 },
};
- log_info("%s (%s)", __func__, arg_slow ? "slow" : "fast");
+ log_info("%s (%s)", __func__, slow ? "slow" : "fast");
for (j = 0; j < ELEMENTSOF(tests); j++) {
assert_se(h = hashmap_new(tests[j].ops));
}
void test_hashmap_funcs(void) {
- int r;
-
log_parse_environment();
log_open();
- r = getenv_bool("SYSTEMD_SLOW_TESTS");
- arg_slow = r >= 0 ? r : SYSTEMD_SLOW_TESTS_DEFAULT;
-
test_hashmap_copy();
test_hashmap_get_strv();
test_hashmap_move_one();
#include <string.h>
#include <unistd.h>
-#include "env-util.h"
#include "log.h"
+#include "tests.h"
#include "watchdog.h"
int main(int argc, char *argv[]) {
log_set_max_level(LOG_DEBUG);
log_parse_environment();
+ log_open();
- r = getenv_bool("SYSTEMD_SLOW_TESTS");
- slow = r >= 0 ? r : SYSTEMD_SLOW_TESTS_DEFAULT;
+ slow = slow_tests_enabled();
t = slow ? 10 * USEC_PER_SEC : 1 * USEC_PER_SEC;
count = slow ? 5 : 3;