Skip to content

Commit c4519eb

Browse files
committed
Add runptf.sh script for basic forwarding PTF tests
1 parent 2e57b6c commit c4519eb

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

exercises/basic/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/
2+
ptf.log
3+
ptf.pcap
4+
ss-log.txt

exercises/basic/runptf.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# Run PTF tests for the basic forwarding exercise.
3+
# Tests run against the solution P4 program.
4+
5+
# Path to p4runtime_shell_utils and testlib
6+
T="`realpath ~/p4-guide/testlib`"
7+
if [ x"${PYTHONPATH}" == "x" ]
8+
then
9+
P="${T}"
10+
else
11+
P="${T}:${PYTHONPATH}"
12+
fi
13+
14+
set -x
15+
16+
# Compile the solution P4 program into build directory
17+
mkdir -p build
18+
p4c --target bmv2 \
19+
--arch v1model \
20+
--p4runtime-files build/basic.p4info.txtpb \
21+
-o build \
22+
solution/basic.p4
23+
24+
/bin/rm -f ss-log.txt
25+
26+
# Start simple_switch_grpc with no P4 program loaded (loaded via P4Runtime)
27+
sudo simple_switch_grpc \
28+
--log-file ss-log \
29+
--log-flush \
30+
--dump-packet-data 10000 \
31+
-i 0@veth0 \
32+
-i 1@veth2 \
33+
-i 2@veth4 \
34+
-i 3@veth6 \
35+
-i 4@veth8 \
36+
-i 5@veth10 \
37+
-i 6@veth12 \
38+
-i 7@veth14 \
39+
--no-p4 &
40+
41+
echo ""
42+
echo "Started simple_switch_grpc. Waiting 2 seconds before starting PTF test ..."
43+
sleep 2
44+
45+
# Run PTF tests
46+
sudo ${P4_EXTRA_SUDO_OPTS} `which ptf` \
47+
--pypath "$P" \
48+
-i 0@veth1 \
49+
-i 1@veth3 \
50+
-i 2@veth5 \
51+
-i 3@veth7 \
52+
-i 4@veth9 \
53+
-i 5@veth11 \
54+
-i 6@veth13 \
55+
-i 7@veth15 \
56+
--test-params="grpcaddr='localhost:9559';p4info='build/basic.p4info.txtpb';config='build/basic.json'" \
57+
--test-dir ptf
58+
59+
echo ""
60+
echo "PTF test finished. Waiting 2 seconds before killing simple_switch_grpc ..."
61+
sleep 2
62+
sudo pkill --signal 9 --list-name simple_switch
63+
echo ""
64+
echo "Verifying that there are no simple_switch_grpc processes running any longer in 4 seconds ..."
65+
sleep 4
66+
ps axguwww | grep simple_switch

0 commit comments

Comments
 (0)