Skip to content

Commit

Permalink
new(test): test that --no-cleanup works
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Di Donato <[email protected]>
  • Loading branch information
leodido committed Jun 1, 2022
1 parent d3f4c52 commit cd9dead
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions test/cli.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,44 @@ setup() {
teardown() {
echo "# teardown:" >&3

killall traffico || true
killall traffico &>/dev/null || true
del_netdev
del_netns "${NETNS}"
}

@test "install nop program at egress" {
run ip netns exec "${NETNS}" traffico -i peer0 nop >/dev/null 3>&- &
run ip netns exec "${NETNS}" traffico -i "${PEER}" nop >/dev/null 3>&- &
sleep 1
run ip netns exec "${NETNS}" tc qdisc show dev peer0 clsact
run ip netns exec "${NETNS}" tc qdisc show dev "${PEER}" clsact
[ "$(echo $output | xargs)" == "qdisc clsact ffff: parent ffff:fff1" ]
}

@test "install nop program at ingress" {
run ip netns exec "${NETNS}" traffico -i peer0 --at ingress nop >/dev/null 3>&- &
run ip netns exec "${NETNS}" traffico -i "${PEER}" --at ingress nop >/dev/null 3>&- &
sleep 1
run ip netns exec "${NETNS}" tc qdisc show dev peer0 clsact
run ip netns exec "${NETNS}" tc qdisc show dev "${PEER}" clsact
[ "$(echo $output | xargs)" == "qdisc clsact ffff: parent ffff:fff1" ]
}

@test "--no-cleanup works" {
echo "# traffico up at interface ${PEER}" >&3
run ip netns exec "${NETNS}" traffico --no-cleanup -i "${PEER}" --at ingress nop >/dev/null 3>&- &
sleep 1
run ip netns exec "${NETNS}" tc qdisc show dev "${PEER}" clsact
[ "$(echo $output | xargs)" == "qdisc clsact ffff: parent ffff:fff1" ]
killall traffico
echo "# traffico down" >&3
sleep 1
run ip netns exec "${NETNS}" tc qdisc show dev "${PEER}" clsact
[ "$(echo $output | xargs)" == "qdisc clsact ffff: parent ffff:fff1" ]
echo "# tc qdisc still there" >&3
run bpftool prog show name nop
OUT=${lines[0]##*: } >&3
[ "${OUT%% *}" == "sched_cls" ]
echo "# BPF program still there" >&3
run ip netns exec "${NETNS}" tc qdisc del dev "${PEER}" clsact
}

@test "block_private_ipv4 blocks ICMP packets" {
run ip netns exec "${NETNS}" ping -W1 -4 -c1 10.22.1.2
[ $status -eq 0 ]
Expand Down

0 comments on commit cd9dead

Please sign in to comment.