linux-zen-desktop/tools/testing/selftests/net/mptcp/mptcp_lib.sh

41 lines
865 B
Bash
Raw Normal View History

2023-08-30 17:31:07 +02:00
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
readonly KSFT_FAIL=1
readonly KSFT_SKIP=4
# SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set when validating all
# features using the last version of the kernel and the selftests to make sure
# a test is not being skipped by mistake.
mptcp_lib_expect_all_features() {
[ "${SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES:-}" = "1" ]
}
# $1: msg
mptcp_lib_fail_if_expected_feature() {
if mptcp_lib_expect_all_features; then
echo "ERROR: missing feature: ${*}"
exit ${KSFT_FAIL}
fi
return 1
}
# $1: file
mptcp_lib_has_file() {
local f="${1}"
if [ -f "${f}" ]; then
return 0
fi
mptcp_lib_fail_if_expected_feature "${f} file not found"
}
mptcp_lib_check_mptcp() {
if ! mptcp_lib_has_file "/proc/sys/net/mptcp/enabled"; then
echo "SKIP: MPTCP support is not available"
exit ${KSFT_SKIP}
fi
}