Messages in this thread | | | From | Willem de Bruijn <> | Date | Tue, 21 Jul 2020 11:04:06 -0400 | Subject | Re: [PATCH] selftests: txtimestamp: tear down setup() 'tc' and 'ip' env on EXIT |
| |
On Tue, Jul 21, 2020 at 10:52 AM Paolo Pisati <paolo.pisati@canonical.com> wrote: > > Add a cleanup() path upon exit, making it possible to run the test twice in a > row: > > $ sudo bash -x ./txtimestamp.sh > + set -e > ++ ip netns identify > + [[ '' == \r\o\o\t ]] > + main > + [[ 0 -eq 0 ]] > + run_test_all > + setup > + tc qdisc add dev lo root netem delay 1ms > Error: Exclusivity flag on, cannot modify. > > Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
The test should already clean up after itself, by being run inside a network namespace. That is a more robust method to ensure that all state is reset.
The issue here is that the else branch is taken in
if [[ "$(ip netns identify)" == "root" ]]; then ./in_netns.sh $0 $@ else main $@ fi
because the ip netns identify usually returns an empty string, not "root". If we fix that, no need to add additional cleanup.
| |