[PATCH] selftest/perf: Add perf-test to perform perf testcase

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The perf test supports testing many functions and includes a way to
detect the prerequisites for each test case. Add a script to launch the
perf test.

Signed-off-by: Jeremy Szu <jszu@xxxxxxxxxx>
---
 tools/testing/selftests/Makefile          |  1 +
 tools/testing/selftests/perf/Makefile     |  5 ++++
 tools/testing/selftests/perf/perf_test.sh | 30 +++++++++++++++++++++++
 tools/testing/selftests/perf/settings     |  1 +
 4 files changed, 37 insertions(+)
 create mode 100644 tools/testing/selftests/perf/Makefile
 create mode 100755 tools/testing/selftests/perf/perf_test.sh
 create mode 100644 tools/testing/selftests/perf/settings

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 9039f3709affb..7598dd39cad28 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -67,6 +67,7 @@ TARGETS += net/openvswitch
 TARGETS += net/tcp_ao
 TARGETS += net/netfilter
 TARGETS += nsfs
+TARGETS += perf
 TARGETS += perf_events
 TARGETS += pidfd
 TARGETS += pid_namespace
diff --git a/tools/testing/selftests/perf/Makefile b/tools/testing/selftests/perf/Makefile
new file mode 100644
index 0000000000000..72d90c71ab290
--- /dev/null
+++ b/tools/testing/selftests/perf/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+TEST_PROGS := perf_test.sh
+
+include ../lib.mk
diff --git a/tools/testing/selftests/perf/perf_test.sh b/tools/testing/selftests/perf/perf_test.sh
new file mode 100755
index 0000000000000..ee78b4f9906cd
--- /dev/null
+++ b/tools/testing/selftests/perf/perf_test.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+skip() {
+    echo "SKIP: $1"
+    exit 4
+}
+
+fail() {
+    echo "FAIL: $1"
+    exit 255
+}
+
+if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
+    [ "$(id -u)" -ne 0 ] && \
+        skip "this test must be run as root."
+    which perf >/dev/null 2>&1 || \
+        skip "perf is not installed."
+
+    cmd_output=$(perf test -vv 2>&1)
+    perf_ret=$?
+
+    if [ $perf_ret -ne 0 ]; then
+        (IFS='\n'; echo $cmd_output)
+        fail "perf command returns non-zero."
+    elif [[ $cmd_output == *"FAILED!"* ]]; then
+        (IFS='\n'; echo $cmd_output)
+        fail "perf test got FAILED!"
+    fi
+fi
diff --git a/tools/testing/selftests/perf/settings b/tools/testing/selftests/perf/settings
new file mode 100644
index 0000000000000..a62d2fa1275c6
--- /dev/null
+++ b/tools/testing/selftests/perf/settings
@@ -0,0 +1 @@
+timeout=600
-- 
2.34.1





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux