new file mode 100644
@@ -0,0 +1,52 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+#
+# kselftest shell test support library
+#
+# - Define pass/fail/skip exitcodes
+# - Multiprocess support: aggregate child process results
+
+readonly KSFT_PASS=0
+readonly KSFT_FAIL=1
+readonly KSFT_SKIP=4
+
+readonly GREEN='\033[0;92m'
+readonly YELLOW='\033[0;33m'
+readonly RED='\033[0;31m'
+readonly NC='\033[0m' # No Color
+
+num_pass=0
+num_err=0
+num_skip=0
+
+# Test child process exit code, add to aggregates.
+kselftest_test_exitcode() {
+ local -r exitcode=$1
+
+ if [[ ${exitcode} -eq ${KSFT_PASS} ]]; then
+ num_pass=$(( $num_pass + 1 ))
+ elif [[ ${exitcode} -eq ${KSFT_SKIP} ]]; then
+ num_skip=$(( $num_skip + 1 ))
+ else
+ num_err=$(( $num_err + 1 ))
+ fi
+}
+
+# Exit from main process.
+kselftest_exit() {
+ echo -e "$(basename $0): PASS=${num_pass} SKIP=${num_skip} FAIL=${num_err}"
+
+ if [[ $num_err -ne 0 ]]; then
+ echo -e "$(basename $0): ${RED}FAIL${NC}"
+ exit ${KSFT_FAIL}
+ fi
+
+ if [[ $num_skip -ne 0 ]]; then
+ echo -e "$(basename $0): ${YELLOW}SKIP${NC}"
+ exit ${KSFT_SKIP}
+ fi
+
+ echo -e "$(basename $0): ${GREEN}PASS${NC}"
+ exit ${KSFT_PASS}
+}
+
@@ -3,47 +3,7 @@
#
# Run a series of udpgso benchmarks
-readonly GREEN='\033[0;92m'
-readonly YELLOW='\033[0;33m'
-readonly RED='\033[0;31m'
-readonly NC='\033[0m' # No Color
-
-readonly KSFT_PASS=0
-readonly KSFT_FAIL=1
-readonly KSFT_SKIP=4
-
-num_pass=0
-num_err=0
-num_skip=0
-
-kselftest_test_exitcode() {
- local -r exitcode=$1
-
- if [[ ${exitcode} -eq ${KSFT_PASS} ]]; then
- num_pass=$(( $num_pass + 1 ))
- elif [[ ${exitcode} -eq ${KSFT_SKIP} ]]; then
- num_skip=$(( $num_skip + 1 ))
- else
- num_err=$(( $num_err + 1 ))
- fi
-}
-
-kselftest_exit() {
- echo -e "$(basename $0): PASS=${num_pass} SKIP=${num_skip} FAIL=${num_err}"
-
- if [[ $num_err -ne 0 ]]; then
- echo -e "$(basename $0): ${RED}FAIL${NC}"
- exit ${KSFT_FAIL}
- fi
-
- if [[ $num_skip -ne 0 ]]; then
- echo -e "$(basename $0): ${YELLOW}SKIP${NC}"
- exit ${KSFT_SKIP}
- fi
-
- echo -e "$(basename $0): ${GREEN}PASS${NC}"
- exit ${KSFT_PASS}
-}
+source "$(dirname $0)/../kselftest.sh"
wake_children() {
local -r jobs="$(jobs -p)"