Changeset View
Standalone View
tests/sys/tcptestsuite/tcptestsuite_test.sh
- This file was added.
#!/usr/bin/env atf-sh | |||||
asomers: You can leave out the shebang. The build process adds it. | |||||
vangyzenAuthorUnsubmitted Done Inline ActionsI added it mostly as documentation for humans, and possibly for editors as a syntax highlighting hint. vangyzen: I added it mostly as documentation for humans, and possibly for editors as a syntax… | |||||
# | |||||
# SPDX-License-Identifier: BSD-2-Clause | |||||
# | |||||
# Copyright (c) 2019 Dell Inc. | |||||
# | |||||
# Written by: Eric van Gyzen <vangyzen@FreeBSD.org> | |||||
# | |||||
# Redistribution and use in source and binary forms, with or without | |||||
# modification, are permitted provided that the following conditions | |||||
# are met: | |||||
# 1. Redistributions of source code must retain the above copyright | |||||
# notice, this list of conditions and the following disclaimer. | |||||
# 2. Redistributions in binary form must reproduce the above copyright | |||||
# notice, this list of conditions and the following disclaimer in the | |||||
# documentation and/or other materials provided with the distribution. | |||||
# | |||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
# SUCH DAMAGE. | |||||
# | |||||
# $FreeBSD$ | |||||
tcptestsuite_path=/usr/local/share/tcptestsuite | |||||
packetdrill_path=/usr/local/bin/packetdrill | |||||
make_script() { | |||||
if [ ! -d $tcptestsuite_path ]; then | |||||
asomersUnsubmitted Not Done Inline ActionsThis is way too complicated. Instead, just put an atf_require_prog tcptestsuite and atf_require_prog packetdrill in each test case's body. Or better yet, just add TESTS_METADATA+= required_programs="packetdrill tcptestsuite" to the Makefile. asomers: This is way too complicated. Instead, just put an `atf_require_prog tcptestsuite` and… | |||||
vangyzenAuthorUnsubmitted Done Inline ActionsNote that tcptestsuite is just a directory, not a program. I wasn't sure how to use this metadata to specify a required directory (and I wanted to get this out for review sooner, which I'm glad I did, due to your feedback). vangyzen: Note that `tcptestsuite` is just a directory, not a program. I wasn't sure how to use this… | |||||
# Generate a stub test that fails. | |||||
cat <<EOF | |||||
atf_test_case skip | |||||
skip_body() { | |||||
atf_skip "Install the tcptestsuite port/package." | |||||
} | |||||
atf_init_test_cases() { | |||||
atf_add_test_case skip | |||||
} | |||||
EOF | |||||
return 1 | |||||
fi | |||||
all_tests=$(mktemp -t tcptestsuite_test) || exit 1 | |||||
(cd $tcptestsuite_path && find * -type f -and -name '*.pkt') | \ | |||||
asomersUnsubmitted Not Done Inline Actionsfind . works better than find *. Same output, but no shell globbing. asomers: `find .` works better than `find *`. Same output, but no shell globbing. | |||||
vangyzenAuthorUnsubmitted Done Inline ActionsThe output is different: it begins with ./. It was important to avoid this in an earlier draft. Now it would be fine. vangyzen: The output is different: it begins with `./`. It was important to avoid this in an earlier… | |||||
sed 's/\.pkt$//' | \ | |||||
grep -vx blacklist > $all_tests | |||||
while read Torig; do | |||||
Tunder=$(basename $Torig | tr - _) | |||||
cat <<EOF | |||||
atf_test_case $Tunder | |||||
${Tunder}_body() { | |||||
atf_require_prog ${packetdrill_path} | |||||
atf_check -o ignore timeout 10 ${packetdrill_path} \ | |||||
${tcptestsuite_path}/${Torig}.pkt | |||||
sleep 0.1 | |||||
asomersUnsubmitted Not Done Inline ActionsWhy the sleep? asomers: Why the sleep? | |||||
vangyzenAuthorUnsubmitted Done Inline ActionsBecause the main script(s) in the tcp-testsuite repo sleep between each test. This is a WIP, and the review is mostly a place to discuss it with @tuexen. vangyzen: Because the main script(s) in the tcp-testsuite repo sleep between each test. This is a WIP… | |||||
} | |||||
EOF | |||||
done < $all_tests | |||||
echo 'atf_init_test_cases() {' | |||||
while read Torig; do | |||||
Tunder=$(basename $Torig | tr - _) | |||||
echo " atf_add_test_case ${Tunder}" | |||||
done < $all_tests | |||||
echo '}' | |||||
rm $all_tests | |||||
} | |||||
atf_script=$(mktemp -t tcptestsuite_test) || exit 1 | |||||
make_script > $atf_script | |||||
. $atf_script | |||||
rm $atf_script |
You can leave out the shebang. The build process adds it.