Browse Source

tests: workaround systemd-nspawn habit of disabling unimplemented syscalls

* tests/clone3.c (do_clone3_): Do not assume that unimplemented
syscalls always fail with ENOSYS.
Dmitry V. Levin 1 month ago
parent
commit
45d9a92359
1 changed files with 14 additions and 6 deletions
  1. 14
    6
      tests/clone3.c

+ 14
- 6
tests/clone3.c View File

@@ -109,13 +109,21 @@ do_clone3_(void *args, kernel_ulong_t size, bool should_fail, int line)
109 109
 				    "of a clone3() call (%ld instead of %ld)",
110 110
 				    line, rc, injected_retval);
111 111
 #else
112
-	if (should_fail && rc >= 0)
113
-		error_msg_and_fail("%d: Unexpected success of a clone3() call",
114
-				   line);
115 112
 
116
-	if (!should_fail && rc < 0 && errno != ENOSYS)
117
-		perror_msg_and_fail("%d: Unexpected failure of a clone3() call",
118
-				    line);
113
+	static int unimplemented_error = -1;
114
+
115
+	if (should_fail) {
116
+		if (rc >= 0)
117
+			error_msg_and_fail("%d: Unexpected success"
118
+					   " of a clone3() call", line);
119
+		if (unimplemented_error < 0)
120
+			unimplemented_error =
121
+				(errno == EINVAL) ? ENOSYS : errno;
122
+	} else {
123
+		if (rc < 0 && errno != unimplemented_error)
124
+			perror_msg_and_fail("%d: Unexpected failure"
125
+					    " of a clone3() call", line);
126
+	}
119 127
 
120 128
 	if (!rc)
121 129
 		_exit(child_exit_status);

Loading…
Cancel
Save