Add a basic test that the configured fallback hostname is OK
Ideally, assert_cc() would be used for this, so that it is not possible to even compile systemd with something like '-Dfallback-hostname=.foo'. But to do a proper check we need to call hostname_is_valid(), and we cannot depend on being able to run code (e.g. during cross-compilation). So let's do a very superficial check in meson, and a proper on in test-util.
This commit is contained in:
@@ -140,6 +140,13 @@ static void test_read_etc_hostname(void) {
|
||||
unlink(path);
|
||||
}
|
||||
|
||||
static void test_fallback_hostname(void) {
|
||||
if (!hostname_is_valid(FALLBACK_HOSTNAME, false)) {
|
||||
log_error("Configured fallback hostname \"%s\" is not valid.", FALLBACK_HOSTNAME);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
log_parse_environment();
|
||||
log_open();
|
||||
@@ -148,5 +155,7 @@ int main(int argc, char *argv[]) {
|
||||
test_hostname_cleanup();
|
||||
test_read_etc_hostname();
|
||||
|
||||
test_fallback_hostname();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user