summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSven Eden <yamakuzure@gmx.net>2018-06-05 19:03:51 +0200
committerSven Eden <yamakuzure@gmx.net>2018-06-05 19:08:49 +0200
commite52c8fee3942b4876b5790dc960518043ce7dcd0 (patch)
tree99a6aa89dca495c29961068a74598e9621e1a755 /src/test
parent38277972506531443cf59d1f68a89863c9fcde2f (diff)
Prep v238: Remove obsolete sources and add missing new ones.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-gcrypt-util.c34
-rw-r--r--src/test/test-watch-pid.c96
2 files changed, 0 insertions, 130 deletions
diff --git a/src/test/test-gcrypt-util.c b/src/test/test-gcrypt-util.c
deleted file mode 100644
index 9f0ed2196..000000000
--- a/src/test/test-gcrypt-util.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+
- * Copyright 2018 Zbigniew Jędrzejewski-Szmek
- */
-
-//#include "alloc-util.h"
-//#include "gcrypt-util.h"
-//#include "macro.h"
-//#include "string-util.h"
-
-static void test_string_hashsum(void) {
- _cleanup_free_ char *out1 = NULL, *out2 = NULL, *out3 = NULL, *out4 = NULL;
-
- assert_se(string_hashsum("asdf", 4, GCRY_MD_SHA224, &out1) == 0);
- /* echo -n 'asdf' | sha224sum - */
- assert_se(streq(out1, "7872a74bcbf298a1e77d507cd95d4f8d96131cbbd4cdfc571e776c8a"));
-
- assert_se(string_hashsum("asdf", 4, GCRY_MD_SHA256, &out2) == 0);
- /* echo -n 'asdf' | sha256sum - */
- assert_se(streq(out2, "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b"));
-
- assert_se(string_hashsum("", 0, GCRY_MD_SHA224, &out3) == 0);
- /* echo -n '' | sha224sum - */
- assert_se(streq(out3, "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f"));
-
- assert_se(string_hashsum("", 0, GCRY_MD_SHA256, &out4) == 0);
- /* echo -n '' | sha256sum - */
- assert_se(streq(out4, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"));
-}
-
-int main(int argc, char **argv) {
- test_string_hashsum();
-
- return 0;
-}
diff --git a/src/test/test-watch-pid.c b/src/test/test-watch-pid.c
deleted file mode 100644
index 37ff2e433..000000000
--- a/src/test/test-watch-pid.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1+ */
-
-//#include "log.h"
-//#include "manager.h"
-//#include "rm-rf.h"
-//#include "test-helper.h"
-//#include "tests.h"
-
-int main(int argc, char *argv[]) {
- _cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL;
- Unit *a, *b, *c, *u;
- Manager *m;
- int r;
-
- log_set_max_level(LOG_DEBUG);
- log_parse_environment();
- log_open();
-
- if (getuid() != 0) {
- log_notice("Not running as root, skipping kernel related tests.");
- return EXIT_TEST_SKIP;
- }
-
- r = enter_cgroup_subroot();
- if (r == -ENOMEDIUM) {
- log_notice("cgroupfs not available, skipping tests");
- return EXIT_TEST_SKIP;
- }
-
- assert_se(set_unit_path(get_testdata_dir("")) >= 0);
- assert_se(runtime_dir = setup_fake_runtime_dir());
-
- assert_se(manager_new(UNIT_FILE_USER, true, &m) >= 0);
- assert_se(manager_startup(m, NULL, NULL) >= 0);
-
- assert_se(a = unit_new(m, sizeof(Service)));
- assert_se(unit_add_name(a, "a.service") >= 0);
- assert_se(set_isempty(a->pids));
-
- assert_se(b = unit_new(m, sizeof(Service)));
- assert_se(unit_add_name(b, "b.service") >= 0);
- assert_se(set_isempty(b->pids));
-
- assert_se(c = unit_new(m, sizeof(Service)));
- assert_se(unit_add_name(c, "c.service") >= 0);
- assert_se(set_isempty(c->pids));
-
- assert_se(hashmap_isempty(m->watch_pids));
- assert_se(manager_get_unit_by_pid(m, 4711) == NULL);
-
- assert_se(unit_watch_pid(a, 4711) >= 0);
- assert_se(manager_get_unit_by_pid(m, 4711) == a);
-
- assert_se(unit_watch_pid(a, 4711) >= 0);
- assert_se(manager_get_unit_by_pid(m, 4711) == a);
-
- assert_se(unit_watch_pid(b, 4711) >= 0);
- u = manager_get_unit_by_pid(m, 4711);
- assert_se(u == a || u == b);
-
- assert_se(unit_watch_pid(b, 4711) >= 0);
- u = manager_get_unit_by_pid(m, 4711);
- assert_se(u == a || u == b);
-
- assert_se(unit_watch_pid(c, 4711) >= 0);
- u = manager_get_unit_by_pid(m, 4711);
- assert_se(u == a || u == b || u == c);
-
- assert_se(unit_watch_pid(c, 4711) >= 0);
- u = manager_get_unit_by_pid(m, 4711);
- assert_se(u == a || u == b || u == c);
-
- unit_unwatch_pid(b, 4711);
- u = manager_get_unit_by_pid(m, 4711);
- assert_se(u == a || u == c);
-
- unit_unwatch_pid(b, 4711);
- u = manager_get_unit_by_pid(m, 4711);
- assert_se(u == a || u == c);
-
- unit_unwatch_pid(a, 4711);
- assert_se(manager_get_unit_by_pid(m, 4711) == c);
-
- unit_unwatch_pid(a, 4711);
- assert_se(manager_get_unit_by_pid(m, 4711) == c);
-
- unit_unwatch_pid(c, 4711);
- assert_se(manager_get_unit_by_pid(m, 4711) == NULL);
-
- unit_unwatch_pid(c, 4711);
- assert_se(manager_get_unit_by_pid(m, 4711) == NULL);
-
- manager_free(m);
-
- return 0;
-}