bpf: selftests: test_tunnel: Setup fresh topology for each subtest
authorDaniel Xu <dxu@dxuuu.xyz>
Thu, 14 Dec 2023 22:49:03 +0000 (15:49 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 15 Dec 2023 01:12:49 +0000 (17:12 -0800)
This helps with determinism b/c individual setup/teardown prevents
leaking state between different subtests.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/0fb59fa16fb58cca7def5239df606005a3e8dd0e.1702593901.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/test_tunnel.c

index d149ab98798db4e38b6f72c0c656655dcd3543ae..b57d48219d0b4e2f93c09679cf071fa3b698427e 100644 (file)
@@ -535,23 +535,20 @@ done:
 #define RUN_TEST(name, ...)                                            \
        ({                                                              \
                if (test__start_subtest(#name)) {                       \
+                       config_device();                                \
                        test_ ## name(__VA_ARGS__);                     \
+                       cleanup();                                      \
                }                                                       \
        })
 
 static void *test_tunnel_run_tests(void *arg)
 {
-       cleanup();
-       config_device();
-
        RUN_TEST(vxlan_tunnel);
        RUN_TEST(ip6vxlan_tunnel);
        RUN_TEST(ipip_tunnel, NONE);
        RUN_TEST(ipip_tunnel, FOU);
        RUN_TEST(ipip_tunnel, GUE);
 
-       cleanup();
-
        return NULL;
 }