mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
tests: move unit files to units/ subdirectory
We have a bazillion of those unit files, and keeping them all directly in tests/ has become rather unwieldy.
This commit is contained in:
parent
cc46b9d913
commit
7b43295346
@ -92,7 +92,6 @@ static void test_packet_from_file(const char* filename, bool canonical) {
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i, N;
|
||||
_cleanup_free_ char *pkts_glob = NULL;
|
||||
_cleanup_globfree_ glob_t g = {};
|
||||
char **fnames;
|
||||
|
||||
@ -102,7 +101,8 @@ int main(int argc, char **argv) {
|
||||
N = argc - 1;
|
||||
fnames = argv + 1;
|
||||
} else {
|
||||
pkts_glob = path_join(get_testdata_dir(), "test-resolve/*.pkts");
|
||||
_cleanup_free_ char *pkts_glob = NULL;
|
||||
assert_se(get_testdata_dir("test-resolve/*.pkts", &pkts_glob) >= 0);
|
||||
assert_se(glob(pkts_glob, GLOB_NOSORT, NULL, &g) == 0);
|
||||
N = g.gl_pathc;
|
||||
fnames = g.gl_pathv;
|
||||
|
@ -58,21 +58,25 @@ static void load_testdata_env(void) {
|
||||
setenv(*k, *v, 0);
|
||||
}
|
||||
|
||||
const char* get_testdata_dir(void) {
|
||||
const char *env;
|
||||
int get_testdata_dir(const char *suffix, char **ret) {
|
||||
const char *dir;
|
||||
char *p;
|
||||
|
||||
load_testdata_env();
|
||||
|
||||
/* if the env var is set, use that */
|
||||
env = getenv("SYSTEMD_TEST_DATA");
|
||||
if (!env)
|
||||
env = SYSTEMD_TEST_DATA;
|
||||
if (access(env, F_OK) < 0) {
|
||||
fprintf(stderr, "ERROR: $SYSTEMD_TEST_DATA directory [%s] does not exist\n", env);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
dir = getenv("SYSTEMD_TEST_DATA");
|
||||
if (!dir)
|
||||
dir = SYSTEMD_TEST_DATA;
|
||||
if (access(dir, F_OK) < 0)
|
||||
return log_error_errno(errno, "ERROR: $SYSTEMD_TEST_DATA directory [%s] not accesible: %m", dir);
|
||||
|
||||
return env;
|
||||
p = path_join(dir, suffix);
|
||||
if (!p)
|
||||
return log_oom();
|
||||
|
||||
*ret = p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* get_catalog_dir(void) {
|
||||
|
@ -20,7 +20,7 @@ static inline bool manager_errno_skip_test(int r) {
|
||||
|
||||
char* setup_fake_runtime_dir(void);
|
||||
int enter_cgroup_subroot(char **ret_cgroup);
|
||||
const char* get_testdata_dir(void);
|
||||
int get_testdata_dir(const char *suffix, char **ret);
|
||||
const char* get_catalog_dir(void);
|
||||
bool slow_tests_enabled(void);
|
||||
void test_setup_logging(int level);
|
||||
|
@ -48,7 +48,9 @@ int main(int argc, char *argv[]) {
|
||||
if (r == -ENOMEDIUM)
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
r = bpf_program_new(BPF_PROG_TYPE_CGROUP_SKB, &p);
|
||||
|
@ -38,7 +38,9 @@ static int test_cgroup_mask(void) {
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
/* Prepare the manager. */
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m);
|
||||
if (IN_SET(r, -EPERM, -EACCES)) {
|
||||
|
@ -22,7 +22,9 @@ static int test_default_memory_low(void) {
|
||||
if (r == -ENOMEDIUM)
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m);
|
||||
if (IN_SET(r, -EPERM, -EACCES)) {
|
||||
|
@ -26,8 +26,11 @@ int main(int argc, char *argv[]) {
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
/* prepare the test */
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m);
|
||||
if (manager_errno_skip_test(r))
|
||||
return log_tests_skipped_errno(r, "manager_new");
|
||||
|
@ -806,7 +806,6 @@ static int run_tests(UnitFileScope scope, const test_entry tests[], char **patte
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL;
|
||||
_cleanup_free_ char *test_execute_path = NULL;
|
||||
|
||||
static const test_entry user_tests[] = {
|
||||
entry(test_exec_basic),
|
||||
@ -878,9 +877,10 @@ int main(int argc, char *argv[]) {
|
||||
if (r == -ENOMEDIUM)
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("test-execute/", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
test_execute_path = path_join(get_testdata_dir(), "test-execute");
|
||||
assert_se(set_unit_path(test_execute_path) >= 0);
|
||||
|
||||
/* Unset VAR1, VAR2 and VAR3 which are used in the PassEnvironment test
|
||||
* cases, otherwise (and if they are present in the environment),
|
||||
|
@ -25,7 +25,7 @@ static void test_basic_parsing(void) {
|
||||
_cleanup_free_ char *journal_data_path = NULL;
|
||||
int r;
|
||||
|
||||
journal_data_path = path_join(get_testdata_dir(), "journal-data/journal-1.txt");
|
||||
assert_se(get_testdata_dir("journal-data/journal-1.txt", &journal_data_path) >= 0);
|
||||
imp.fd = open(journal_data_path, O_RDONLY|O_CLOEXEC);
|
||||
assert_se(imp.fd >= 0);
|
||||
|
||||
@ -56,7 +56,7 @@ static void test_bad_input(void) {
|
||||
_cleanup_free_ char *journal_data_path = NULL;
|
||||
int r;
|
||||
|
||||
journal_data_path = path_join(get_testdata_dir(), "journal-data/journal-2.txt");
|
||||
assert_se(get_testdata_dir("journal-data/journal-1.txt", &journal_data_path) >= 0);
|
||||
imp.fd = open(journal_data_path, O_RDONLY|O_CLOEXEC);
|
||||
assert_se(imp.fd >= 0);
|
||||
|
||||
|
@ -251,7 +251,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
test_setup_logging(LOG_INFO);
|
||||
|
||||
test_path = path_join(get_testdata_dir(), "test-path");
|
||||
assert_se(get_testdata_dir("test-path", &test_path) >= 0);
|
||||
assert_se(set_unit_path(test_path) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
|
@ -25,8 +25,11 @@ int main(int argc, char *argv[]) {
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
/* prepare the test */
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
r = manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m);
|
||||
if (manager_errno_skip_test(r))
|
||||
return log_tests_skipped_errno(r, "manager_new");
|
||||
|
@ -15,8 +15,10 @@ static void test_mount_points_list(const char *fname) {
|
||||
|
||||
log_info("/* %s(\"%s\") */", __func__, fname ?: "/proc/self/mountinfo");
|
||||
|
||||
if (fname)
|
||||
fname = testdata_fname = path_join(get_testdata_dir(), fname);
|
||||
if (fname) {
|
||||
assert_se(get_testdata_dir(fname, &testdata_fname) >= 0);
|
||||
fname = testdata_fname;
|
||||
}
|
||||
|
||||
LIST_HEAD_INIT(mp_list_head);
|
||||
assert_se(mount_points_list_get(fname, &mp_list_head) >= 0);
|
||||
@ -37,8 +39,10 @@ static void test_swap_list(const char *fname) {
|
||||
|
||||
log_info("/* %s(\"%s\") */", __func__, fname ?: "/proc/swaps");
|
||||
|
||||
if (fname)
|
||||
fname = testdata_fname = path_join(get_testdata_dir(), fname);
|
||||
if (fname) {
|
||||
assert_se(get_testdata_dir(fname, &testdata_fname) >= 0);
|
||||
fname = testdata_fname;
|
||||
}
|
||||
|
||||
LIST_HEAD_INIT(mp_list_head);
|
||||
assert_se(swap_list_get(fname, &mp_list_head) >= 0);
|
||||
|
@ -20,7 +20,10 @@ int main(int argc, char *argv[]) {
|
||||
if (r == -ENOMEDIUM)
|
||||
return log_tests_skipped("cgroupfs not available");
|
||||
|
||||
assert_se(set_unit_path(get_testdata_dir()) >= 0);
|
||||
_cleanup_free_ char *unit_dir = NULL;
|
||||
assert_se(get_testdata_dir("units/", &unit_dir) >= 0);
|
||||
assert_se(set_unit_path(unit_dir) >= 0);
|
||||
|
||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||
|
||||
assert_se(manager_new(UNIT_FILE_USER, MANAGER_TEST_RUN_BASIC, &m) >= 0);
|
||||
|
@ -1 +0,0 @@
|
||||
../units/basic.target
|
@ -1,49 +1,8 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1+
|
||||
|
||||
test_data_files = '''
|
||||
a.service
|
||||
a-conj.service
|
||||
b.service
|
||||
basic.target
|
||||
c.service
|
||||
d.service
|
||||
daughter.service
|
||||
dml.slice
|
||||
dml-passthrough.slice
|
||||
dml-passthrough-empty.service
|
||||
dml-passthrough-set-dml.service
|
||||
dml-passthrough-set-ml.service
|
||||
dml-override.slice
|
||||
dml-override-empty.service
|
||||
dml-discard.slice
|
||||
dml-discard-empty.service
|
||||
dml-discard-set-ml.service
|
||||
e.service
|
||||
end.service
|
||||
f.service
|
||||
g.service
|
||||
grandchild.service
|
||||
h.service
|
||||
hello-after-sleep.target
|
||||
hello.service
|
||||
hwdb.d/10-bad.hwdb
|
||||
i.service
|
||||
journal-data/journal-1.txt
|
||||
journal-data/journal-2.txt
|
||||
nomem.slice
|
||||
nomemleaf.service
|
||||
parent-deep.slice
|
||||
parent.slice
|
||||
sched_idle_bad.service
|
||||
sched_idle_ok.service
|
||||
sched_rr_bad.service
|
||||
sched_rr_change.service
|
||||
sched_rr_ok.service
|
||||
shutdown.target
|
||||
sleep.service
|
||||
sockets.target
|
||||
son.service
|
||||
sysinit.target
|
||||
test-execute/exec-basic.service
|
||||
test-execute/exec-ambientcapabilities-merge-nfsnobody.service
|
||||
test-execute/exec-ambientcapabilities-merge-nobody.service
|
||||
@ -194,14 +153,6 @@ test_data_files = '''
|
||||
test-umount/example.swaps
|
||||
test-umount/garbled.mountinfo
|
||||
test-umount/rhbug-1554943.mountinfo
|
||||
testsuite.target
|
||||
timers.target
|
||||
unit-with-.service.d/20-override.conf
|
||||
unit-with-multiple-.service.d/20-override.conf
|
||||
unit-with-multiple-.service.d/30-override.conf
|
||||
unit-with-multiple-dashes.service
|
||||
unit-with-multiple-dashes.service.d/10-override.conf
|
||||
unstoppable.service
|
||||
'''.split()
|
||||
|
||||
if conf.get('ENABLE_RESOLVE') == 1
|
||||
@ -232,6 +183,10 @@ if install_tests
|
||||
endforeach
|
||||
endif
|
||||
|
||||
install_subdir(
|
||||
'units',
|
||||
install_dir : testsdir + '/testdata/')
|
||||
|
||||
############################################################
|
||||
|
||||
rule_syntax_check_py = find_program('rule-syntax-check.py')
|
||||
|
@ -1 +0,0 @@
|
||||
../units/shutdown.target
|
@ -1 +0,0 @@
|
||||
../units/sockets.target
|
@ -1 +0,0 @@
|
||||
../units/sysinit.target
|
@ -1 +0,0 @@
|
||||
../units/timers.target
|
1
test/units/basic.target
Symbolic link
1
test/units/basic.target
Symbolic link
@ -0,0 +1 @@
|
||||
../../units/basic.target
|
1
test/units/shutdown.target
Symbolic link
1
test/units/shutdown.target
Symbolic link
@ -0,0 +1 @@
|
||||
../../units/shutdown.target
|
1
test/units/sockets.target
Symbolic link
1
test/units/sockets.target
Symbolic link
@ -0,0 +1 @@
|
||||
../../units/sockets.target
|
1
test/units/sysinit.target
Symbolic link
1
test/units/sysinit.target
Symbolic link
@ -0,0 +1 @@
|
||||
../../units/sysinit.target
|
1
test/units/timers.target
Symbolic link
1
test/units/timers.target
Symbolic link
@ -0,0 +1 @@
|
||||
../../units/timers.target
|
Loading…
x
Reference in New Issue
Block a user