mirror of
https://github.com/systemd/systemd
synced 2026-03-30 19:54:51 +02:00
Compare commits
No commits in common. "6f47ab1bb1c7dc2d6917d0bcb30d5da9af85dc77" and "de3ef2524e9f4ebcd2cee2c70daa78189dcfd339" have entirely different histories.
6f47ab1bb1
...
de3ef2524e
6
.github/workflows/build_test.sh
vendored
6
.github/workflows/build_test.sh
vendored
@ -72,17 +72,11 @@ if [[ "$COMPILER" == clang ]]; then
|
|||||||
CC="clang-$COMPILER_VERSION"
|
CC="clang-$COMPILER_VERSION"
|
||||||
CXX="clang++-$COMPILER_VERSION"
|
CXX="clang++-$COMPILER_VERSION"
|
||||||
AR="llvm-ar-$COMPILER_VERSION"
|
AR="llvm-ar-$COMPILER_VERSION"
|
||||||
|
|
||||||
# ATTOW llvm-11 got into focal-updates, which conflicts with llvm-11
|
|
||||||
# provided by the apt.llvm.org repositories. Let's use the system
|
|
||||||
# llvm package if available in such cases to avoid that.
|
|
||||||
if ! apt show --quiet "llvm-$COMPILER_VERSION" &>/dev/null; then
|
|
||||||
# Latest LLVM stack deb packages provided by https://apt.llvm.org/
|
# Latest LLVM stack deb packages provided by https://apt.llvm.org/
|
||||||
# Following snippet was borrowed from https://apt.llvm.org/llvm.sh
|
# Following snippet was borrowed from https://apt.llvm.org/llvm.sh
|
||||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
|
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
|
||||||
add-apt-repository -y "deb http://apt.llvm.org/$RELEASE/ llvm-toolchain-$RELEASE-$COMPILER_VERSION main"
|
add-apt-repository -y "deb http://apt.llvm.org/$RELEASE/ llvm-toolchain-$RELEASE-$COMPILER_VERSION main"
|
||||||
PACKAGES+=("clang-$COMPILER_VERSION" "lldb-$COMPILER_VERSION" "lld-$COMPILER_VERSION" "clangd-$COMPILER_VERSION")
|
PACKAGES+=("clang-$COMPILER_VERSION" "lldb-$COMPILER_VERSION" "lld-$COMPILER_VERSION" "clangd-$COMPILER_VERSION")
|
||||||
fi
|
|
||||||
elif [[ "$COMPILER" == gcc ]]; then
|
elif [[ "$COMPILER" == gcc ]]; then
|
||||||
CC="gcc-$COMPILER_VERSION"
|
CC="gcc-$COMPILER_VERSION"
|
||||||
CXX="g++-$COMPILER_VERSION"
|
CXX="g++-$COMPILER_VERSION"
|
||||||
|
|||||||
@ -354,10 +354,48 @@ static void test_introspect_on_path(void) {
|
|||||||
assert_se(strv_extend(&expected, "/org/freedesktop/LogControl1") >= 0);
|
assert_se(strv_extend(&expected, "/org/freedesktop/LogControl1") >= 0);
|
||||||
assert_se(strv_extend(&expected, "/org/freedesktop/network1") >= 0);
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1") >= 0);
|
||||||
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network") >= 0);
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network") >= 0);
|
||||||
for (unsigned i = 0; i <= 20; i++) {
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/0") >= 0);
|
||||||
assert_se(strv_extendf(&expected, "/org/freedesktop/network1/network/%u", i) >= 0);
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/0/hoge") >= 0);
|
||||||
assert_se(strv_extendf(&expected, "/org/freedesktop/network1/network/%u/hoge", i) >= 0);
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/1") >= 0);
|
||||||
}
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/1/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/2") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/2/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/3") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/3/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/4") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/4/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/5") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/5/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/6") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/6/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/7") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/7/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/8") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/8/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/9") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/9/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/10") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/10/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/11") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/11/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/12") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/12/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/13") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/13/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/14") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/14/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/15") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/15/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/16") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/16/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/17") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/17/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/18") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/18/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/19") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/19/hoge") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/20") >= 0);
|
||||||
|
assert_se(strv_extend(&expected, "/org/freedesktop/network1/network/20/hoge") >= 0);
|
||||||
|
|
||||||
strv_sort(expected);
|
strv_sort(expected);
|
||||||
assert_se(strv_equal(l, expected));
|
assert_se(strv_equal(l, expected));
|
||||||
|
|||||||
@ -121,7 +121,7 @@ static DHCPMessage *create_message(uint8_t *options, uint16_t optlen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void test_ignore_opts(uint8_t *descoption, int *descpos, int *desclen) {
|
static void test_ignore_opts(uint8_t *descoption, int *descpos, int *desclen) {
|
||||||
assert_se(*descpos >= 0);
|
assert(*descpos >= 0);
|
||||||
|
|
||||||
while (*descpos < *desclen) {
|
while (*descpos < *desclen) {
|
||||||
switch(descoption[*descpos]) {
|
switch(descoption[*descpos]) {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ static void test_one_address(sd_bus *b,
|
|||||||
r = bus_set_address_system_remote(b, host);
|
r = bus_set_address_system_remote(b, host);
|
||||||
log_info("\"%s\" → %d, \"%s\"", host, r, strna(r >= 0 ? b->address : NULL));
|
log_info("\"%s\" → %d, \"%s\"", host, r, strna(r >= 0 ? b->address : NULL));
|
||||||
if (result < 0 || expected) {
|
if (result < 0 || expected) {
|
||||||
assert_se(r == result);
|
assert(r == result);
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
assert_se(streq(b->address, expected));
|
assert_se(streq(b->address, expected));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -219,19 +219,6 @@ static int enumerator2_callback(sd_bus *bus, const char *path, void *userdata, c
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int enumerator3_callback(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
|
|
||||||
_cleanup_strv_free_ char **v = NULL;
|
|
||||||
|
|
||||||
if (!object_path_startswith("/value/b", path))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < 30; i++)
|
|
||||||
assert_se(strv_extendf(&v, "/value/b/%u", i) >= 0);
|
|
||||||
|
|
||||||
*nodes = TAKE_PTR(v);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *server(void *p) {
|
static void *server(void *p) {
|
||||||
struct context *c = p;
|
struct context *c = p;
|
||||||
sd_bus *bus = NULL;
|
sd_bus *bus = NULL;
|
||||||
@ -251,7 +238,6 @@ static void *server(void *p) {
|
|||||||
assert_se(sd_bus_add_fallback_vtable(bus, NULL, "/value", "org.freedesktop.systemd.ValueTest", vtable2, NULL, UINT_TO_PTR(20)) >= 0);
|
assert_se(sd_bus_add_fallback_vtable(bus, NULL, "/value", "org.freedesktop.systemd.ValueTest", vtable2, NULL, UINT_TO_PTR(20)) >= 0);
|
||||||
assert_se(sd_bus_add_node_enumerator(bus, NULL, "/value", enumerator_callback, NULL) >= 0);
|
assert_se(sd_bus_add_node_enumerator(bus, NULL, "/value", enumerator_callback, NULL) >= 0);
|
||||||
assert_se(sd_bus_add_node_enumerator(bus, NULL, "/value/a", enumerator2_callback, NULL) >= 0);
|
assert_se(sd_bus_add_node_enumerator(bus, NULL, "/value/a", enumerator2_callback, NULL) >= 0);
|
||||||
assert_se(sd_bus_add_node_enumerator(bus, NULL, "/value/b", enumerator3_callback, NULL) >= 0);
|
|
||||||
assert_se(sd_bus_add_object_manager(bus, NULL, "/value") >= 0);
|
assert_se(sd_bus_add_object_manager(bus, NULL, "/value") >= 0);
|
||||||
assert_se(sd_bus_add_object_manager(bus, NULL, "/value/a") >= 0);
|
assert_se(sd_bus_add_object_manager(bus, NULL, "/value/a") >= 0);
|
||||||
|
|
||||||
@ -294,7 +280,6 @@ static int client(struct context *c) {
|
|||||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||||
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
|
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
|
||||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
_cleanup_strv_free_ char **lines = NULL;
|
|
||||||
const char *s;
|
const char *s;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -415,30 +400,6 @@ static int client(struct context *c) {
|
|||||||
assert_se(r >= 0);
|
assert_se(r >= 0);
|
||||||
fputs(s, stdout);
|
fputs(s, stdout);
|
||||||
|
|
||||||
assert_se(lines = strv_split_newlines(s));
|
|
||||||
assert_se(strv_contains(lines, " <node name=\"x\"/>"));
|
|
||||||
assert_se(strv_contains(lines, " <node name=\"y\"/>"));
|
|
||||||
assert_se(strv_contains(lines, " <node name=\"z\"/>"));
|
|
||||||
lines = strv_free(lines);
|
|
||||||
|
|
||||||
reply = sd_bus_message_unref(reply);
|
|
||||||
|
|
||||||
r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value/b", "org.freedesktop.DBus.Introspectable", "Introspect", &error, &reply, NULL);
|
|
||||||
assert_se(r >= 0);
|
|
||||||
|
|
||||||
r = sd_bus_message_read(reply, "s", &s);
|
|
||||||
assert_se(r >= 0);
|
|
||||||
fputs(s, stdout);
|
|
||||||
|
|
||||||
assert_se(lines = strv_split_newlines(s));
|
|
||||||
for (unsigned i = 0; i < 30; i++) {
|
|
||||||
_cleanup_free_ char *n = NULL;
|
|
||||||
|
|
||||||
assert_se(asprintf(&n, " <node name=\"%u\"/>", i) >= 0);
|
|
||||||
assert_se(strv_contains(lines, n));
|
|
||||||
}
|
|
||||||
lines = strv_free(lines);
|
|
||||||
|
|
||||||
reply = sd_bus_message_unref(reply);
|
reply = sd_bus_message_unref(reply);
|
||||||
|
|
||||||
r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.DBus.Properties", "GetAll", &error, &reply, "s", NULL);
|
r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.DBus.Properties", "GetAll", &error, &reply, "s", NULL);
|
||||||
|
|||||||
@ -404,8 +404,8 @@ struct inotify_context {
|
|||||||
static void maybe_exit(sd_event_source *s, struct inotify_context *c) {
|
static void maybe_exit(sd_event_source *s, struct inotify_context *c) {
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
assert_se(s);
|
assert(s);
|
||||||
assert_se(c);
|
assert(c);
|
||||||
|
|
||||||
if (!c->delete_self_handler_called)
|
if (!c->delete_self_handler_called)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -118,7 +118,7 @@ _unused_ static void test_decompress_startswith(const char *compression,
|
|||||||
compressed = compressed2 = malloc(BUFSIZE_2);
|
compressed = compressed2 = malloc(BUFSIZE_2);
|
||||||
assert_se(compressed2);
|
assert_se(compressed2);
|
||||||
r = compress(data, data_len, compressed, BUFSIZE_2, &csize);
|
r = compress(data, data_len, compressed, BUFSIZE_2, &csize);
|
||||||
assert_se(r == 0);
|
assert(r == 0);
|
||||||
}
|
}
|
||||||
assert_se(r == 0);
|
assert_se(r == 0);
|
||||||
|
|
||||||
|
|||||||
@ -287,7 +287,7 @@ struct test_async_object {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct test_async_object *test_async_object_free(struct test_async_object *t) {
|
static struct test_async_object *test_async_object_free(struct test_async_object *t) {
|
||||||
assert_se(t);
|
assert(t);
|
||||||
|
|
||||||
free(t->ifname);
|
free(t->ifname);
|
||||||
return mfree(t);
|
return mfree(t);
|
||||||
@ -315,7 +315,7 @@ static int link_handler2(sd_netlink *rtnl, sd_netlink_message *m, void *userdata
|
|||||||
static void test_async_object_destroy(void *userdata) {
|
static void test_async_object_destroy(void *userdata) {
|
||||||
struct test_async_object *t = userdata;
|
struct test_async_object *t = userdata;
|
||||||
|
|
||||||
assert_se(userdata);
|
assert(userdata);
|
||||||
|
|
||||||
log_info("%s: n_ref=%u", __func__, t->n_ref);
|
log_info("%s: n_ref=%u", __func__, t->n_ref);
|
||||||
test_async_object_unref(t);
|
test_async_object_unref(t);
|
||||||
@ -593,8 +593,8 @@ static int genl_ctrl_match_callback(sd_netlink *genl, sd_netlink_message *m, voi
|
|||||||
uint16_t id;
|
uint16_t id;
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
|
|
||||||
assert_se(genl);
|
assert(genl);
|
||||||
assert_se(m);
|
assert(m);
|
||||||
|
|
||||||
assert_se(sd_genl_message_get_family_name(genl, m, &name) >= 0);
|
assert_se(sd_genl_message_get_family_name(genl, m, &name) >= 0);
|
||||||
assert_se(streq(name, CTRL_GENL_NAME));
|
assert_se(streq(name, CTRL_GENL_NAME));
|
||||||
|
|||||||
@ -52,7 +52,7 @@ static void test_oomd_cgroup_kill(void) {
|
|||||||
/* Create another cgroup below this one for the pids we forked off. We need this to be managed
|
/* Create another cgroup below this one for the pids we forked off. We need this to be managed
|
||||||
* by the test so that pid1 doesn't delete it before we can read the xattrs. */
|
* by the test so that pid1 doesn't delete it before we can read the xattrs. */
|
||||||
cgroup = path_join(cgroup_root, "oomdkilltest");
|
cgroup = path_join(cgroup_root, "oomdkilltest");
|
||||||
assert_se(cgroup);
|
assert(cgroup);
|
||||||
assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, cgroup) >= 0);
|
assert_se(cg_create(SYSTEMD_CGROUP_CONTROLLER, cgroup) >= 0);
|
||||||
|
|
||||||
/* If we don't have permissions to set xattrs we're likely in a userns or missing capabilities */
|
/* If we don't have permissions to set xattrs we're likely in a userns or missing capabilities */
|
||||||
|
|||||||
@ -105,14 +105,14 @@ static void test_parse_etc_hosts(void) {
|
|||||||
assert_se(address_equal_4(bn->addresses[2], inet_addr("1.2.3.11")));
|
assert_se(address_equal_4(bn->addresses[2], inet_addr("1.2.3.11")));
|
||||||
assert_se(address_equal_4(bn->addresses[3], inet_addr("1.2.3.12")));
|
assert_se(address_equal_4(bn->addresses[3], inet_addr("1.2.3.12")));
|
||||||
|
|
||||||
assert_se(!hashmap_get(hosts.by_name, "within.comment"));
|
assert(!hashmap_get(hosts.by_name, "within.comment"));
|
||||||
assert_se(!hashmap_get(hosts.by_name, "within.comment2"));
|
assert(!hashmap_get(hosts.by_name, "within.comment2"));
|
||||||
assert_se(!hashmap_get(hosts.by_name, "within.comment3"));
|
assert(!hashmap_get(hosts.by_name, "within.comment3"));
|
||||||
assert_se(!hashmap_get(hosts.by_name, "#"));
|
assert(!hashmap_get(hosts.by_name, "#"));
|
||||||
|
|
||||||
assert_se(!hashmap_get(hosts.by_name, "short.address"));
|
assert(!hashmap_get(hosts.by_name, "short.address"));
|
||||||
assert_se(!hashmap_get(hosts.by_name, "long.address"));
|
assert(!hashmap_get(hosts.by_name, "long.address"));
|
||||||
assert_se(!hashmap_get(hosts.by_name, "multi.colon"));
|
assert(!hashmap_get(hosts.by_name, "multi.colon"));
|
||||||
assert_se(!set_contains(hosts.no_address, "short.address"));
|
assert_se(!set_contains(hosts.no_address, "short.address"));
|
||||||
assert_se(!set_contains(hosts.no_address, "long.address"));
|
assert_se(!set_contains(hosts.no_address, "long.address"));
|
||||||
assert_se(!set_contains(hosts.no_address, "multi.colon"));
|
assert_se(!set_contains(hosts.no_address, "multi.colon"));
|
||||||
|
|||||||
@ -76,11 +76,11 @@ int main(int argc, char* argv[]) {
|
|||||||
test_setup_logging(LOG_DEBUG);
|
test_setup_logging(LOG_DEBUG);
|
||||||
|
|
||||||
p = test_acpi_fpdt();
|
p = test_acpi_fpdt();
|
||||||
assert_se(p >= 0);
|
assert(p >= 0);
|
||||||
q = test_efi_loader();
|
q = test_efi_loader();
|
||||||
assert_se(q >= 0);
|
assert(q >= 0);
|
||||||
r = test_boot_timestamps();
|
r = test_boot_timestamps();
|
||||||
assert_se(r >= 0);
|
assert(r >= 0);
|
||||||
|
|
||||||
if (p == 0 && q == 0 && r == 0)
|
if (p == 0 && q == 0 && r == 0)
|
||||||
return log_tests_skipped("access to firmware variables not possible");
|
return log_tests_skipped("access to firmware variables not possible");
|
||||||
|
|||||||
@ -56,10 +56,10 @@ int main(int argc, char *argv[]) {
|
|||||||
assert_se(runtime_dir = setup_fake_runtime_dir());
|
assert_se(runtime_dir = setup_fake_runtime_dir());
|
||||||
|
|
||||||
r = bpf_program_new(BPF_PROG_TYPE_CGROUP_SKB, &p);
|
r = bpf_program_new(BPF_PROG_TYPE_CGROUP_SKB, &p);
|
||||||
assert_se(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
r = bpf_program_add_instructions(p, exit_insn, ELEMENTSOF(exit_insn));
|
r = bpf_program_add_instructions(p, exit_insn, ELEMENTSOF(exit_insn));
|
||||||
assert_se(r == 0);
|
assert(r == 0);
|
||||||
|
|
||||||
if (getuid() != 0)
|
if (getuid() != 0)
|
||||||
return log_tests_skipped("not running as root");
|
return log_tests_skipped("not running as root");
|
||||||
@ -76,7 +76,7 @@ int main(int argc, char *argv[]) {
|
|||||||
log_notice("BPF firewalling (though without BPF_F_ALLOW_MULTI) supported. Good.");
|
log_notice("BPF firewalling (though without BPF_F_ALLOW_MULTI) supported. Good.");
|
||||||
|
|
||||||
r = bpf_program_load_kernel(p, log_buf, ELEMENTSOF(log_buf));
|
r = bpf_program_load_kernel(p, log_buf, ELEMENTSOF(log_buf));
|
||||||
assert_se(r >= 0);
|
assert(r >= 0);
|
||||||
|
|
||||||
if (test_custom_filter) {
|
if (test_custom_filter) {
|
||||||
zero(attr);
|
zero(attr);
|
||||||
@ -158,8 +158,8 @@ int main(int argc, char *argv[]) {
|
|||||||
return log_tests_skipped("Kernel doesn't support the necessary bpf bits (masked out via seccomp?)");
|
return log_tests_skipped("Kernel doesn't support the necessary bpf bits (masked out via seccomp?)");
|
||||||
assert_se(r >= 0);
|
assert_se(r >= 0);
|
||||||
|
|
||||||
assert_se(u->ip_bpf_ingress);
|
assert(u->ip_bpf_ingress);
|
||||||
assert_se(u->ip_bpf_egress);
|
assert(u->ip_bpf_egress);
|
||||||
|
|
||||||
r = bpf_program_load_kernel(u->ip_bpf_ingress, log_buf, ELEMENTSOF(log_buf));
|
r = bpf_program_load_kernel(u->ip_bpf_ingress, log_buf, ELEMENTSOF(log_buf));
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ int main(int argc, char *argv[]) {
|
|||||||
log_notice("%s", log_buf);
|
log_notice("%s", log_buf);
|
||||||
log_notice("-------");
|
log_notice("-------");
|
||||||
|
|
||||||
assert_se(r >= 0);
|
assert(r >= 0);
|
||||||
|
|
||||||
r = bpf_program_load_kernel(u->ip_bpf_egress, log_buf, ELEMENTSOF(log_buf));
|
r = bpf_program_load_kernel(u->ip_bpf_egress, log_buf, ELEMENTSOF(log_buf));
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ int main(int argc, char *argv[]) {
|
|||||||
log_notice("%s", log_buf);
|
log_notice("%s", log_buf);
|
||||||
log_notice("-------");
|
log_notice("-------");
|
||||||
|
|
||||||
assert_se(r >= 0);
|
assert(r >= 0);
|
||||||
|
|
||||||
assert_se(unit_start(u) >= 0);
|
assert_se(unit_start(u) >= 0);
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,7 @@ static void test_destroy_callback(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r = sd_bus_request_name_async(bus, &slot, "org.freedesktop.systemd.test-bus-util", 0, callback, &n_called);
|
r = sd_bus_request_name_async(bus, &slot, "org.freedesktop.systemd.test-bus-util", 0, callback, &n_called);
|
||||||
assert_se(r == 1);
|
assert(r == 1);
|
||||||
|
|
||||||
assert_se(sd_bus_slot_get_destroy_callback(slot, NULL) == 0);
|
assert_se(sd_bus_slot_get_destroy_callback(slot, NULL) == 0);
|
||||||
assert_se(sd_bus_slot_get_destroy_callback(slot, &t) == 0);
|
assert_se(sd_bus_slot_get_destroy_callback(slot, &t) == 0);
|
||||||
@ -41,9 +41,9 @@ static void test_destroy_callback(void) {
|
|||||||
assert_se(t == destroy_callback);
|
assert_se(t == destroy_callback);
|
||||||
|
|
||||||
/* Force cleanup so we can look at n_called */
|
/* Force cleanup so we can look at n_called */
|
||||||
assert_se(n_called == 0);
|
assert(n_called == 0);
|
||||||
sd_bus_slot_unref(slot);
|
sd_bus_slot_unref(slot);
|
||||||
assert_se(n_called == 1);
|
assert(n_called == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|||||||
@ -58,7 +58,7 @@ static void _test_next(int line, const char *input, const char *new_tz, usec_t a
|
|||||||
if (expect != USEC_INFINITY)
|
if (expect != USEC_INFINITY)
|
||||||
assert_se(r >= 0 && u == expect);
|
assert_se(r >= 0 && u == expect);
|
||||||
else
|
else
|
||||||
assert_se(r == -ENOENT);
|
assert(r == -ENOENT);
|
||||||
|
|
||||||
calendar_spec_free(c);
|
calendar_spec_free(c);
|
||||||
|
|
||||||
|
|||||||
@ -194,7 +194,7 @@ static void test_update_inherited_set(void) {
|
|||||||
|
|
||||||
assert_se(!capability_update_inherited_set(caps, set));
|
assert_se(!capability_update_inherited_set(caps, set));
|
||||||
assert_se(!cap_get_flag(caps, CAP_CHOWN, CAP_INHERITABLE, &fv));
|
assert_se(!cap_get_flag(caps, CAP_CHOWN, CAP_INHERITABLE, &fv));
|
||||||
assert_se(fv == CAP_SET);
|
assert(fv == CAP_SET);
|
||||||
|
|
||||||
cap_free(caps);
|
cap_free(caps);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -395,12 +395,12 @@ static void test_cg_get_keyed_attribute(void) {
|
|||||||
|
|
||||||
assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "no_such_attr"), vals3) == -ENXIO);
|
assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "no_such_attr"), vals3) == -ENXIO);
|
||||||
assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "no_such_attr"), vals3) == 1);
|
assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "no_such_attr"), vals3) == 1);
|
||||||
assert_se(vals3[0] && !vals3[1]);
|
assert(vals3[0] && !vals3[1]);
|
||||||
free(vals3[0]);
|
free(vals3[0]);
|
||||||
|
|
||||||
assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "usage_usec"), vals3) == -ENXIO);
|
assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "usage_usec"), vals3) == -ENXIO);
|
||||||
assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "usage_usec"), vals3) == 1);
|
assert_se(cg_get_keyed_attribute_graceful("cpu", "/init.scope", "cpu.stat", STRV_MAKE("usage_usec", "usage_usec"), vals3) == 1);
|
||||||
assert_se(vals3[0] && !vals3[1]);
|
assert(vals3[0] && !vals3[1]);
|
||||||
free(vals3[0]);
|
free(vals3[0]);
|
||||||
|
|
||||||
assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat",
|
assert_se(cg_get_keyed_attribute("cpu", "/init.scope", "cpu.stat",
|
||||||
|
|||||||
@ -34,8 +34,8 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
|
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
assert_se(argc >= 0);
|
assert(argc >= 0);
|
||||||
assert_se(argv);
|
assert(argv);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "", options, NULL)) >= 0)
|
while ((c = getopt_long(argc, argv, "", options, NULL)) >= 0)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -103,9 +103,9 @@ static int run(int argc, char **argv) {
|
|||||||
else {
|
else {
|
||||||
log_info("→ %s", p);
|
log_info("→ %s", p);
|
||||||
if (arg_open)
|
if (arg_open)
|
||||||
assert_se(fd >= 0);
|
assert(fd >= 0);
|
||||||
else
|
else
|
||||||
assert_se(fd == -1);
|
assert(fd == -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -689,12 +689,12 @@ static void test_condition_test_group(void) {
|
|||||||
free(gid);
|
free(gid);
|
||||||
|
|
||||||
ngroups_max = sysconf(_SC_NGROUPS_MAX);
|
ngroups_max = sysconf(_SC_NGROUPS_MAX);
|
||||||
assert_se(ngroups_max > 0);
|
assert(ngroups_max > 0);
|
||||||
|
|
||||||
gids = newa(gid_t, ngroups_max);
|
gids = newa(gid_t, ngroups_max);
|
||||||
|
|
||||||
ngroups = getgroups(ngroups_max, gids);
|
ngroups = getgroups(ngroups_max, gids);
|
||||||
assert_se(ngroups >= 0);
|
assert(ngroups >= 0);
|
||||||
|
|
||||||
max_gid = getgid();
|
max_gid = getgid();
|
||||||
for (i = 0; i < ngroups; i++) {
|
for (i = 0; i < ngroups; i++) {
|
||||||
|
|||||||
@ -256,7 +256,7 @@ static void test_cpu_set_to_from_dbus(void) {
|
|||||||
|
|
||||||
assert_se(allocated <= sizeof expected);
|
assert_se(allocated <= sizeof expected);
|
||||||
assert_se(allocated >= DIV_ROUND_UP(201u, 8u)); /* We need at least 201 bits for our mask */
|
assert_se(allocated >= DIV_ROUND_UP(201u, 8u)); /* We need at least 201 bits for our mask */
|
||||||
assert_se(memcmp(array, expected, allocated) == 0);
|
assert(memcmp(array, expected, allocated) == 0);
|
||||||
|
|
||||||
assert_se(cpu_set_from_dbus(array, allocated, &c2) == 0);
|
assert_se(cpu_set_from_dbus(array, allocated, &c2) == 0);
|
||||||
assert_se(c2.set);
|
assert_se(c2.set);
|
||||||
@ -268,7 +268,7 @@ static void test_cpus_in_affinity_mask(void) {
|
|||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = cpus_in_affinity_mask();
|
r = cpus_in_affinity_mask();
|
||||||
assert_se(r > 0);
|
assert(r > 0);
|
||||||
log_info("cpus_in_affinity_mask: %d", r);
|
log_info("cpus_in_affinity_mask: %d", r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,8 +58,8 @@ static void test_xescape_full(bool eight_bits) {
|
|||||||
log_info("%02d: <%s>", i, q);
|
log_info("%02d: <%s>", i, q);
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
assert_se(endswith(q, "."));
|
assert_se(endswith(q, "."));
|
||||||
assert_se(strlen(q) <= i);
|
assert(strlen(q) <= i);
|
||||||
assert_se(strlen(q) + 3 >= strlen(t));
|
assert(strlen(q) + 3 >= strlen(t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,22 +26,22 @@ static void *ignore_stdout_args[] = { &here, &here2, &here3 };
|
|||||||
|
|
||||||
/* noop handlers, just check that arguments are passed correctly */
|
/* noop handlers, just check that arguments are passed correctly */
|
||||||
static int ignore_stdout_func(int fd, void *arg) {
|
static int ignore_stdout_func(int fd, void *arg) {
|
||||||
assert_se(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert_se(arg == &here);
|
assert(arg == &here);
|
||||||
safe_close(fd);
|
safe_close(fd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int ignore_stdout_func2(int fd, void *arg) {
|
static int ignore_stdout_func2(int fd, void *arg) {
|
||||||
assert_se(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert_se(arg == &here2);
|
assert(arg == &here2);
|
||||||
safe_close(fd);
|
safe_close(fd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int ignore_stdout_func3(int fd, void *arg) {
|
static int ignore_stdout_func3(int fd, void *arg) {
|
||||||
assert_se(fd >= 0);
|
assert(fd >= 0);
|
||||||
assert_se(arg == &here3);
|
assert(arg == &here3);
|
||||||
safe_close(fd);
|
safe_close(fd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -174,7 +174,7 @@ static bool check_user_has_group_with_same_name(const char *name) {
|
|||||||
struct passwd *p;
|
struct passwd *p;
|
||||||
struct group *g;
|
struct group *g;
|
||||||
|
|
||||||
assert_se(name);
|
assert(name);
|
||||||
|
|
||||||
p = getpwnam(name);
|
p = getpwnam(name);
|
||||||
if (!p ||
|
if (!p ||
|
||||||
@ -510,8 +510,8 @@ static int on_spawn_io(sd_event_source *s, int fd, uint32_t revents, void *userd
|
|||||||
char buf[4096];
|
char buf[4096];
|
||||||
ssize_t l;
|
ssize_t l;
|
||||||
|
|
||||||
assert_se(s);
|
assert(s);
|
||||||
assert_se(fd >= 0);
|
assert(fd >= 0);
|
||||||
|
|
||||||
l = read(fd, buf, sizeof(buf) - 1);
|
l = read(fd, buf, sizeof(buf) - 1);
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
@ -538,7 +538,7 @@ reenable:
|
|||||||
static int on_spawn_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
|
static int on_spawn_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||||
pid_t *pid = userdata;
|
pid_t *pid = userdata;
|
||||||
|
|
||||||
assert_se(pid);
|
assert(pid);
|
||||||
|
|
||||||
(void) kill(*pid, SIGKILL);
|
(void) kill(*pid, SIGKILL);
|
||||||
|
|
||||||
@ -548,7 +548,7 @@ static int on_spawn_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
|
|||||||
static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
|
static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
|
||||||
int ret = -EIO;
|
int ret = -EIO;
|
||||||
|
|
||||||
assert_se(si);
|
assert(si);
|
||||||
|
|
||||||
if (si->si_code == CLD_EXITED)
|
if (si->si_code == CLD_EXITED)
|
||||||
ret = si->si_status;
|
ret = si->si_status;
|
||||||
@ -568,8 +568,8 @@ static int find_libraries(const char *exec, char ***ret) {
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert_se(exec);
|
assert(exec);
|
||||||
assert_se(ret);
|
assert(ret);
|
||||||
|
|
||||||
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
|
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, -1) >= 0);
|
||||||
|
|
||||||
@ -653,7 +653,7 @@ static void test_exec_mount_apivfs(Manager *m) {
|
|||||||
_cleanup_strv_free_ char **libraries = NULL, **libraries_test = NULL;
|
_cleanup_strv_free_ char **libraries = NULL, **libraries_test = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert_se(user_runtime_unit_dir);
|
assert(user_runtime_unit_dir);
|
||||||
|
|
||||||
r = find_executable("touch", &fullpath_touch);
|
r = find_executable("touch", &fullpath_touch);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
|||||||
@ -241,7 +241,7 @@ static void test_merge_env_file(void) {
|
|||||||
"zzzz=${foobar:-${nothing}}\n"
|
"zzzz=${foobar:-${nothing}}\n"
|
||||||
"zzzzz=${nothing:+${nothing}}\n"
|
"zzzzz=${nothing:+${nothing}}\n"
|
||||||
, WRITE_STRING_FILE_AVOID_NEWLINE);
|
, WRITE_STRING_FILE_AVOID_NEWLINE);
|
||||||
assert_se(r >= 0);
|
assert(r >= 0);
|
||||||
|
|
||||||
r = merge_env_file(&a, NULL, t);
|
r = merge_env_file(&a, NULL, t);
|
||||||
assert_se(r >= 0);
|
assert_se(r >= 0);
|
||||||
@ -305,7 +305,7 @@ static void test_merge_env_file_invalid(void) {
|
|||||||
"#\n"
|
"#\n"
|
||||||
"\n\n" /* empty line */
|
"\n\n" /* empty line */
|
||||||
, WRITE_STRING_FILE_AVOID_NEWLINE);
|
, WRITE_STRING_FILE_AVOID_NEWLINE);
|
||||||
assert_se(r >= 0);
|
assert(r >= 0);
|
||||||
|
|
||||||
r = merge_env_file(&a, NULL, t);
|
r = merge_env_file(&a, NULL, t);
|
||||||
assert_se(r >= 0);
|
assert_se(r >= 0);
|
||||||
|
|||||||
@ -47,8 +47,8 @@ static void test_v6(FirewallContext *ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static union in_addr_union *parse_addr(const char *str, union in_addr_union *u) {
|
static union in_addr_union *parse_addr(const char *str, union in_addr_union *u) {
|
||||||
assert_se(str);
|
assert(str);
|
||||||
assert_se(u);
|
assert(u);
|
||||||
assert_se(in_addr_from_string(AF_INET, str, u) >= 0);
|
assert_se(in_addr_from_string(AF_INET, str, u) >= 0);
|
||||||
return u;
|
return u;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ static bool test_v4(FirewallContext *ctx) {
|
|||||||
if (ignore)
|
if (ignore)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
assert_se(r >= 0);
|
assert(r >= 0);
|
||||||
|
|
||||||
assert_se(fw_add_masquerade(&ctx, true, AF_INET, parse_addr("10.0.2.0", &u), 28) >= 0);
|
assert_se(fw_add_masquerade(&ctx, true, AF_INET, parse_addr("10.0.2.0", &u), 28) >= 0);
|
||||||
assert_se(fw_add_masquerade(&ctx, false, AF_INET, parse_addr("10.0.2.0", &u), 28) >= 0);
|
assert_se(fw_add_masquerade(&ctx, false, AF_INET, parse_addr("10.0.2.0", &u), 28) >= 0);
|
||||||
|
|||||||
@ -486,7 +486,7 @@ static void test_hashmap_foreach_key(void) {
|
|||||||
hashmap_put(m, key, (void*) (const char*) "my dummy val");
|
hashmap_put(m, key, (void*) (const char*) "my dummy val");
|
||||||
|
|
||||||
HASHMAP_FOREACH_KEY(s, key, m) {
|
HASHMAP_FOREACH_KEY(s, key, m) {
|
||||||
assert_se(s);
|
assert(s);
|
||||||
if (!key_found[0] && streq(key, "key 1"))
|
if (!key_found[0] && streq(key, "key 1"))
|
||||||
key_found[0] = true;
|
key_found[0] = true;
|
||||||
else if (!key_found[1] && streq(key, "key 2"))
|
else if (!key_found[1] && streq(key, "key 2"))
|
||||||
|
|||||||
@ -15,7 +15,7 @@ static void test_read_etc_hostname(void) {
|
|||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
fd = mkostemp_safe(path);
|
fd = mkostemp_safe(path);
|
||||||
assert_se(fd > 0);
|
assert(fd > 0);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
/* simple hostname */
|
/* simple hostname */
|
||||||
|
|||||||
@ -286,7 +286,7 @@ static void test_linked_units(const char *root) {
|
|||||||
else
|
else
|
||||||
assert_not_reached();
|
assert_not_reached();
|
||||||
}
|
}
|
||||||
assert_se(!p && !q);
|
assert(!p && !q);
|
||||||
unit_file_changes_free(changes, n_changes);
|
unit_file_changes_free(changes, n_changes);
|
||||||
changes = NULL; n_changes = 0;
|
changes = NULL; n_changes = 0;
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ static void test_linked_units(const char *root) {
|
|||||||
else
|
else
|
||||||
assert_not_reached();
|
assert_not_reached();
|
||||||
}
|
}
|
||||||
assert_se(!p && !q);
|
assert(!p && !q);
|
||||||
unit_file_changes_free(changes, n_changes);
|
unit_file_changes_free(changes, n_changes);
|
||||||
changes = NULL; n_changes = 0;
|
changes = NULL; n_changes = 0;
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ static void test_linked_units(const char *root) {
|
|||||||
else
|
else
|
||||||
assert_not_reached();
|
assert_not_reached();
|
||||||
}
|
}
|
||||||
assert_se(!p && !q);
|
assert(!p && !q);
|
||||||
unit_file_changes_free(changes, n_changes);
|
unit_file_changes_free(changes, n_changes);
|
||||||
changes = NULL; n_changes = 0;
|
changes = NULL; n_changes = 0;
|
||||||
|
|
||||||
@ -681,7 +681,7 @@ static void test_revert(const char *root) {
|
|||||||
UnitFileChange *changes = NULL;
|
UnitFileChange *changes = NULL;
|
||||||
size_t n_changes = 0;
|
size_t n_changes = 0;
|
||||||
|
|
||||||
assert_se(root);
|
assert(root);
|
||||||
|
|
||||||
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "xx.service", NULL) == -ENOENT);
|
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "xx.service", NULL) == -ENOENT);
|
||||||
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "yy.service", NULL) == -ENOENT);
|
assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "yy.service", NULL) == -ENOENT);
|
||||||
@ -1103,13 +1103,13 @@ static void verify_one(
|
|||||||
i->name, alias, r, expected,
|
i->name, alias, r, expected,
|
||||||
alias2 ? " [" : "", strempty(alias2),
|
alias2 ? " [" : "", strempty(alias2),
|
||||||
alias2 ? "]" : "");
|
alias2 ? "]" : "");
|
||||||
assert_se(r == expected);
|
assert(r == expected);
|
||||||
|
|
||||||
/* This is test for "instance propagation". This propagation matters mostly for WantedBy= and
|
/* This is test for "instance propagation". This propagation matters mostly for WantedBy= and
|
||||||
* RequiredBy= settings, and less so for Alias=. The only case where it should happen is when we have
|
* RequiredBy= settings, and less so for Alias=. The only case where it should happen is when we have
|
||||||
* an Alias=alias@.service an instantiated template template@instance. In that case the instance name
|
* an Alias=alias@.service an instantiated template template@instance. In that case the instance name
|
||||||
* should be propagated into the alias as alias@instance. */
|
* should be propagated into the alias as alias@instance. */
|
||||||
assert_se(streq_ptr(alias2, updated_name));
|
assert(streq_ptr(alias2, updated_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_verify_alias(void) {
|
static void test_verify_alias(void) {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ static void test_file(void) {
|
|||||||
log_info("RELATIVE_SOURCE_PATH: %s", RELATIVE_SOURCE_PATH);
|
log_info("RELATIVE_SOURCE_PATH: %s", RELATIVE_SOURCE_PATH);
|
||||||
log_info("PROJECT_FILE: %s", PROJECT_FILE);
|
log_info("PROJECT_FILE: %s", PROJECT_FILE);
|
||||||
|
|
||||||
assert_se(startswith(__FILE__, RELATIVE_SOURCE_PATH "/"));
|
assert(startswith(__FILE__, RELATIVE_SOURCE_PATH "/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_log_struct(void) {
|
static void test_log_struct(void) {
|
||||||
|
|||||||
@ -243,15 +243,15 @@ static void test_foreach_pointer(void) {
|
|||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_se(k == 3);
|
assert(k == 3);
|
||||||
|
|
||||||
FOREACH_POINTER(i, &b) {
|
FOREACH_POINTER(i, &b) {
|
||||||
assert_se(k == 3);
|
assert(k == 3);
|
||||||
assert_se(i == &b);
|
assert(i == &b);
|
||||||
k = 4;
|
k = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_se(k == 4);
|
assert(k == 4);
|
||||||
|
|
||||||
FOREACH_POINTER(i, NULL, &c, NULL, &b, NULL, &a, NULL) {
|
FOREACH_POINTER(i, NULL, &c, NULL, &b, NULL, &a, NULL) {
|
||||||
switch (k) {
|
switch (k) {
|
||||||
@ -292,7 +292,7 @@ static void test_foreach_pointer(void) {
|
|||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_se(k == 11);
|
assert(k == 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_align_to(void) {
|
static void test_align_to(void) {
|
||||||
|
|||||||
@ -8,7 +8,7 @@ static void test_normalize_recovery_key(const char *t, const char *expected) {
|
|||||||
_cleanup_free_ char *z = NULL;
|
_cleanup_free_ char *z = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert_se(t);
|
assert(t);
|
||||||
|
|
||||||
r = normalize_recovery_key(t, &z);
|
r = normalize_recovery_key(t, &z);
|
||||||
assert_se(expected ?
|
assert_se(expected ?
|
||||||
|
|||||||
@ -60,7 +60,7 @@ static void test_user_and_global_paths(void) {
|
|||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
log_info(" %s", *p);
|
log_info(" %s", *p);
|
||||||
assert_se(u[k]); /* If NULL, we didn't find a matching entry */
|
assert(u[k]); /* If NULL, we didn't find a matching entry */
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
STRV_FOREACH(p, u + k)
|
STRV_FOREACH(p, u + k)
|
||||||
|
|||||||
@ -42,7 +42,7 @@ static void test_read_mem_pressure(void) {
|
|||||||
assert_se(LOADAVG_INT_SIDE(rp.avg300) == 1);
|
assert_se(LOADAVG_INT_SIDE(rp.avg300) == 1);
|
||||||
assert_se(LOADAVG_DECIMAL_SIDE(rp.avg300) == 11);
|
assert_se(LOADAVG_DECIMAL_SIDE(rp.avg300) == 11);
|
||||||
assert_se(rp.total == 58761459);
|
assert_se(rp.total == 58761459);
|
||||||
assert_se(read_resource_pressure(path, PRESSURE_TYPE_FULL, &rp) == 0);
|
assert(read_resource_pressure(path, PRESSURE_TYPE_FULL, &rp) == 0);
|
||||||
assert_se(LOADAVG_INT_SIDE(rp.avg10) == 0);
|
assert_se(LOADAVG_INT_SIDE(rp.avg10) == 0);
|
||||||
assert_se(LOADAVG_DECIMAL_SIDE(rp.avg10) == 23);
|
assert_se(LOADAVG_DECIMAL_SIDE(rp.avg10) == 23);
|
||||||
assert_se(LOADAVG_INT_SIDE(rp.avg60) == 0);
|
assert_se(LOADAVG_INT_SIDE(rp.avg60) == 0);
|
||||||
@ -62,7 +62,7 @@ static void test_read_mem_pressure(void) {
|
|||||||
assert_se(LOADAVG_INT_SIDE(rp.avg300) == 1);
|
assert_se(LOADAVG_INT_SIDE(rp.avg300) == 1);
|
||||||
assert_se(LOADAVG_DECIMAL_SIDE(rp.avg300) == 11);
|
assert_se(LOADAVG_DECIMAL_SIDE(rp.avg300) == 11);
|
||||||
assert_se(rp.total == 58761459);
|
assert_se(rp.total == 58761459);
|
||||||
assert_se(read_resource_pressure(path, PRESSURE_TYPE_FULL, &rp) == 0);
|
assert(read_resource_pressure(path, PRESSURE_TYPE_FULL, &rp) == 0);
|
||||||
assert_se(LOADAVG_INT_SIDE(rp.avg10) == 0);
|
assert_se(LOADAVG_INT_SIDE(rp.avg10) == 0);
|
||||||
assert_se(LOADAVG_DECIMAL_SIDE(rp.avg10) == 23);
|
assert_se(LOADAVG_DECIMAL_SIDE(rp.avg10) == 23);
|
||||||
assert_se(LOADAVG_INT_SIDE(rp.avg60) == 0);
|
assert_se(LOADAVG_INT_SIDE(rp.avg60) == 0);
|
||||||
|
|||||||
@ -63,8 +63,8 @@ static int recurse_dir_callback(
|
|||||||
|
|
||||||
char ***l = userdata;
|
char ***l = userdata;
|
||||||
|
|
||||||
assert_se(path);
|
assert(path);
|
||||||
assert_se(de);
|
assert(de);
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
||||||
|
|||||||
@ -45,11 +45,11 @@ static void test_basic_enumerate(void) {
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
r = sd_hwdb_enumerate(hwdb, &key, &value);
|
r = sd_hwdb_enumerate(hwdb, &key, &value);
|
||||||
assert_se(IN_SET(r, 0, 1));
|
assert(IN_SET(r, 0, 1));
|
||||||
if (r == 0)
|
if (r == 0)
|
||||||
break;
|
break;
|
||||||
assert_se(key);
|
assert(key);
|
||||||
assert_se(value);
|
assert(value);
|
||||||
log_debug("A: \"%s\" → \"%s\"", key, value);
|
log_debug("A: \"%s\" → \"%s\"", key, value);
|
||||||
len1 += strlen(key) + strlen(value);
|
len1 += strlen(key) + strlen(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -143,7 +143,7 @@ static void test_set_copy(void) {
|
|||||||
copy = set_copy(s);
|
copy = set_copy(s);
|
||||||
assert_se(copy);
|
assert_se(copy);
|
||||||
|
|
||||||
assert_se(set_equal(s, copy));
|
assert(set_equal(s, copy));
|
||||||
|
|
||||||
set_free(s);
|
set_free(s);
|
||||||
set_free_free(copy);
|
set_free_free(copy);
|
||||||
|
|||||||
@ -16,7 +16,7 @@ static void test_rt_signals(void) {
|
|||||||
info(SIGRTMAX);
|
info(SIGRTMAX);
|
||||||
|
|
||||||
/* We use signals SIGRTMIN+0 to SIGRTMIN+24 unconditionally */
|
/* We use signals SIGRTMIN+0 to SIGRTMIN+24 unconditionally */
|
||||||
assert_se(SIGRTMAX - SIGRTMIN >= 24);
|
assert(SIGRTMAX - SIGRTMIN >= 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_signal_to_string_one(int val) {
|
static void test_signal_to_string_one(int val) {
|
||||||
|
|||||||
@ -16,7 +16,7 @@ static void test_socket_address_parse_one(const char *in, int ret, int family, c
|
|||||||
r = socket_address_print(&a, &out);
|
r = socket_address_print(&a, &out);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
log_error_errno(r, "Printing failed for \"%s\": %m", in);
|
log_error_errno(r, "Printing failed for \"%s\": %m", in);
|
||||||
assert_se(r >= 0);
|
assert(r >= 0);
|
||||||
assert_se(a.type == 0);
|
assert_se(a.type == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,37 +26,37 @@ assert_cc(SUN_PATH_LEN == 108);
|
|||||||
static void test_ifname_valid(void) {
|
static void test_ifname_valid(void) {
|
||||||
log_info("/* %s */", __func__);
|
log_info("/* %s */", __func__);
|
||||||
|
|
||||||
assert_se( ifname_valid("foo"));
|
assert( ifname_valid("foo"));
|
||||||
assert_se( ifname_valid("eth0"));
|
assert( ifname_valid("eth0"));
|
||||||
|
|
||||||
assert_se(!ifname_valid("0"));
|
assert(!ifname_valid("0"));
|
||||||
assert_se(!ifname_valid("99"));
|
assert(!ifname_valid("99"));
|
||||||
assert_se( ifname_valid("a99"));
|
assert( ifname_valid("a99"));
|
||||||
assert_se( ifname_valid("99a"));
|
assert( ifname_valid("99a"));
|
||||||
|
|
||||||
assert_se(!ifname_valid(NULL));
|
assert(!ifname_valid(NULL));
|
||||||
assert_se(!ifname_valid(""));
|
assert(!ifname_valid(""));
|
||||||
assert_se(!ifname_valid(" "));
|
assert(!ifname_valid(" "));
|
||||||
assert_se(!ifname_valid(" foo"));
|
assert(!ifname_valid(" foo"));
|
||||||
assert_se(!ifname_valid("bar\n"));
|
assert(!ifname_valid("bar\n"));
|
||||||
assert_se(!ifname_valid("."));
|
assert(!ifname_valid("."));
|
||||||
assert_se(!ifname_valid(".."));
|
assert(!ifname_valid(".."));
|
||||||
assert_se(ifname_valid("foo.bar"));
|
assert(ifname_valid("foo.bar"));
|
||||||
assert_se(!ifname_valid("x:y"));
|
assert(!ifname_valid("x:y"));
|
||||||
|
|
||||||
assert_se( ifname_valid_full("xxxxxxxxxxxxxxx", 0));
|
assert( ifname_valid_full("xxxxxxxxxxxxxxx", 0));
|
||||||
assert_se(!ifname_valid_full("xxxxxxxxxxxxxxxx", 0));
|
assert(!ifname_valid_full("xxxxxxxxxxxxxxxx", 0));
|
||||||
assert_se( ifname_valid_full("xxxxxxxxxxxxxxxx", IFNAME_VALID_ALTERNATIVE));
|
assert( ifname_valid_full("xxxxxxxxxxxxxxxx", IFNAME_VALID_ALTERNATIVE));
|
||||||
assert_se( ifname_valid_full("xxxxxxxxxxxxxxxx", IFNAME_VALID_ALTERNATIVE));
|
assert( ifname_valid_full("xxxxxxxxxxxxxxxx", IFNAME_VALID_ALTERNATIVE));
|
||||||
assert_se(!ifname_valid_full("999", IFNAME_VALID_ALTERNATIVE));
|
assert(!ifname_valid_full("999", IFNAME_VALID_ALTERNATIVE));
|
||||||
assert_se( ifname_valid_full("999", IFNAME_VALID_ALTERNATIVE | IFNAME_VALID_NUMERIC));
|
assert( ifname_valid_full("999", IFNAME_VALID_ALTERNATIVE | IFNAME_VALID_NUMERIC));
|
||||||
assert_se(!ifname_valid_full("0", IFNAME_VALID_ALTERNATIVE | IFNAME_VALID_NUMERIC));
|
assert(!ifname_valid_full("0", IFNAME_VALID_ALTERNATIVE | IFNAME_VALID_NUMERIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_socket_print_unix_one(const char *in, size_t len_in, const char *expected) {
|
static void test_socket_print_unix_one(const char *in, size_t len_in, const char *expected) {
|
||||||
_cleanup_free_ char *out = NULL, *c = NULL;
|
_cleanup_free_ char *out = NULL, *c = NULL;
|
||||||
|
|
||||||
assert_se(len_in <= SUN_PATH_LEN);
|
assert(len_in <= SUN_PATH_LEN);
|
||||||
SocketAddress a = { .sockaddr = { .un = { .sun_family = AF_UNIX } },
|
SocketAddress a = { .sockaddr = { .un = { .sun_family = AF_UNIX } },
|
||||||
.size = offsetof(struct sockaddr_un, sun_path) + len_in,
|
.size = offsetof(struct sockaddr_un, sun_path) + len_in,
|
||||||
.type = SOCK_STREAM,
|
.type = SOCK_STREAM,
|
||||||
@ -194,7 +194,7 @@ static void test_getpeercred_getpeergroups(void) {
|
|||||||
test_gid = getgid();
|
test_gid = getgid();
|
||||||
|
|
||||||
ngroups_max = sysconf(_SC_NGROUPS_MAX);
|
ngroups_max = sysconf(_SC_NGROUPS_MAX);
|
||||||
assert_se(ngroups_max > 0);
|
assert(ngroups_max > 0);
|
||||||
|
|
||||||
test_gids = newa(gid_t, ngroups_max);
|
test_gids = newa(gid_t, ngroups_max);
|
||||||
|
|
||||||
|
|||||||
@ -184,7 +184,7 @@ static void test_device_path_make_canonical_one(const char *path) {
|
|||||||
log_debug("> %s", path);
|
log_debug("> %s", path);
|
||||||
|
|
||||||
if (stat(path, &st) < 0) {
|
if (stat(path, &st) < 0) {
|
||||||
assert_se(errno == ENOENT);
|
assert(errno == ENOENT);
|
||||||
log_notice("Path %s not found, skipping test", path);
|
log_notice("Path %s not found, skipping test", path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1007,7 +1007,7 @@ static void test_strv_fnmatch(void) {
|
|||||||
v = strv_new("xxx", "*\\*", "yyy");
|
v = strv_new("xxx", "*\\*", "yyy");
|
||||||
assert_se(!strv_fnmatch_full(v, "\\", 0, NULL));
|
assert_se(!strv_fnmatch_full(v, "\\", 0, NULL));
|
||||||
assert_se(strv_fnmatch_full(v, "\\", FNM_NOESCAPE, &pos));
|
assert_se(strv_fnmatch_full(v, "\\", FNM_NOESCAPE, &pos));
|
||||||
assert_se(pos == 1);
|
assert(pos == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|||||||
@ -656,7 +656,7 @@ int main(int argc, char *argv[]) {
|
|||||||
/* Ensure TIME_T_MAX works correctly */
|
/* Ensure TIME_T_MAX works correctly */
|
||||||
uintmax_t x = TIME_T_MAX;
|
uintmax_t x = TIME_T_MAX;
|
||||||
x++;
|
x++;
|
||||||
assert_se((time_t) x < 0);
|
assert((time_t) x < 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ static void test_tempfn_random_one(const char *p, const char *extra, const char
|
|||||||
r = tempfn_random(p, extra, &s);
|
r = tempfn_random(p, extra, &s);
|
||||||
log_info_errno(r, "%s+%s → %s vs. %s (%i/%m vs. %i/%s)", p, strna(extra), strna(s), strna(expect), r, ret, strerror_safe(ret));
|
log_info_errno(r, "%s+%s → %s vs. %s (%i/%m vs. %i/%s)", p, strna(extra), strna(s), strna(expect), r, ret, strerror_safe(ret));
|
||||||
|
|
||||||
assert_se(!s == !expect);
|
assert(!s == !expect);
|
||||||
if (s) {
|
if (s) {
|
||||||
const char *suffix;
|
const char *suffix;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ static void test_tempfn_random_one(const char *p, const char *extra, const char
|
|||||||
assert_se(in_charset(suffix, HEXDIGITS));
|
assert_se(in_charset(suffix, HEXDIGITS));
|
||||||
assert_se(strlen(suffix) == 16);
|
assert_se(strlen(suffix) == 16);
|
||||||
}
|
}
|
||||||
assert_se(ret == r);
|
assert(ret == r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_tempfn_random(void) {
|
static void test_tempfn_random(void) {
|
||||||
@ -59,14 +59,14 @@ static void test_tempfn_xxxxxx_one(const char *p, const char *extra, const char
|
|||||||
r = tempfn_xxxxxx(p, extra, &s);
|
r = tempfn_xxxxxx(p, extra, &s);
|
||||||
log_info_errno(r, "%s+%s → %s vs. %s (%i/%m vs. %i/%s)", p, strna(extra), strna(s), strna(expect), r, ret, strerror_safe(ret));
|
log_info_errno(r, "%s+%s → %s vs. %s (%i/%m vs. %i/%s)", p, strna(extra), strna(s), strna(expect), r, ret, strerror_safe(ret));
|
||||||
|
|
||||||
assert_se(!s == !expect);
|
assert(!s == !expect);
|
||||||
if (s) {
|
if (s) {
|
||||||
const char *suffix;
|
const char *suffix;
|
||||||
|
|
||||||
assert_se(suffix = startswith(s, expect));
|
assert_se(suffix = startswith(s, expect));
|
||||||
assert_se(streq(suffix, "XXXXXX"));
|
assert_se(streq(suffix, "XXXXXX"));
|
||||||
}
|
}
|
||||||
assert_se(ret == r);
|
assert(ret == r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_tempfn_xxxxxx(void) {
|
static void test_tempfn_xxxxxx(void) {
|
||||||
|
|||||||
@ -65,7 +65,7 @@ static void test_unit_file_build_name_map(char **ids) {
|
|||||||
*id,
|
*id,
|
||||||
&fragment,
|
&fragment,
|
||||||
&names);
|
&names);
|
||||||
assert_se(r == 0);
|
assert(r == 0);
|
||||||
log_info("fragment: %s", fragment);
|
log_info("fragment: %s", fragment);
|
||||||
log_info("names:");
|
log_info("names:");
|
||||||
SET_FOREACH(name, names)
|
SET_FOREACH(name, names)
|
||||||
|
|||||||
@ -17,7 +17,7 @@ static void test_deserialize_exec_command_one(Manager *m, const char *key, const
|
|||||||
|
|
||||||
r = service_deserialize_exec_command(u, key, line);
|
r = service_deserialize_exec_command(u, key, line);
|
||||||
log_debug("[%s] → %d (expected: %d)", line, r, expected);
|
log_debug("[%s] → %d (expected: %d)", line, r, expected);
|
||||||
assert_se(r == expected);
|
assert(r == expected);
|
||||||
|
|
||||||
/* Note that the command doesn't match any command in the empty list of commands in 's', so it is
|
/* Note that the command doesn't match any command in the empty list of commands in 's', so it is
|
||||||
* always rejected with "Current command vanished from the unit file", and we don't leak anything. */
|
* always rejected with "Current command vanished from the unit file", and we don't leak anything. */
|
||||||
|
|||||||
@ -374,14 +374,14 @@ static void test_make_salt(void) {
|
|||||||
assert_se(make_salt(&t) == 0);
|
assert_se(make_salt(&t) == 0);
|
||||||
log_info("got %s", t);
|
log_info("got %s", t);
|
||||||
|
|
||||||
assert_se(!streq(s, t));
|
assert(!streq(s, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_in_gid(void) {
|
static void test_in_gid(void) {
|
||||||
assert_se(in_gid(getgid()) >= 0);
|
assert(in_gid(getgid()) >= 0);
|
||||||
assert_se(in_gid(getegid()) >= 0);
|
assert(in_gid(getegid()) >= 0);
|
||||||
assert_se(in_gid(GID_INVALID) < 0);
|
assert(in_gid(GID_INVALID) < 0);
|
||||||
assert_se(in_gid(TTY_GID) == 0); /* The TTY gid is for owning ttys, it would be really really weird if we were in it. */
|
assert(in_gid(TTY_GID) == 0); /* The TTY gid is for owning ttys, it would be really really weird if we were in it. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_gid_lists_ops(void) {
|
static void test_gid_lists_ops(void) {
|
||||||
|
|||||||
@ -72,8 +72,8 @@ static int reply(Varlink *link, JsonVariant *parameters, const char *error_id, V
|
|||||||
static int on_connect(VarlinkServer *s, Varlink *link, void *userdata) {
|
static int on_connect(VarlinkServer *s, Varlink *link, void *userdata) {
|
||||||
uid_t uid = UID_INVALID;
|
uid_t uid = UID_INVALID;
|
||||||
|
|
||||||
assert_se(s);
|
assert(s);
|
||||||
assert_se(link);
|
assert(link);
|
||||||
|
|
||||||
assert_se(varlink_get_peer_uid(link, &uid) >= 0);
|
assert_se(varlink_get_peer_uid(link, &uid) >= 0);
|
||||||
assert_se(getuid() == uid);
|
assert_se(getuid() == uid);
|
||||||
|
|||||||
@ -47,8 +47,8 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
|
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
assert_se(argc >= 0);
|
assert(argc >= 0);
|
||||||
assert_se(argv);
|
assert(argv);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "r:", options, NULL)) >= 0)
|
while ((c = getopt_long(argc, argv, "r:", options, NULL)) >= 0)
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user