Merge pull request #32477 from DaanDeMeyer/fixes

Various fixes
This commit is contained in:
Daan De Meyer
2024-04-25 18:24:09 +02:00
committed by GitHub
50 changed files with 109 additions and 150 deletions
+15 -6
View File
@@ -321,6 +321,7 @@ meson_build_sh = find_program('tools/meson-build.sh')
want_tests = get_option('tests')
slow_tests = want_tests != 'false' and get_option('slow-tests')
fuzz_tests = want_tests != 'false' and get_option('fuzz-tests')
integration_tests = want_tests != 'false' and get_option('integration-tests')
install_tests = want_tests != 'false' and get_option('install-tests')
if add_languages('cpp', native : false, required : fuzzer_build)
@@ -2574,6 +2575,18 @@ endif
#####################################################################
mkosi = find_program('mkosi', required : false)
if integration_tests and not mkosi.found()
error('Could not find mkosi which is required to run the integration tests')
endif
mkosi_depends = public_programs
foreach executable : ['systemd-journal-remote', 'systemd-measure']
if executable in executables_by_name
mkosi_depends += [executables_by_name[executable]]
endif
endforeach
if mkosi.found()
custom_target('mkosi',
build_always_stale : true,
@@ -2588,13 +2601,9 @@ if mkosi.found()
'--build-dir', meson.current_build_dir() / 'mkosi.builddir',
'--force',
'--debug',
'build'
],
depends : public_programs + [
executables_by_name['systemd-journal-remote'],
executables_by_name['systemd-measure'],
ukify,
'build',
],
depends : mkosi_depends,
)
endif
@@ -40,6 +40,7 @@ Packages=
quota-tools
sbsigntools
shadow
squashfs-tools
tpm2-tss
vim
@@ -52,6 +52,7 @@ Packages=
selinux-policy
selinux-policy-targeted
setools-console
squashfs-tools
util-linux
vim-common
@@ -61,6 +61,7 @@ Packages=
psmisc
quota
sbsigntool
squashfs-tools
tzdata
xxd
@@ -61,6 +61,7 @@ Packages=
sbsigntools
sed
shadow
squashfs
timezone
user(bin)
user(daemon)
@@ -19,6 +19,9 @@ enable dbus-broker.service
enable systemd-networkd.service
enable systemd-networkd-wait-online.service
# systemd-resolved is disable by default on CentOS so make sure it is enabled.
enable systemd-resolved.service
# We install dnf in some images but it's only going to be used rarely,
# so let's not have dnf create its cache.
disable dnf-makecache.*
+1 -2
View File
@@ -83,8 +83,7 @@ static int run(int argc, char *argv[]) {
/* This is mostly intended to be used for scripts which want
* to detect whether AC power is plugged in or not. */
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -3
View File
@@ -226,9 +226,7 @@ static int run(int argc, char *argv[]) {
usec_t timeout;
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -2
View File
@@ -499,8 +499,7 @@ static int run(int argc, char *argv[]) {
int r;
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -2
View File
@@ -79,8 +79,7 @@ static int run(int argc, char *argv[]) {
uint32_t n;
int r;
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -3
View File
@@ -1160,9 +1160,7 @@ static int measure_main(int argc, char *argv[]) {
static int run(int argc, char *argv[]) {
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -3
View File
@@ -797,9 +797,7 @@ static int run(int argc, char *argv[]) {
size_t vks;
int slot, slot_to_wipe, r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
@@ -84,8 +84,7 @@ static int load_and_print(void) {
static int run(int argc, char *argv[]) {
int r;
log_parse_environment();
log_open();
log_setup();
if (argc > 1)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program takes no arguments.");
+1 -2
View File
@@ -33,8 +33,7 @@ static inline void fuzz_setup_logging(void) {
* in a fuzzing mode, so disable most of the logging. */
log_set_assert_return_is_critical(true);
log_set_max_level(LOG_CRIT);
log_parse_environment();
log_open();
log_setup();
}
/* Force value to not be optimized away. */
+1 -2
View File
@@ -120,8 +120,7 @@ static int hwdb_main(int argc, char *argv[]) {
static int run(int argc, char *argv[]) {
int r;
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -2
View File
@@ -1070,8 +1070,7 @@ static int run(int argc, char **argv) {
_cleanup_free_ char *cert = NULL, *trust = NULL;
int r;
log_show_color(true);
log_parse_environment();
log_setup();
/* The journal merging logic potentially needs a lot of fds. */
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
+1 -2
View File
@@ -764,8 +764,7 @@ static int run(int argc, char **argv) {
bool use_journal;
int r;
log_show_color(true);
log_parse_environment();
log_setup();
/* The journal merging logic potentially needs a lot of fds. */
(void) rlimit_nofile_bump(HIGH_RLIMIT_NOFILE);
+1 -2
View File
@@ -305,8 +305,7 @@ static int run(int argc, char *argv[]) {
_cleanup_free_ char *message = NULL;
int r;
log_open();
log_parse_environment();
log_setup();
sigbus_install();
+1 -3
View File
@@ -257,9 +257,7 @@ static int run(int argc, char *argv[]) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -2
View File
@@ -190,8 +190,7 @@ static int do_umount(const char *user) {
static int run(int argc, char *argv[]) {
int r;
log_parse_environment();
log_open();
log_setup();
if (argc != 3)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+1 -2
View File
@@ -139,8 +139,7 @@ static int run(int argc, char *argv[]) {
_cleanup_(umount_and_freep) char *mounted_dir = NULL;
int r;
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -3
View File
@@ -1492,9 +1492,7 @@ static int run(int argc, char* argv[]) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -2
View File
@@ -5777,8 +5777,7 @@ static int run(int argc, char *argv[]) {
_cleanup_(fw_ctx_freep) FirewallContext *fw_ctx = NULL;
pid_t pid = 0;
log_parse_environment();
log_open();
log_setup();
arg_privileged = getuid() == 0;
+1 -1
View File
@@ -56,7 +56,7 @@ static int run(int argc, char *argv[]) {
int r;
log_set_max_level(LOG_DEBUG);
log_open();
log_setup();
r = userns_restrict_install(/* pin= */ false, &obj);
if (ERRNO_IS_NOT_SUPPORTED(r)) {
+1 -3
View File
@@ -119,9 +119,7 @@ static int run(int argc, char* argv[]) {
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -3
View File
@@ -8005,9 +8005,7 @@ static int run(int argc, char *argv[]) {
bool node_is_our_loop = false;
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -3
View File
@@ -218,9 +218,7 @@ static int parse_argv(int argc, char *argv[]) {
static int run(int argc, char* argv[]) {
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -1
View File
@@ -4,7 +4,7 @@
MountAPIVFS=yes
BindReadOnlyPaths=/dev/log /run/systemd/journal/socket /run/systemd/journal/stdout
BindReadOnlyPaths=/etc/machine-id
BindReadOnlyPaths=/etc/resolv.conf
BindReadOnlyPaths=-/etc/resolv.conf
BindReadOnlyPaths=/run/dbus/system_bus_socket
DynamicUser=yes
RemoveIPC=yes
+1 -1
View File
@@ -5,4 +5,4 @@ MountAPIVFS=yes
PrivateTmp=yes
BindPaths=/run
BindReadOnlyPaths=/etc/machine-id
BindReadOnlyPaths=/etc/resolv.conf
BindReadOnlyPaths=-/etc/resolv.conf
+1 -3
View File
@@ -2320,9 +2320,7 @@ static int run(int argc, char* argv[]) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
if (invoked_as(argv, "run0"))
r = parse_argv_sudo_mode(argc, argv);
+1 -2
View File
@@ -970,6 +970,5 @@ void log_setup_generator(void) {
log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
}
log_parse_environment();
(void) log_open();
log_setup();
}
+1 -3
View File
@@ -446,9 +446,7 @@ static int run(int argc, char **argv) {
_cleanup_strv_free_ char **exec_argv = NULL;
int r, n;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -2
View File
@@ -676,8 +676,7 @@ static int run(int argc, char *argv[]) {
_unused_ _cleanup_(notify_on_cleanup) const char *notify_stop = NULL;
int r, n, fd;
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -3
View File
@@ -105,9 +105,7 @@ static int run(int argc, char *argv[]) {
bool is_unix;
int r, in_fd, out_fd;
log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -3
View File
@@ -1111,9 +1111,7 @@ static int run(int argc, char* argv[]) {
_cleanup_(context_done) Context context = {};
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1
View File
@@ -15,6 +15,7 @@ test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map)
test_env.set('PATH', project_build_root + ':' + path)
test_env.set('PROJECT_BUILD_ROOT', project_build_root)
test_env.set('SYSTEMD_SLOW_TESTS', slow_tests ? '1' : '0')
test_env.set('SYSTEMD_INTEGRATION_TESTS', integration_tests ? '1' : '0')
if efi_addon != ''
test_env.set('EFI_ADDON', efi_addon)
+1 -1
View File
@@ -148,7 +148,7 @@ TEST(rearrange_stdio) {
assert_se(rearrange_stdio(-EBADF, -EBADF, -EBADF) >= 0);
/* Reconfigure logging after rearranging stdout/stderr, so we still log to somewhere if the
* following tests fail, making it slightly less annoying to debug */
log_set_target(LOG_TARGET_KMSG);
log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
log_open();
assert_se(fd_get_path(STDIN_FILENO, &path) >= 0);
+2 -4
View File
@@ -413,10 +413,8 @@ static int run(int argc, char *argv[]) {
uint16_t word;
int r, peripheral_device_type = -1;
log_set_target(LOG_TARGET_AUTO);
udev_parse_config();
log_parse_environment();
log_open();
(void) udev_parse_config();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+2 -4
View File
@@ -959,10 +959,8 @@ static int run(int argc, char *argv[]) {
_cleanup_(context_clear) Context c = CONTEXT_EMPTY;
int r;
log_set_target(LOG_TARGET_AUTO);
udev_parse_config();
log_parse_environment();
log_open();
(void) udev_parse_config();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+2 -4
View File
@@ -685,10 +685,8 @@ static int run(int argc, char* const* argv) {
size_t size;
int r;
log_set_target(LOG_TARGET_AUTO);
udev_parse_config();
log_parse_environment();
log_open();
(void) udev_parse_config();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+2 -4
View File
@@ -70,10 +70,8 @@ static int run(int argc, char **argv) {
ssize_t desc_len;
int r;
log_set_target(LOG_TARGET_AUTO);
udev_parse_config();
log_parse_environment();
log_open();
(void) udev_parse_config();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+2 -4
View File
@@ -480,10 +480,8 @@ int main(int argc, char **argv) {
char maj_min_dev[MAX_PATH_LEN];
int newargc;
log_set_target(LOG_TARGET_AUTO);
udev_parse_config();
log_parse_environment();
log_open();
(void) udev_parse_config();
log_setup();
/*
* Get config file options.
+1 -2
View File
@@ -79,8 +79,7 @@ int builtin_main(int argc, char *argv[], void *userdata) {
UdevBuiltinCommand cmd;
int r;
log_set_max_level(LOG_DEBUG);
log_parse_environment();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -2
View File
@@ -96,8 +96,7 @@ int test_main(int argc, char *argv[], void *userdata) {
sigset_t mask, sigmask_orig;
int r;
log_set_max_level(LOG_DEBUG);
log_parse_environment();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+1 -1
View File
@@ -123,7 +123,7 @@ static int run(int argc, char *argv[]) {
if (invoked_as(argv, "udevd"))
return run_udevd(argc, argv);
udev_parse_config();
(void) udev_parse_config();
log_setup();
r = parse_argv(argc, argv);
+1 -5
View File
@@ -289,8 +289,7 @@ int run_udevd(int argc, char *argv[]) {
int fd_ctrl = -EBADF, fd_uevent = -EBADF;
int r;
log_set_target(LOG_TARGET_AUTO);
log_open();
log_setup();
manager = manager_new();
if (!manager)
@@ -298,9 +297,6 @@ int run_udevd(int argc, char *argv[]) {
manager_parse_udev_config(manager);
log_parse_environment();
log_open(); /* Done again to update after reading configuration. */
r = parse_argv(argc, argv, manager);
if (r <= 0)
return r;
+1 -3
View File
@@ -216,9 +216,7 @@ static int parse_argv(int argc, char *argv[]) {
static int run(int argc, char *argv[]) {
int r;
log_show_color(true);
log_parse_environment();
log_open();
log_setup();
r = parse_argv(argc, argv);
if (r <= 0)
+4 -4
View File
@@ -31,7 +31,7 @@ $ sudo make -C test/TEST-01-BASIC clean setup run
To run the meson-based integration test config
enable integration tests and options for required commands with the following:
$ meson configure build -Dintegration-tests=true -Dremote=enabled -Dopenssl=enabled -Dblkid=enabled -Dtpm2=enabled
$ meson configure build -Dremote=enabled -Dopenssl=enabled -Dblkid=enabled -Dtpm2=enabled
Once enabled, first build the integration test image:
@@ -39,18 +39,18 @@ $ meson compile -C build mkosi
After the image has been built, the integration tests can be run with:
$ meson test -C build/ --suite integration-tests --num-processes "$(($(nproc) / 2))"
$ SYSTEMD_INTEGRATION_TESTS=1 meson test -C build/ --suite integration-tests --num-processes "$(($(nproc) / 2))"
As usual, specific tests can be run in meson by appending the name of the test
which is usually the name of the directory e.g.
$ meson test -C build/ -v TEST-01-BASIC
$ SYSTEMD_INTEGRATION_TESTS=1 meson test -C build/ -v TEST-01-BASIC
Due to limitations in meson, the integration tests do not yet depend on the mkosi target, which means the
mkosi target has to be manually rebuilt before running the integration tests. To rebuild the image and rerun
a test, the following command can be used:
$ meson compile -C build mkosi && meson test -C build -v TEST-01-BASIC
$ meson compile -C build mkosi && SYSTEMD_INTEGRATION_TESTS=1 meson test -C build -v TEST-01-BASIC
See `meson introspect build --tests` for a list of tests.
+4
View File
@@ -38,6 +38,10 @@ ExecStart=false
def main():
if not bool(int(os.getenv("SYSTEMD_INTEGRATION_TESTS", "0"))):
print("SYSTEMD_INTEGRATION_TESTS=1 not found in environment, skipping", file=sys.stderr)
exit(77)
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--meson-source-dir', required=True, type=Path)
parser.add_argument('--meson-build-dir', required=True, type=Path)
+33 -39
View File
@@ -334,45 +334,39 @@ endif
############################################################
if get_option('integration-tests')
if not mkosi.found()
error('Could not find mkosi which is required to run the integration tests')
integration_test_wrapper = find_program('integration-test-wrapper.py')
integration_tests = {
'01': 'TEST-01-BASIC',
'02': 'TEST-02-UNITTESTS',
}
foreach test_number, dirname : integration_tests
test_params = {
'mkosi_args' : [],
'timeout' : 600,
}
# TODO: This fs.exists call isn't included in rebuild logic
# so if you add a new meson.build in a subdir
# you need to touch another build file to get it to reparse.
if fs.exists(dirname / 'meson.build')
subdir(dirname)
endif
integration_test_wrapper = find_program('integration-test-wrapper.py')
integration_tests = {
'01': 'TEST-01-BASIC',
'02': 'TEST-02-UNITTESTS',
}
foreach test_number, dirname : integration_tests
test_params = {
'mkosi_args' : [],
'timeout' : 600,
}
args = [
'--meson-source-dir', meson.project_source_root(),
'--meson-build-dir', meson.project_build_root(),
'--test-name', dirname,
'--test-number', test_number,
'--',
] + test_params['mkosi_args']
# TODO: This fs.exists call isn't included in rebuild logic
# so if you add a new meson.build in a subdir
# you need to touch another build file to get it to reparse.
if fs.exists(dirname / 'meson.build')
subdir(dirname)
endif
args = [
'--meson-source-dir', meson.project_source_root(),
'--meson-build-dir', meson.project_build_root(),
'--test-name', dirname,
'--test-number', test_number,
'--',
] + test_params['mkosi_args']
# We don't explicitly depend on the "mkosi" target because that means the image is rebuilt
# on every "ninja -C build". Instead, the mkosi target has to be rebuilt manually before
# running the integration tests with mkosi.
test(dirname,
integration_test_wrapper,
env: test_env,
args : args,
timeout : test_params['timeout'],
suite : 'integration-tests')
endforeach
endif
# We don't explicitly depend on the "mkosi" target because that means the image is rebuilt
# on every "ninja -C build". Instead, the mkosi target has to be rebuilt manually before
# running the integration tests with mkosi.
test(dirname,
integration_test_wrapper,
env: test_env,
args : args,
timeout : test_params['timeout'],
suite : 'integration-tests')
endforeach