[systemd-commits] 5 commits - Makefile.am man/systemd-analyze.xml src/journal src/libsystemd-bus src/shared src/test TODO .travis.yml units/kmod-static-nodes.service.in
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Wed Aug 21 21:54:10 PDT 2013
.travis.yml | 5 ++--
Makefile.am | 13 ++++++++++--
TODO | 2 -
man/systemd-analyze.xml | 2 -
src/journal/journal-send.c | 2 -
src/journal/journald-native.c | 12 +++++------
src/journal/test-catalog.c | 20 ++++++++++++++++--
src/journal/test-journal-interleaving.c | 4 +++
src/journal/test-journal-stream.c | 4 +++
src/journal/test-journal-verify.c | 4 +++
src/journal/test-journal.c | 4 +++
src/libsystemd-bus/bus-match.c | 26 ++++++++++++------------
src/shared/logs-show.c | 2 -
src/shared/macro.h | 2 -
src/shared/util.c | 34 --------------------------------
src/shared/util.h | 14 +++++++++++--
src/test/test-cgroup-util.c | 5 ++--
src/test/test-helper.h | 31 +++++++++++++++++++++++++++++
src/test/test-id128.c | 11 ++++++----
src/test/test-unit-file.c | 3 +-
src/test/test-unit-name.c | 5 +++-
src/test/test-util.c | 9 ++++++--
units/kmod-static-nodes.service.in | 2 -
23 files changed, 136 insertions(+), 80 deletions(-)
New commits:
commit df89481a35d4d7d58c7563f3082f67c218891375
Author: Kay Sievers <kay at vrfy.org>
Date: Wed Aug 21 22:16:44 2013 +0200
Optimize startswith() to macro
I guess it's easier and cleaner anyway to use simple static inline
functions instead of defines.
diff --git a/src/shared/util.c b/src/shared/util.c
index ca9c2eb..1dde8af 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -128,40 +128,6 @@ char* endswith(const char *s, const char *postfix) {
return (char*) s + sl - pl;
}
-char* startswith(const char *s, const char *prefix) {
- const char *a, *b;
-
- assert(s);
- assert(prefix);
-
- a = s, b = prefix;
- for (;;) {
- if (*b == 0)
- return (char*) a;
- if (*a != *b)
- return NULL;
-
- a++, b++;
- }
-}
-
-char* startswith_no_case(const char *s, const char *prefix) {
- const char *a, *b;
-
- assert(s);
- assert(prefix);
-
- a = s, b = prefix;
- for (;;) {
- if (*b == 0)
- return (char*) a;
- if (tolower(*a) != tolower(*b))
- return NULL;
-
- a++, b++;
- }
-}
-
bool first_word(const char *s, const char *word) {
size_t sl, wl;
diff --git a/src/shared/util.h b/src/shared/util.h
index 3be692e..63f4e3d 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -106,9 +106,19 @@ static inline bool isempty(const char *p) {
return !p || !p[0];
}
+static inline const char *startswith(const char *s, const char *prefix) {
+ if (strncmp(s, prefix, strlen(prefix)) == 0)
+ return s + strlen(prefix);
+ return NULL;
+}
+
+static inline const char *startswith_no_case(const char *s, const char *prefix) {
+ if (strncasecmp(s, prefix, strlen(prefix)) == 0)
+ return s + strlen(prefix);
+ return NULL;
+}
+
char *endswith(const char *s, const char *postfix) _pure_;
-char *startswith(const char *s, const char *prefix) _pure_;
-char *startswith_no_case(const char *s, const char *prefix) _pure_;
bool first_word(const char *s, const char *word) _pure_;
commit 2a0e0692565f0435657c93498e09cbb2d3517152
Author: Shawn Landden <shawnlandden at gmail.com>
Date: Wed Aug 21 18:20:55 2013 -0700
remove hasprefix(), use startswith()
diff --git a/TODO b/TODO
index 9bc14fd..3800ce4 100644
--- a/TODO
+++ b/TODO
@@ -96,8 +96,6 @@ Features:
* systemctl list-unit-files should list generated files (and probably with a new state "generated" for them, or so)
-* do we really need both hasprefix() and startswith()?
-
* journald: when we drop syslog messages because the syslog socket is
full, make sure to write how many messages are lost as first thing
to syslog when it works again.
diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
index fef66fc..d00e26f 100644
--- a/src/journal/journal-send.c
+++ b/src/journal/journal-send.c
@@ -245,7 +245,7 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
have_syslog_identifier = have_syslog_identifier ||
(c == (char *) iov[i].iov_base + 17 &&
- hasprefix(iov[i].iov_base, "SYSLOG_IDENTIFIER"));
+ startswith(iov[i].iov_base, "SYSLOG_IDENTIFIER"));
nl = memchr(iov[i].iov_base, '\n', iov[i].iov_len);
if (nl) {
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index 0f9af37..c50cf64 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -154,23 +154,23 @@ void server_process_native_message(
* of this entry for the rate limiting
* logic */
if (l == 10 &&
- hasprefix(p, "PRIORITY=") &&
+ startswith(p, "PRIORITY=") &&
p[9] >= '0' && p[9] <= '9')
priority = (priority & LOG_FACMASK) | (p[9] - '0');
else if (l == 17 &&
- hasprefix(p, "SYSLOG_FACILITY=") &&
+ startswith(p, "SYSLOG_FACILITY=") &&
p[16] >= '0' && p[16] <= '9')
priority = (priority & LOG_PRIMASK) | ((p[16] - '0') << 3);
else if (l == 18 &&
- hasprefix(p, "SYSLOG_FACILITY=") &&
+ startswith(p, "SYSLOG_FACILITY=") &&
p[16] >= '0' && p[16] <= '9' &&
p[17] >= '0' && p[17] <= '9')
priority = (priority & LOG_PRIMASK) | (((p[16] - '0')*10 + (p[17] - '0')) << 3);
else if (l >= 19 &&
- hasprefix(p, "SYSLOG_IDENTIFIER=")) {
+ startswith(p, "SYSLOG_IDENTIFIER=")) {
char *t;
t = strndup(p + 18, l - 18);
@@ -179,7 +179,7 @@ void server_process_native_message(
identifier = t;
}
} else if (l >= 8 &&
- hasprefix(p, "MESSAGE=")) {
+ startswith(p, "MESSAGE=")) {
char *t;
t = strndup(p + 8, l - 8);
@@ -189,7 +189,7 @@ void server_process_native_message(
}
} else if (l > strlen("OBJECT_PID=") &&
l < strlen("OBJECT_PID=") + DECIMAL_STR_MAX(pid_t) &&
- hasprefix(p, "OBJECT_PID=") &&
+ startswith(p, "OBJECT_PID=") &&
allow_object_pid(ucred)) {
char buf[DECIMAL_STR_MAX(pid_t)];
memcpy(buf, p + strlen("OBJECT_PID="), l - strlen("OBJECT_PID="));
diff --git a/src/libsystemd-bus/bus-match.c b/src/libsystemd-bus/bus-match.c
index 750acfe..1411167 100644
--- a/src/libsystemd-bus/bus-match.c
+++ b/src/libsystemd-bus/bus-match.c
@@ -555,22 +555,22 @@ static int bus_match_find_leaf(
enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n) {
assert(k);
- if (n == 4 && hasprefix(k, "type"))
+ if (n == 4 && startswith(k, "type"))
return BUS_MATCH_MESSAGE_TYPE;
- if (n == 6 && hasprefix(k, "sender"))
+ if (n == 6 && startswith(k, "sender"))
return BUS_MATCH_SENDER;
- if (n == 11 && hasprefix(k, "destination"))
+ if (n == 11 && startswith(k, "destination"))
return BUS_MATCH_DESTINATION;
- if (n == 9 && hasprefix(k, "interface"))
+ if (n == 9 && startswith(k, "interface"))
return BUS_MATCH_INTERFACE;
- if (n == 6 && hasprefix(k, "member"))
+ if (n == 6 && startswith(k, "member"))
return BUS_MATCH_MEMBER;
- if (n == 4 && hasprefix(k, "path"))
+ if (n == 4 && startswith(k, "path"))
return BUS_MATCH_PATH;
- if (n == 14 && hasprefix(k, "path_namespace"))
+ if (n == 14 && startswith(k, "path_namespace"))
return BUS_MATCH_PATH_NAMESPACE;
- if (n == 4 && hasprefix(k, "arg")) {
+ if (n == 4 && startswith(k, "arg")) {
int j;
j = undecchar(k[3]);
@@ -580,7 +580,7 @@ enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return BUS_MATCH_ARG + j;
}
- if (n == 5 && hasprefix(k, "arg")) {
+ if (n == 5 && startswith(k, "arg")) {
int a, b;
enum bus_match_node_type t;
@@ -596,7 +596,7 @@ enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return t;
}
- if (n == 8 && hasprefix(k, "arg") && hasprefix(k + 4, "path")) {
+ if (n == 8 && startswith(k, "arg") && startswith(k + 4, "path")) {
int j;
j = undecchar(k[3]);
@@ -606,7 +606,7 @@ enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return BUS_MATCH_ARG_PATH + j;
}
- if (n == 9 && hasprefix(k, "arg") && hasprefix(k + 5, "path")) {
+ if (n == 9 && startswith(k, "arg") && startswith(k + 5, "path")) {
enum bus_match_node_type t;
int a, b;
@@ -622,7 +622,7 @@ enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return t;
}
- if (n == 13 && hasprefix(k, "arg") && hasprefix(k + 4, "namespace")) {
+ if (n == 13 && startswith(k, "arg") && startswith(k + 4, "namespace")) {
int j;
j = undecchar(k[3]);
@@ -632,7 +632,7 @@ enum bus_match_node_type bus_match_node_type_from_string(const char *k, size_t n
return BUS_MATCH_ARG_NAMESPACE + j;
}
- if (n == 14 && hasprefix(k, "arg") && hasprefix(k + 5, "namespace")) {
+ if (n == 14 && startswith(k, "arg") && startswith(k + 5, "namespace")) {
enum bus_match_node_type t;
int a, b;
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index f0236ee..87633e7 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -536,7 +536,7 @@ static int output_export(
/* We already printed the boot id, from the data in
* the header, hence let's suppress it here */
if (length >= 9 &&
- hasprefix(data, "_BOOT_ID="))
+ startswith(data, "_BOOT_ID="))
continue;
if (!utf8_is_printable(data, length)) {
diff --git a/src/shared/macro.h b/src/shared/macro.h
index 0d3ff1c..d4f92b6 100644
--- a/src/shared/macro.h
+++ b/src/shared/macro.h
@@ -186,8 +186,6 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
#define char_array_0(x) x[sizeof(x)-1] = 0;
-#define hasprefix(s, prefix) (memcmp(s, prefix, strlen(prefix)) == 0)
-
#define IOVEC_SET_STRING(i, s) \
do { \
struct iovec *_i = &(i); \
commit 67c15b9a7ac016ac5c9b885756b2eaa7f44a0509
Author: Khem Raj <raj.khem at gmail.com>
Date: Wed Aug 21 20:35:44 2013 -0700
use CAP_MKNOD ConditionCapability
Fixes errors seen when booting VMs on QEMU like
systemd[1]: kmod-static-nodes.service: main process exited, code=exited, status=203/EXEC
systemd[1]: Failed to start Create list of required static device nodes for the current kernel.
systemd[1]: Unit kmod-static-nodes.service entered failed state.
Make sure that mknod capability is available
Signed-off-by: Khem Raj <raj.khem at gmail.com>
diff --git a/units/kmod-static-nodes.service.in b/units/kmod-static-nodes.service.in
index 98664ea..d8a8420 100644
--- a/units/kmod-static-nodes.service.in
+++ b/units/kmod-static-nodes.service.in
@@ -9,7 +9,7 @@
Description=Create list of required static device nodes for the current kernel
DefaultDependencies=no
Before=sysinit.target systemd-tmpfiles-setup-dev.service
-ConditionVirtualization=!container
+ConditionCapability=CAP_MKNOD
[Service]
Type=oneshot
commit d83c224da0aedcec9a432fe51fa27a3fed7be4b3
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Wed Aug 21 23:02:46 2013 -0400
man: typo
ohsix> ooh theres a typo in the example
diff --git a/man/systemd-analyze.xml b/man/systemd-analyze.xml
index a8adf87..6037709 100644
--- a/man/systemd-analyze.xml
+++ b/man/systemd-analyze.xml
@@ -285,7 +285,7 @@ $ eog avahi.svg</programlisting>
<para>This plots the dependencies between all known target units:</para>
- <programlisting>systemd-analyze dot --to-pattern='*.target' --from-patter='*.target' | dot -Tsvg > targets.svg
+ <programlisting>systemd-analyze dot --to-pattern='*.target' --from-pattern='*.target' | dot -Tsvg > targets.svg
$ eog targets.svg</programlisting>
commit 143bfdaf0b890fa7acadf02d1eafacaef1b696bd
Author: Holger Hans Peter Freyther <holger at moiji-mobile.com>
Date: Thu Jul 18 08:30:06 2013 +0200
test: Make testing work on systems without or old systemd
* Introduce a macro to conditionally execute tests. This avoids
skipping the entire test if some parts require systemd
* Skip the journal tests when no /etc/machine-id is present
* Change test-catalog to load the catalog from the source directory
of systemd.
* /proc/PID/comm got introduced in v2.6.33 but travis is still
using v2.6.32.
* Enable make check and make distcheck on the travis build
* Use -D"CATALOG_DIR=STR($(abs_top_srcdir)/catalog)" as a STRINGIY
would result in the path '/home/ich/source/linux' to be expanded
to '/home/ich/source/1' as linux is defined to 1.
diff --git a/.travis.yml b/.travis.yml
index 42433fd..7e5251c 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 fdfdd65..fd38e82 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 987867f..5db5bed 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 069d297..2b21523 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 6b32b25..8e1d08d 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 6b7414a..0540074 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 534fd28..190c426 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 295bb02..16bf968 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 0000000..92864ed
--- /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 2ed8e29..7b92758 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 2075e86..dc6bc55 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 6776ef0..c17692b 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 875aeab..dd7768d 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);
More information about the systemd-commits
mailing list