1 // SPDX-License-Identifier: GPL-2.0 2 #include <test_progs.h> 3 #include "timer_crash.skel.h" 4 5 enum { 6 MODE_ARRAY, 7 MODE_HASH, 8 }; 9 10 static void test_timer_crash_mode(int mode) 11 { 12 struct timer_crash *skel; 13 14 skel = timer_crash__open_and_load(); 15 if (!skel && errno == EOPNOTSUPP) { 16 test__skip(); 17 return; 18 } 19 if (!ASSERT_OK_PTR(skel, "timer_crash__open_and_load")) 20 return; 21 skel->bss->pid = getpid(); 22 skel->bss->crash_map = mode; 23 if (!ASSERT_OK(timer_crash__attach(skel), "timer_crash__attach")) 24 goto end; 25 usleep(1); 26 end: 27 timer_crash__destroy(skel); 28 } 29 30 void test_timer_crash(void) 31 { 32 if (test__start_subtest("array")) 33 test_timer_crash_mode(MODE_ARRAY); 34 if (test__start_subtest("hash")) 35 test_timer_crash_mode(MODE_HASH); 36 } 37