From 7e8c5d7bb280b3745d0d121751d003760053d2ea Mon Sep 17 00:00:00 2001 From: Stephen Brennan Date: Wed, 17 Jul 2024 16:53:18 -0700 Subject: [PATCH] tests: Fix print_annotated_memory test on SLOB The test for print_annotated_memory() shouldn't assert anything when CONFIG_SLOB is enabled, because we can't find slab objects. However, the test shouldn't be skipped entirely, because print_annotated_memory() should run without error in this case. Skip the assertion only. Fixes: c7717280 ("helpers.common.memory: add print_annotated_memory() helper") Signed-off-by: Stephen Brennan --- tests/linux_kernel/helpers/test_common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/linux_kernel/helpers/test_common.py b/tests/linux_kernel/helpers/test_common.py index c39eabc39..43b579703 100644 --- a/tests/linux_kernel/helpers/test_common.py +++ b/tests/linux_kernel/helpers/test_common.py @@ -92,7 +92,11 @@ def test_print_annotated_memory(self): self.prog["drgn_test_small_slab_objects"].address_, sizeof(self.prog["drgn_test_small_slab_objects"]), ) - self.assertIn("slab object: drgn_test_small+0x0", f.getvalue()) + # For CONFIG_SLOB, we cannot find slab objects. However, + # print_annotated_memory() should still function with no error. So we + # don't skip the test here: just skip the assertion. + if not self.prog["drgn_test_slob"]: + self.assertIn("slab object: drgn_test_small+0x0", f.getvalue()) class TestPrintAnnotatedStack(LinuxKernelTestCase):