tests: use new ASSERT_OK_OR macro

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-07-01 17:51:49 +02:00
parent 367b325554
commit ea64d55080
4 changed files with 18 additions and 40 deletions
+6 -11
View File
@@ -223,9 +223,7 @@ static void start_parent_slices(Unit *unit) {
slice = UNIT_GET_SLICE(unit);
if (slice) {
start_parent_slices(slice);
int r = unit_start(slice, NULL);
if (r != -EALREADY)
ASSERT_OK(r);
ASSERT_OK_OR(unit_start(slice, NULL), -EALREADY);
}
}
@@ -1472,7 +1470,6 @@ static int prepare_ns(const char *process_name) {
ASSERT_OK(r);
if (r == 0) {
_cleanup_free_ char *unit_dir = NULL, *build_dir = NULL, *build_dir_mount = NULL;
int ret;
const char *coverage = getenv("COVERAGE_BUILD_DIR");
if (!coverage)
@@ -1494,9 +1491,7 @@ static int prepare_ns(const char *process_name) {
ASSERT_OK(copy_directory_at(AT_FDCWD, unit_dir, AT_FDCWD, PRIVATE_UNIT_DIR, COPY_MERGE_EMPTY));
/* Mount tmpfs on the following directories to make not StateDirectory= or friends disturb the host. */
ret = get_build_exec_dir(&build_dir);
if (ret != -ENOEXEC)
ASSERT_OK(ret);
ASSERT_OK_OR(get_build_exec_dir(&build_dir), -ENOEXEC);
if (build_dir) {
/* Account for a build directory being in one of the soon-to-be-tmpfs directories. If we
@@ -1512,11 +1507,11 @@ static int prepare_ns(const char *process_name) {
ASSERT_OK(mount_nofollow_verbose(LOG_DEBUG, "tmpfs", p, "tmpfs", MS_NOSUID|MS_NODEV, NULL));
if (build_dir_mount) {
ret = RET_NERRNO(access(build_dir, F_OK));
if (ret != -ENOENT)
ASSERT_OK(ret);
int k;
if (ret == -ENOENT) {
ASSERT_OK_OR(k = RET_NERRNO(access(build_dir, F_OK)), -ENOENT);
if (k == -ENOENT) {
/* The build directory got overmounted by tmpfs, so let's use the "backup" bind mount to
* bring it back. */
ASSERT_OK(mkdir_p(build_dir, 0755));