summaryrefslogtreecommitdiff
path: root/src/test/test-sysctl-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-12-31 03:56:59 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-12-31 04:05:38 +0900
commit9383fa08bd263277d9a17a8999c3497458f273e3 (patch)
tree4a49e935e3565bdc4c0ecb63b88f0f92011bf392 /src/test/test-sysctl-util.c
parentd8d6b2275f7b7a5b58c6b0d89b78c927333c6af9 (diff)
downloadsystemd-9383fa08bd263277d9a17a8999c3497458f273e3.tar.gz
hostname-util: drop GET_HOSTNAME_ALLOW_NONE flag and always refuse "(none)"
The flag is now only used in test-sysctl-util.c, and it should be replaced with uname(), because of the same reason as the previous commit.
Diffstat (limited to 'src/test/test-sysctl-util.c')
-rw-r--r--src/test/test-sysctl-util.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/test/test-sysctl-util.c b/src/test/test-sysctl-util.c
index 6464a7965b..8bd3c26152 100644
--- a/src/test/test-sysctl-util.c
+++ b/src/test/test-sysctl-util.c
@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include <sys/utsname.h>
+
#include "sd-id128.h"
#include "errno-util.h"
@@ -38,7 +40,8 @@ TEST(sysctl_normalize) {
}
TEST(sysctl_read) {
- _cleanup_free_ char *s = NULL, *h = NULL;
+ _cleanup_free_ char *s = NULL;
+ struct utsname u;
sd_id128_t a, b;
int r;
@@ -63,8 +66,8 @@ TEST(sysctl_read) {
s = mfree(s);
assert_se(sysctl_read("kernel/hostname", &s) >= 0);
- assert_se(gethostname_full(GET_HOSTNAME_ALLOW_NONE|GET_HOSTNAME_ALLOW_LOCALHOST, &h) >= 0);
- assert_se(streq(s, h));
+ assert_se(uname(&u) >= 0);
+ assert_se(streq_ptr(s, u.nodename));
r = sysctl_write("kernel/hostname", s);
assert_se(r >= 0 || ERRNO_IS_PRIVILEGE(r) || r == -EROFS);