1#! /bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4readonly KSFT_FAIL=1 5readonly KSFT_SKIP=4 6 7# SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES env var can be set when validating all 8# features using the last version of the kernel and the selftests to make sure 9# a test is not being skipped by mistake. 10mptcp_lib_expect_all_features() { 11 [ "${SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES:-}" = "1" ] 12} 13 14# $1: msg 15mptcp_lib_fail_if_expected_feature() { 16 if mptcp_lib_expect_all_features; then 17 echo "ERROR: missing feature: ${*}" 18 exit ${KSFT_FAIL} 19 fi 20 21 return 1 22} 23 24# $1: file 25mptcp_lib_has_file() { 26 local f="${1}" 27 28 if [ -f "${f}" ]; then 29 return 0 30 fi 31 32 mptcp_lib_fail_if_expected_feature "${f} file not found" 33} 34 35mptcp_lib_check_mptcp() { 36 if ! mptcp_lib_has_file "/proc/sys/net/mptcp/enabled"; then 37 echo "SKIP: MPTCP support is not available" 38 exit ${KSFT_SKIP} 39 fi 40} 41