From 8de83fdd9abaee8aca14203770420601a6ffe690 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Tue, 8 Sep 2020 16:02:24 -0600 Subject: [PATCH] tests: add tests for deferred interface teardown (refcounting) --- tests/fixtures/deferred-teardown-1.ifstate | 6 ++++ tests/fixtures/deferred-teardown-1.interfaces | 9 ++++++ tests/fixtures/deferred-teardown-2.ifstate | 5 ++++ tests/fixtures/deferred-teardown-2.interfaces | 11 +++++++ tests/ifdown_test | 30 +++++++++++++++++++ 5 files changed, 61 insertions(+) create mode 100644 tests/fixtures/deferred-teardown-1.ifstate create mode 100644 tests/fixtures/deferred-teardown-1.interfaces create mode 100644 tests/fixtures/deferred-teardown-2.ifstate create mode 100644 tests/fixtures/deferred-teardown-2.interfaces diff --git a/tests/fixtures/deferred-teardown-1.ifstate b/tests/fixtures/deferred-teardown-1.ifstate new file mode 100644 index 0000000..188647b --- /dev/null +++ b/tests/fixtures/deferred-teardown-1.ifstate @@ -0,0 +1,6 @@ +lo=lo 1 +br0=br0 1 +bond0=bond0 2 +eth0=eth0 3 +eth1=eth1 2 +tun0=tun0 1 diff --git a/tests/fixtures/deferred-teardown-1.interfaces b/tests/fixtures/deferred-teardown-1.interfaces new file mode 100644 index 0000000..61930e2 --- /dev/null +++ b/tests/fixtures/deferred-teardown-1.interfaces @@ -0,0 +1,9 @@ +auto br0 +iface br0 + requires bond0 + +iface bond0 + requires eth0 eth1 + +iface tun0 + requires eth0 diff --git a/tests/fixtures/deferred-teardown-2.ifstate b/tests/fixtures/deferred-teardown-2.ifstate new file mode 100644 index 0000000..23f77d7 --- /dev/null +++ b/tests/fixtures/deferred-teardown-2.ifstate @@ -0,0 +1,5 @@ +eth0=eth0 5 +tun0=tun0 1 +tun1=tun1 1 +tun2=tun2 1 +tun3=tun3 1 diff --git a/tests/fixtures/deferred-teardown-2.interfaces b/tests/fixtures/deferred-teardown-2.interfaces new file mode 100644 index 0000000..b7ecc98 --- /dev/null +++ b/tests/fixtures/deferred-teardown-2.interfaces @@ -0,0 +1,11 @@ +iface tun0 + requires eth0 + +iface tun1 + requires eth0 + +iface tun2 + requires eth0 + +iface tun3 + requires eth0 diff --git a/tests/ifdown_test b/tests/ifdown_test index 3a8510a..8f2e7bf 100755 --- a/tests/ifdown_test +++ b/tests/ifdown_test @@ -19,6 +19,9 @@ tests_init \ learned_dependency_2 \ learned_executor \ implicit_vlan \ + deferred_teardown_1 \ + deferred_teardown_2 \ + deferred_teardown_3 \ regress_opt_f noargs_body() { @@ -142,6 +145,33 @@ implicit_vlan_body() { ifdown -n -S $FIXTURES/vlan.ifstate -E $EXECUTORS -i $FIXTURES/vlan.interfaces eth0.8 } +deferred_teardown_1_body() { + atf_check -s exit:0 -o ignore \ + -e match:"skipping dependent interface eth0 \\(of bond0\\) -- transient dependencies still exist" \ + -e match:"changing state of dependent interface eth1 \\(of bond0\\) to down" \ + ifdown -n -S $FIXTURES/deferred-teardown-1.ifstate -E $EXECUTORS \ + -i $FIXTURES/deferred-teardown-1.interfaces br0 +} + +deferred_teardown_2_body() { + atf_check -s exit:0 -o ignore \ + -e match:"skipping dependent interface eth0 \\(of tun0\\) -- transient dependencies still exist" \ + -e match:"skipping dependent interface eth0 \\(of tun1\\) -- transient dependencies still exist" \ + -e match:"skipping dependent interface eth0 \\(of tun2\\) -- transient dependencies still exist" \ + ifdown -n -S $FIXTURES/deferred-teardown-2.ifstate -E $EXECUTORS \ + -i $FIXTURES/deferred-teardown-2.interfaces tun0 tun1 tun2 +} + +deferred_teardown_3_body() { + atf_check -s exit:0 -o ignore \ + -e match:"skipping dependent interface eth0 \\(of tun0\\) -- transient dependencies still exist" \ + -e match:"skipping dependent interface eth0 \\(of tun1\\) -- transient dependencies still exist" \ + -e match:"skipping dependent interface eth0 \\(of tun2\\) -- transient dependencies still exist" \ + -e match:"changing state of dependent interface eth0 \\(of tun3\\) to down" \ + ifdown -n -S $FIXTURES/deferred-teardown-2.ifstate -E $EXECUTORS \ + -i $FIXTURES/deferred-teardown-2.interfaces tun0 tun1 tun2 tun3 +} + regress_opt_f_body() { atf_check -s exit:0 -o ignore -e ignore \ ifdown -n -S $FIXTURES/vlan.ifstate -E $EXECUTORS -i $FIXTURES/vlan.interfaces -f eth0.8