Skip to content

Commit

Permalink
Merge pull request snabbco#444 from Igalia/move-soaktest-to-folder
Browse files Browse the repository at this point in the history
Move soaktest to own folder
  • Loading branch information
dpino authored Sep 20, 2016
2 parents 430edb9 + 65804a8 commit dcc8444
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 96 deletions.
36 changes: 7 additions & 29 deletions src/program/lwaftr/tests/end-to-end/core-end-to-end.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,36 +88,14 @@ function snabb_run_and_cmp {
fi
}

export SNABB_LWAFTR="../../../../snabb lwaftr"
export TEST_OUT="/tmp"
export EMPTY="../data/empty.pcap"
export COUNTERS="../data/counters"
source "test_env.sh"

source "test-data.sh"
TEST_OUT="/tmp"
SNABB_LWAFTR="../../../../snabb lwaftr"

function run_test {
index=$1
test_name="$(read_column $index)"
conf="${TEST_BASE}/$(read_column $((index + 1)))"
in_v4=$(read_column_pcap $(($index + 2)))
in_v6=$(read_column_pcap $(($index + 3)))
out_v4=$(read_column_pcap $(($index + 4)))
out_v6=$(read_column_pcap $(($index + 5)))
counters="${COUNTERS}/$(read_column $(($index + 6)))"
echo "Testing: $test_name"
snabb_run_and_cmp "$conf" "$in_v4" "$in_v6" "$out_v4" "$out_v6" "$counters"
}

function next_test {
ROW_INDEX=$(($ROW_INDEX + 7))
if [[ $ROW_INDEX -ge $TEST_SIZE ]]; then
echo "All end-to-end lwAFTR tests passed."
exit 0
fi
}

ROW_INDEX=0
while true; do
run_test $ROW_INDEX
next_test
print_test_name
snabb_run_and_cmp $(read_test_data)
next_test || break
done
echo "All end-to-end lwAFTR tests passed."
51 changes: 0 additions & 51 deletions src/program/lwaftr/tests/end-to-end/core-soaktest.sh

This file was deleted.

2 changes: 0 additions & 2 deletions src/program/lwaftr/tests/end-to-end/selftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@
cd "`dirname \"$0\"`"
./end-to-end.sh
./end-to-end-vlan.sh
./soaktest.sh
./soaktest-vlan.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
#/usr/bin/env bash

COUNTERS="../data/counters"
EMPTY="../data/empty.pcap"
TEST_INDEX=0

export COUNTERS

function read_column {
echo "${TEST_DATA[$1]}"
}

function read_column_pcap {
index=$1
column="${TEST_DATA[$index]}"
if [[ ${#column} == 0 ]]; then
echo "${EMPTY}"
else
echo "${TEST_BASE}/$column"
fi
}

function print_test_name {
test_name="$(read_column $TEST_INDEX)"
echo "Testing: $test_name"
}

function read_test_data {
conf="${TEST_BASE}/$(read_column $((TEST_INDEX + 1)))"
in_v4=$(read_column_pcap $((TEST_INDEX + 2)))
in_v6=$(read_column_pcap $((TEST_INDEX + 3)))
out_v4=$(read_column_pcap $((TEST_INDEX + 4)))
out_v6=$(read_column_pcap $((TEST_INDEX + 5)))
counters="${COUNTERS}/$(read_column $((TEST_INDEX + 6)))"
echo "$conf" "$in_v4" "$in_v6" "$out_v4" "$out_v6" "$counters"
}

function next_test {
TEST_INDEX=$(($TEST_INDEX + 7))
if [[ $TEST_INDEX -lt $TEST_SIZE ]]; then
return 0
else
return 1
fi
}

# Contains an array of test cases.
#
# A test case is a group of 7 data fields, structured as 3 rows:
Expand Down Expand Up @@ -346,17 +390,3 @@ TEST_DATA=(
"in-1p-ipv6-out-1p-ipv4-4-and-echo.lua"
)
TEST_SIZE=${#TEST_DATA[@]}

function read_column {
echo "${TEST_DATA[$1]}"
}

function read_column_pcap {
index=$1
column="${TEST_DATA[$index]}"
if [[ ${#column} == 0 ]]; then
echo "${EMPTY}"
else
echo "${TEST_BASE}/$column"
fi
}
32 changes: 32 additions & 0 deletions src/program/lwaftr/tests/soaktest/core-soaktest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi

function quit_with_msg {
errno=$1; msg="$2"
echo "Test failed: $msg"
exit $errno
}

function soaktest {
conf="$1"; in_v4="$2"; in_v6="$3"
$SNABB_LWAFTR soaktest "$conf" "$in_v4" "$in_v6" ||
quit_with_msg $? "Test failed: $SNABB_LWAFTR soaktest $@"
$SNABB_LWAFTR soaktest --on-a-stick "$conf" "$in_v4" "$in_v6" ||
quit_with_msg $? "Test failed: $SNABB_LWAFTR soaktest --on-a-stick $@"
}

source "../end-to-end/test_env.sh"

TEST_OUT="/tmp"
SNABB_LWAFTR="../../../../snabb lwaftr"

while true; do
print_test_name
soaktest $(read_test_data)
next_test || break
done
echo "All lwAFTR soak tests passed."
4 changes: 4 additions & 0 deletions src/program/lwaftr/tests/soaktest/selftest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
cd "`dirname \"$0\"`"
./soaktest.sh
./soaktest-vlan.sh

0 comments on commit dcc8444

Please sign in to comment.