app/test: remove meson dependency on file in /sys
authorBruce Richardson <bruce.richardson@intel.com>
Mon, 20 Jan 2020 12:22:18 +0000 (12:22 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 20 Jan 2020 15:37:27 +0000 (16:37 +0100)
Meson versions 0.52 and 0.53 are being overly smart and detecting the path
"/sys/devices/system/cpu/present" in the call to cat in
app/test/meson.build and then adding it as a dependency to the build
configuration. This causes issues on systems where the timestamp of that
file always returns the current time, since it means that the build.ninja
file is always out of date, and therefore needs to be rebuilt.

We can fix this by just using a simple shell script to return the coremask
appropriately for BSD and Linux, and removing that code logic from meson -
thereby hiding the use of the /sys file.

Fixes: c70622ac6f72 ("test: detect number of cores with meson")
Cc: stable@dpdk.org
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
MAINTAINERS
app/test/get-coremask.sh [new file with mode: 0755]
app/test/meson.build

index 8916ef9..48fbaa0 100644 (file)
@@ -1446,6 +1446,7 @@ Unit tests framework
 F: app/test/Makefile
 F: app/test/autotest*
 F: app/test/commands.c
+F: app/test/get-coremask.sh
 F: app/test/packet_burst_generator.c
 F: app/test/packet_burst_generator.h
 F: app/test/process.h
diff --git a/app/test/get-coremask.sh b/app/test/get-coremask.sh
new file mode 100755 (executable)
index 0000000..bb8cf40
--- /dev/null
@@ -0,0 +1,13 @@
+#! /bin/sh -e
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2019 Intel Corporation
+
+if [ "$(uname)" = "Linux" ] ; then
+       cat /sys/devices/system/cpu/present
+elif [ "$(uname)" = "FreeBSD" ] ; then
+       ncpus=$(/sbin/sysctl -n hw.ncpu)
+       echo 0-$(expr $ncpus - 1)
+else
+# fallback
+       echo 0-3
+fi
index fb49d80..22b0cef 100644 (file)
@@ -398,20 +398,8 @@ dpdk_test = executable('dpdk-test',
 timeout_seconds = 600
 timeout_seconds_fast = 10
 
-# Retrieve the number of CPU cores, defaulting to 4.
-num_cores = '0-3'
-if host_machine.system() == 'linux'
-       num_cores = run_command('cat',
-                               '/sys/devices/system/cpu/present'
-                              ).stdout().strip()
-elif host_machine.system() == 'freebsd'
-       snum_cores = run_command('/sbin/sysctl', '-n',
-                                'hw.ncpu').stdout().strip()
-       inum_cores = snum_cores.to_int() - 1
-        num_cores = '0-@0@'.format(inum_cores)
-endif
-
-num_cores_arg = '-l ' + num_cores
+get_coremask = find_program('get-coremask.sh')
+num_cores_arg = '-l ' + run_command(get_coremask).stdout().strip()
 
 test_args = [num_cores_arg]
 foreach arg : fast_test_names