]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
tests: add test for issue #522
authorChristian Brauner (Microsoft) <christian.brauner@ubuntu.com>
Sat, 12 Mar 2022 10:54:41 +0000 (11:54 +0100)
committerChristian Brauner (Microsoft) <christian.brauner@ubuntu.com>
Sat, 12 Mar 2022 11:02:04 +0000 (12:02 +0100)
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
tests/main.sh.in
tests/meson.build
tests/test_sysfs.in [new file with mode: 0755]

index 656bb6a03378cd61c6f05bf391be2afc10d22afe..20571ee1147b0ab7994f3431fbc94d6df7dab47f 100755 (executable)
@@ -82,6 +82,8 @@ TESTCASE="Stress readdir"
 RUNTEST ${dirname}/test_readdir
 TESTCASE="test_proc"
 RUNTEST ${dirname}/test_proc
+TESTCASE="test_sysfs"
+RUNTEST ${dirname}/test_sysfs
 TESTCASE="test_cgroup"
 RUNTEST ${dirname}/test_cgroup
 TESTCASE="test_read_proc.sh"
index ad8699c237dea45ece80e5016026df1974aa836c..fb461d062e5dbc097b999199fe5bad18adeddfb9 100644 (file)
@@ -60,6 +60,18 @@ test_programs += custom_target(
         '@OUTPUT@',
     ])
 
+test_programs += custom_target(
+   'test_sysfs',
+    build_by_default: want_tests != false,
+    input: 'test_sysfs.in',
+    output: 'test_sysfs',
+    command: [
+        meson_render_jinja2,
+        config_h,
+        '@INPUT@',
+        '@OUTPUT@',
+    ])
+
 test_programs += custom_target(
     'test_read_proc.sh',
     build_by_default: want_tests != false,
diff --git a/tests/test_sysfs.in b/tests/test_sysfs.in
new file mode 100755 (executable)
index 0000000..6fd1ba9
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+# SPDX-License-Identifier: LGPL-2.1+
+
+set -eu
+[ -n "${DEBUG:-}" ] && set -x
+
+PASS=0
+
+cleanup() {
+    [ "$PASS" = "1" ] || (echo FAIL && exit 1)
+}
+
+trap cleanup EXIT HUP INT TERM
+
+LXCFSDIR=${LXCFSDIR:-/var/lib/lxcfs}
+
+if ! mountpoint -q ${LXCFSDIR}; then
+    echo "lxcfs isn't mounted on ${LXCFSDIR}"
+    exit 1
+fi
+
+echo "==> Setting up memory/cpuset cgroup in lxcfs_test_proc"
+[ ! -d /sys/devices/system/cpu ] && exit 0
+num_cpus="$(getconf _NPROCESSORS_CONF)"
+echo "Detected ${num_cpus} cpus"
+[ "${num_cpus}" != "0" ] 
+
+PASS=1