#! /bin/sh
# SPDX-License-Identifier: BSD-3-Clause

# Test that libmptcpwrap injects MPTCP into the socket() system call.
#
# Copyright (c) 2021-2022, Intel Corporation

set -e

# An exit status of 77 causes the Automake test driver to consider the
# test as skipped.
skip_exit_status=77

# Check if we're using the upstream kernel.
#
# upstream:          /proc/sys/net/mptcp/enabled
# multipath-tcp.org: /proc/sys/net/mptcp/mptcp_enabled
if [ ! -f /proc/sys/net/mptcp/enabled ]; then
    # Skip the test if we're not using the upstream kernel.
    echo Not running upstream kernel.  libmptcpwrap will not be tested.
    exit $skip_exit_status
fi

LD_PRELOAD=../src/.libs/libmptcpwrap.so \
MPTCPWRAP_DEBUG=1 \
./mptcpwrap-tester
