Browse Source

tests: skip a few tests on systems with nproc == 1

Several tests require some concurrency between threads,
skip these tests if nproc reports 1.

* tests/init.sh (require_min_nproc): New function.
* tests/status-none-threads.test: Use it.
* tests/threads-execve.test: Likewise.
Dmitry V. Levin 1 month ago
parent
commit
07f42429cf
3 changed files with 20 additions and 0 deletions
  1. 14
    0
      tests/init.sh
  2. 3
    0
      tests/status-none-threads.test
  3. 3
    0
      tests/threads-execve.test

+ 14
- 0
tests/init.sh View File

@@ -247,6 +247,20 @@ require_min_kernel_version_or_skip()
247 247
 		skip_ "the kernel release $uname_r is not $1 or newer"
248 248
 }
249 249
 
250
+# Usage: require_min_nproc 2
251
+require_min_nproc()
252
+{
253
+	local min_nproc
254
+	min_nproc="$1"; shift
255
+
256
+	check_prog
257
+	local nproc
258
+	nproc="$(nproc)"
259
+
260
+	[ "$nproc" -ge "$min_nproc" ] ||
261
+		framework_skip_ "nproc = $nproc is less than $min_nproc"
262
+}
263
+
250 264
 # Usage: grep_pid_status $pid GREP-OPTIONS...
251 265
 grep_pid_status()
252 266
 {

+ 3
- 0
tests/status-none-threads.test View File

@@ -13,6 +13,9 @@
13 13
 # The kernel before commit v3.1-rc1~308^2~7 reported 0 instead of old pid.
14 14
 require_min_kernel_version_or_skip 3.1
15 15
 
16
+# This test requires some concurrency between threads.
17
+require_min_nproc 2
18
+
16 19
 check_prog diff
17 20
 run_prog_skip_if_failed date +%s > /dev/null
18 21
 s0="$(date +%s)"

+ 3
- 0
tests/threads-execve.test View File

@@ -14,6 +14,9 @@
14 14
 # The kernel before commit v3.1-rc1~308^2~7 reported 0 instead of old pid.
15 15
 require_min_kernel_version_or_skip 3.1
16 16
 
17
+# This test requires some concurrency between threads.
18
+require_min_nproc 2
19
+
17 20
 check_prog diff
18 21
 run_prog_skip_if_failed date +%s > /dev/null
19 22
 s0="$(date +%s)"

Loading…
Cancel
Save