summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml5
-rw-r--r--Makefile.am13
-rw-r--r--src/journal/test-catalog.c20
-rw-r--r--src/journal/test-journal-interleaving.c4
-rw-r--r--src/journal/test-journal-stream.c4
-rw-r--r--src/journal/test-journal-verify.c4
-rw-r--r--src/journal/test-journal.c4
-rw-r--r--src/test/test-cgroup-util.c5
-rw-r--r--src/test/test-helper.h31
-rw-r--r--src/test/test-id128.c11
-rw-r--r--src/test/test-unit-file.c3
-rw-r--r--src/test/test-unit-name.c5
-rw-r--r--src/test/test-util.c9
13 files changed, 101 insertions, 17 deletions
diff --git a/.travis.yml b/.travis.yml
index 42433fd4d0..7e5251cfb0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,8 +3,9 @@ compiler:
- gcc
before_install:
- sudo apt-get update -qq
- - sudo apt-get install autotools-dev automake autoconf libtool libdbus-1-dev libcap-dev libblkid-dev libpam-dev libcryptsetup-dev libaudit-dev libacl1-dev libattr1-dev libselinux-dev liblzma-dev libgcrypt-dev libqrencode-dev libmicrohttpd-dev gtk-doc-tools gperf
-script: ./autogen.sh && ./configure --enable-gtk-doc --enable-gtk-doc-pdf && make V=1 && make dist V=1
+ - sudo apt-get install autotools-dev automake autoconf libtool libdbus-1-dev libcap-dev libblkid-dev libpam-dev libcryptsetup-dev libaudit-dev libacl1-dev libattr1-dev libselinux-dev liblzma-dev libgcrypt-dev libqrencode-dev libmicrohttpd-dev gtk-doc-tools gperf python2.7-dev
+script: ./autogen.sh && ./configure --enable-gtk-doc --enable-gtk-doc-pdf && make V=1 && sudo ./systemd-machine-id-setup && make check && make distcheck
+after_failure: cat test-suite.log
notifications:
irc:
channels:
diff --git a/Makefile.am b/Makefile.am
index fdfdd6515e..fd38e8201f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1143,6 +1143,9 @@ EXTRA_DIST += \
test/sched_rr_ok.service \
test/sched_rr_change.service
+EXTRA_DIST += \
+ src/test/test-helper.h
+
test_engine_SOURCES = \
src/test/test-engine.c
@@ -1341,7 +1344,8 @@ test_cgroup_util_SOURCES = \
test_cgroup_util_LDADD = \
libsystemd-label.la \
- libsystemd-shared.la
+ libsystemd-shared.la \
+ libsystemd-daemon.la
test_env_replace_SOURCES = \
src/test/test-env-replace.c
@@ -2680,7 +2684,8 @@ test_id128_SOURCES = \
test_id128_LDADD = \
libsystemd-shared.la \
- libsystemd-id128-internal.la
+ libsystemd-id128-internal.la \
+ libsystemd-daemon.la
tests += \
test-id128
@@ -2852,6 +2857,10 @@ test_mmap_cache_LDADD = \
test_catalog_SOURCES = \
src/journal/test-catalog.c
+test_catalog_CFLAGS = \
+ $(AM_CFLAGS) \
+ -DCATALOG_DIR=\"$(abs_top_srcdir)/catalog\"
+
test_catalog_LDADD = \
libsystemd-shared.la \
libsystemd-label.la \
diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c
index 987867f0c8..5db5bed8de 100644
--- a/src/journal/test-catalog.c
+++ b/src/journal/test-catalog.c
@@ -31,6 +31,16 @@
#include "sd-messages.h"
#include "catalog.h"
+static const char *catalog_dirs[] = {
+ CATALOG_DIR,
+ NULL,
+};
+
+static const char *no_catalog_dirs[] = {
+ "/bin/hopefully/with/no/catalog",
+ NULL
+};
+
static void test_import(Hashmap *h, struct strbuf *sb,
const char* contents, ssize_t size, int code) {
int r;
@@ -100,9 +110,13 @@ static void test_catalog_update(void) {
r = catalog_update(database, NULL, NULL);
assert(r >= 0);
- /* Note: this might actually not find anything, if systemd was
- * not installed before. That should be fine too. */
- r = catalog_update(database, NULL, catalog_file_dirs);
+ /* Test what happens if there are no files in the directory. */
+ r = catalog_update(database, NULL, no_catalog_dirs);
+ assert(r >= 0);
+
+ /* Make sure that we at least have some files loaded or the
+ catalog_list below will fail. */
+ r = catalog_update(database, NULL, catalog_dirs);
assert(r >= 0);
}
diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c
index 069d297a9f..2b21523f57 100644
--- a/src/journal/test-journal-interleaving.c
+++ b/src/journal/test-journal-interleaving.c
@@ -288,6 +288,10 @@ static void test_sequence_numbers(void) {
int main(int argc, char *argv[]) {
log_set_max_level(LOG_DEBUG);
+ /* journal_file_open requires a valid machine id */
+ if (access("/etc/machine-id", F_OK) != 0)
+ return EXIT_TEST_SKIP;
+
arg_keep = argc > 1;
test_skip(setup_sequential);
diff --git a/src/journal/test-journal-stream.c b/src/journal/test-journal-stream.c
index 6b32b252e8..8e1d08d596 100644
--- a/src/journal/test-journal-stream.c
+++ b/src/journal/test-journal-stream.c
@@ -80,6 +80,10 @@ int main(int argc, char *argv[]) {
const void *data;
size_t l;
+ /* journal_file_open requires a valid machine id */
+ if (access("/etc/machine-id", F_OK) != 0)
+ return EXIT_TEST_SKIP;
+
log_set_max_level(LOG_DEBUG);
assert_se(mkdtemp(t));
diff --git a/src/journal/test-journal-verify.c b/src/journal/test-journal-verify.c
index 6b7414a4b1..0540074207 100644
--- a/src/journal/test-journal-verify.c
+++ b/src/journal/test-journal-verify.c
@@ -77,6 +77,10 @@ int main(int argc, char *argv[]) {
struct stat st;
uint64_t p;
+ /* journal_file_open requires a valid machine id */
+ if (access("/etc/machine-id", F_OK) != 0)
+ return EXIT_TEST_SKIP;
+
log_set_max_level(LOG_DEBUG);
assert_se(mkdtemp(t));
diff --git a/src/journal/test-journal.c b/src/journal/test-journal.c
index 534fd28fa6..190c426eba 100644
--- a/src/journal/test-journal.c
+++ b/src/journal/test-journal.c
@@ -174,6 +174,10 @@ static void test_empty(void) {
int main(int argc, char *argv[]) {
arg_keep = argc > 1;
+ /* journal_file_open requires a valid machine id */
+ if (access("/etc/machine-id", F_OK) != 0)
+ return EXIT_TEST_SKIP;
+
test_non_empty();
test_empty();
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c
index 295bb02e3b..16bf968340 100644
--- a/src/test/test-cgroup-util.c
+++ b/src/test/test-cgroup-util.c
@@ -23,6 +23,7 @@
#include "util.h"
#include "cgroup-util.h"
+#include "test-helper.h"
static void check_p_d_u(const char *path, int code, const char *result) {
_cleanup_free_ char *unit = NULL;
@@ -239,9 +240,9 @@ int main(void) {
test_path_get_session();
test_path_get_owner_uid();
test_path_get_machine_name();
- test_get_paths();
+ TEST_REQ_RUNNING_SYSTEMD(test_get_paths());
test_proc();
- test_escape();
+ TEST_REQ_RUNNING_SYSTEMD(test_escape());
test_controller_is_valid();
test_slice_to_path();
diff --git a/src/test/test-helper.h b/src/test/test-helper.h
new file mode 100644
index 0000000000..92864edb54
--- /dev/null
+++ b/src/test/test-helper.h
@@ -0,0 +1,31 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#pragma once
+
+/***
+ This file is part of systemd.
+
+ Copyright 2013 Holger Hans Peter Freyther
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "sd-daemon.h"
+
+#define TEST_REQ_RUNNING_SYSTEMD(x) \
+ if (sd_booted() > 0) { \
+ x; \
+ } else { \
+ printf("systemd not booted skipping '%s'\n", #x); \
+ }
diff --git a/src/test/test-id128.c b/src/test/test-id128.c
index 2ed8e292e6..7b92758174 100644
--- a/src/test/test-id128.c
+++ b/src/test/test-id128.c
@@ -25,6 +25,7 @@
#include "util.h"
#include "macro.h"
+#include "sd-daemon.h"
#define ID128_WALDI SD_ID128_MAKE(01, 02, 03, 04, 05, 06, 07, 08, 09, 0a, 0b, 0c, 0d, 0e, 0f, 10)
#define STR_WALDI "0102030405060708090a0b0c0d0e0f10"
@@ -41,11 +42,13 @@ int main(int argc, char *argv[]) {
assert_se(sd_id128_from_string(t, &id2) == 0);
assert_se(sd_id128_equal(id, id2));
- assert_se(sd_id128_get_machine(&id) == 0);
- printf("machine: %s\n", sd_id128_to_string(id, t));
+ if (sd_booted() > 0) {
+ assert_se(sd_id128_get_machine(&id) == 0);
+ printf("machine: %s\n", sd_id128_to_string(id, t));
- assert_se(sd_id128_get_boot(&id) == 0);
- printf("boot: %s\n", sd_id128_to_string(id, t));
+ assert_se(sd_id128_get_boot(&id) == 0);
+ printf("boot: %s\n", sd_id128_to_string(id, t));
+ }
printf("waldi: %s\n", sd_id128_to_string(ID128_WALDI, t));
assert_se(streq(t, STR_WALDI));
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index 2075e86115..dc6bc55244 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -35,6 +35,7 @@
#include "load-fragment.h"
#include "strv.h"
#include "fileio.h"
+#include "test-helper.h"
static int test_unit_file_get_set(void) {
int r;
@@ -366,7 +367,7 @@ int main(int argc, char *argv[]) {
test_load_env_file_2();
test_load_env_file_3();
test_load_env_file_4();
- test_install_printf();
+ TEST_REQ_RUNNING_SYSTEMD(test_install_printf());
return r;
}
diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c
index 6776ef0857..c17692b845 100644
--- a/src/test/test-unit-name.c
+++ b/src/test/test-unit-name.c
@@ -34,6 +34,7 @@
#include "specifier.h"
#include "util.h"
#include "macro.h"
+#include "test-helper.h"
static void test_replacements(void) {
#define expect(pattern, repl, expected) \
@@ -196,6 +197,8 @@ static int test_unit_printf(void) {
}
int main(int argc, char* argv[]) {
+ int rc = 0;
test_replacements();
- return test_unit_printf();
+ TEST_REQ_RUNNING_SYSTEMD(rc = test_unit_printf());
+ return rc;
}
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 875aeab3d5..dd7768d36c 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -397,6 +397,7 @@ static void test_u64log2(void) {
}
static void test_get_process_comm(void) {
+ struct stat st;
_cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL;
unsigned long long b;
pid_t e;
@@ -405,8 +406,12 @@ static void test_get_process_comm(void) {
dev_t h;
int r;
- assert_se(get_process_comm(1, &a) >= 0);
- log_info("pid1 comm: '%s'", a);
+ if (stat("/proc/1/comm", &st) == 0) {
+ assert_se(get_process_comm(1, &a) >= 0);
+ log_info("pid1 comm: '%s'", a);
+ } else {
+ log_warning("/proc/1/comm does not exist.");
+ }
assert_se(get_starttime_of_pid(1, &b) >= 0);
log_info("pid1 starttime: '%llu'", b);