-
Notifications
You must be signed in to change notification settings - Fork 299
/
Copy pathselftest.sh
executable file
·96 lines (86 loc) · 2.62 KB
/
selftest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
echo "selftest: packetblaster"
# do tests first that don't require PCI
function test_lwaftr_pcap {
PCAP=$1
shift
TEMP_PCAP=/tmp/lwaftr$$.pcap
echo "testing lwaftr pcap $PCAP ..."
./snabb packetblaster lwaftr --pcap $TEMP_PCAP $@
status=$?
if [ $status != 0 ]; then
echo "Error: lwaftr pcap generation failed for ${PCAP} with ${status}"
rm $TEMP_PCAP
exit 1
fi
if ! which tcpdump; then
echo "Error: no tcpdump to compare packets"
rm $TEMP_PCAP
exit 43
fi
cmp $TEMP_PCAP $PCAP
tcpdump -venr $TEMP_PCAP | sort > $TEMP_PCAP.txt
rm $TEMP_PCAP
diffies=$(tcpdump -venr $PCAP | sort | diff -u /dev/stdin $TEMP_PCAP.txt)
rm $TEMP_PCAP.txt
if test -n "$diffies"; then
echo "Error: lwaftr generated pcap differs from ${PCAP}:"
echo "$diffies"
exit 1
fi
}
test_lwaftr_pcap program/packetblaster/lwaftr/test_lwaftr_1.pcap --count 1
test_lwaftr_pcap program/packetblaster/lwaftr/test_lwaftr_2.pcap --count 2 --vlan 100 --size 64
# lwaftr tap test
sudo ip netns add snabbtest || exit $TEST_SKIPPED
sudo ip netns exec snabbtest ip tuntap add tap0 mode tap
sudo ip netns exec snabbtest ip link set up dev tap0
sudo ip netns exec snabbtest ./snabb packetblaster lwaftr --tap tap0 -D 1
status=$?
ip netns exec snabbtest ifconfig tap0
sudo ip netns delete snabbtest
if [ $status != 0 ]; then
echo "Error: lwaftr tap failed for tap0 with ${status}"
exit 1
fi
export PCIADDR=$SNABB_PCI_INTEL0
[ ! -z "$PCIADDR" ] || export PCIADDR=$SNABB_PCI0
if [ -z "${PCIADDR}" ]; then
echo "selftest: skipping test - SNABB_PCI_INTEL0/SNABB_PCI0 not set"
exit 43
fi
# Simple test: Just make sure packetblaster runs for a period of time
# (doesn't crash on startup).
echo "packetblaster replay"
timeout 5 ./snabb packetblaster replay program/snabbnfv/test_fixtures/pcap/64.pcap ${PCIADDR}
status=$?
if [ $status != 124 ]; then
echo "Error: expected timeout (124) but got ${status}"
exit 1
else
echo "ok"
fi
echo "packetblaster synth"
timeout 5 ./snabb packetblaster synth --src 11:11:11:11:11:11 --dst 22:22:22:22:22:22 --sizes 64,128,256 ${PCIADDR}
status=$?
if [ $status != 124 ]; then
echo "Error: expected timeout (124) but got ${status}"
exit 1
else
echo "ok"
fi
if [ "$PCIADDR" = "$SNABB_PCI_INTEL0" ]; then
echo "packetblaster lwaftr --pci"
timeout 5 ./snabb packetblaster lwaftr --pci ${PCIADDR}
status=$?
if [ $status != 124 ]; then
echo "Error: expected timeout (124) but got ${status}"
exit 1
else
echo "ok"
fi
else
echo 'Skipping ./snabb packetblaster lwaftr --pci ${PCIADDR}'
echo '${PCIADDR} is not ${SNABB_PCI_INTEL0}'
fi
echo "selftest: ok"