Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/sched_ext: Fix enum resolution

All scx enums are now automatically generated from vmlinux.h and they
must be initialized using the SCX_ENUM_INIT() macro.

Fix the scx selftests to use this macro to properly initialize these
values.

Fixes: 8da7bf2cee27 ("tools/sched_ext: Receive updates from SCX repo")
Reported-by: Ihor Solodrai <ihor.solodrai@pm.me>
Closes: https://lore.kernel.org/all/Z2tNK2oFDX1OPp8C@slm.duckdns.org/
Signed-off-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Andrea Righi and committed by
Tejun Heo
74ca3343 2279563e

+88 -67
+5 -5
tools/testing/selftests/sched_ext/create_dsq.c
··· 14 14 { 15 15 struct create_dsq *skel; 16 16 17 - skel = create_dsq__open_and_load(); 18 - if (!skel) { 19 - SCX_ERR("Failed to open and load skel"); 20 - return SCX_TEST_FAIL; 21 - } 17 + skel = create_dsq__open(); 18 + SCX_FAIL_IF(!skel, "Failed to open"); 19 + SCX_ENUM_INIT(skel); 20 + SCX_FAIL_IF(create_dsq__load(skel), "Failed to load skel"); 21 + 22 22 *ctx = skel; 23 23 24 24 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.c
··· 15 15 { 16 16 struct ddsp_bogus_dsq_fail *skel; 17 17 18 - skel = ddsp_bogus_dsq_fail__open_and_load(); 19 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 18 + skel = ddsp_bogus_dsq_fail__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(ddsp_bogus_dsq_fail__load(skel), "Failed to load skel"); 22 + 20 23 *ctx = skel; 21 24 22 25 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.c
··· 14 14 { 15 15 struct ddsp_vtimelocal_fail *skel; 16 16 17 - skel = ddsp_vtimelocal_fail__open_and_load(); 18 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 17 + skel = ddsp_vtimelocal_fail__open(); 18 + SCX_FAIL_IF(!skel, "Failed to open"); 19 + SCX_ENUM_INIT(skel); 20 + SCX_FAIL_IF(ddsp_vtimelocal_fail__load(skel), "Failed to load skel"); 21 + 19 22 *ctx = skel; 20 23 21 24 return SCX_TEST_PASS;
+1
tools/testing/selftests/sched_ext/dsp_local_on.c
··· 15 15 16 16 skel = dsp_local_on__open(); 17 17 SCX_FAIL_IF(!skel, "Failed to open"); 18 + SCX_ENUM_INIT(skel); 18 19 19 20 skel->rodata->nr_cpus = libbpf_num_possible_cpus(); 20 21 SCX_FAIL_IF(dsp_local_on__load(skel), "Failed to load skel");
+5 -5
tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c
··· 15 15 { 16 16 struct enq_last_no_enq_fails *skel; 17 17 18 - skel = enq_last_no_enq_fails__open_and_load(); 19 - if (!skel) { 20 - SCX_ERR("Failed to open and load skel"); 21 - return SCX_TEST_FAIL; 22 - } 18 + skel = enq_last_no_enq_fails__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(enq_last_no_enq_fails__load(skel), "Failed to load skel"); 22 + 23 23 *ctx = skel; 24 24 25 25 return SCX_TEST_PASS;
+5 -5
tools/testing/selftests/sched_ext/enq_select_cpu_fails.c
··· 15 15 { 16 16 struct enq_select_cpu_fails *skel; 17 17 18 - skel = enq_select_cpu_fails__open_and_load(); 19 - if (!skel) { 20 - SCX_ERR("Failed to open and load skel"); 21 - return SCX_TEST_FAIL; 22 - } 18 + skel = enq_select_cpu_fails__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(enq_select_cpu_fails__load(skel), "Failed to load skel"); 22 + 23 23 *ctx = skel; 24 24 25 25 return SCX_TEST_PASS;
+1
tools/testing/selftests/sched_ext/exit.c
··· 23 23 char buf[16]; 24 24 25 25 skel = exit__open(); 26 + SCX_ENUM_INIT(skel); 26 27 skel->rodata->exit_point = tc; 27 28 exit__load(skel); 28 29 link = bpf_map__attach_struct_ops(skel->maps.exit_ops);
+4 -2
tools/testing/selftests/sched_ext/hotplug.c
··· 49 49 50 50 SCX_ASSERT(is_cpu_online()); 51 51 52 - skel = hotplug__open_and_load(); 53 - SCX_ASSERT(skel); 52 + skel = hotplug__open(); 53 + SCX_FAIL_IF(!skel, "Failed to open"); 54 + SCX_ENUM_INIT(skel); 55 + SCX_FAIL_IF(hotplug__load(skel), "Failed to load skel"); 54 56 55 57 /* Testing the offline -> online path, so go offline before starting */ 56 58 if (onlining)
+8 -17
tools/testing/selftests/sched_ext/init_enable_count.c
··· 15 15 16 16 #define SCHED_EXT 7 17 17 18 - static struct init_enable_count * 19 - open_load_prog(bool global) 20 - { 21 - struct init_enable_count *skel; 22 - 23 - skel = init_enable_count__open(); 24 - SCX_BUG_ON(!skel, "Failed to open skel"); 25 - 26 - if (!global) 27 - skel->struct_ops.init_enable_count_ops->flags |= SCX_OPS_SWITCH_PARTIAL; 28 - 29 - SCX_BUG_ON(init_enable_count__load(skel), "Failed to load skel"); 30 - 31 - return skel; 32 - } 33 - 34 18 static enum scx_test_status run_test(bool global) 35 19 { 36 20 struct init_enable_count *skel; ··· 24 40 struct sched_param param = {}; 25 41 pid_t pids[num_pre_forks]; 26 42 27 - skel = open_load_prog(global); 43 + skel = init_enable_count__open(); 44 + SCX_FAIL_IF(!skel, "Failed to open"); 45 + SCX_ENUM_INIT(skel); 46 + 47 + if (!global) 48 + skel->struct_ops.init_enable_count_ops->flags |= SCX_OPS_SWITCH_PARTIAL; 49 + 50 + SCX_FAIL_IF(init_enable_count__load(skel), "Failed to load skel"); 28 51 29 52 /* 30 53 * Fork a bunch of children before we attach the scheduler so that we
+5 -2
tools/testing/selftests/sched_ext/maximal.c
··· 14 14 { 15 15 struct maximal *skel; 16 16 17 - skel = maximal__open_and_load(); 18 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 17 + skel = maximal__open(); 18 + SCX_FAIL_IF(!skel, "Failed to open"); 19 + SCX_ENUM_INIT(skel); 20 + SCX_FAIL_IF(maximal__load(skel), "Failed to load skel"); 21 + 19 22 *ctx = skel; 20 23 21 24 return SCX_TEST_PASS;
+5 -5
tools/testing/selftests/sched_ext/minimal.c
··· 15 15 { 16 16 struct minimal *skel; 17 17 18 - skel = minimal__open_and_load(); 19 - if (!skel) { 20 - SCX_ERR("Failed to open and load skel"); 21 - return SCX_TEST_FAIL; 22 - } 18 + skel = minimal__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(minimal__load(skel), "Failed to load skel"); 22 + 23 23 *ctx = skel; 24 24 25 25 return SCX_TEST_PASS;
+5 -5
tools/testing/selftests/sched_ext/prog_run.c
··· 15 15 { 16 16 struct prog_run *skel; 17 17 18 - skel = prog_run__open_and_load(); 19 - if (!skel) { 20 - SCX_ERR("Failed to open and load skel"); 21 - return SCX_TEST_FAIL; 22 - } 18 + skel = prog_run__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(prog_run__load(skel), "Failed to load skel"); 22 + 23 23 *ctx = skel; 24 24 25 25 return SCX_TEST_PASS;
+4 -5
tools/testing/selftests/sched_ext/reload_loop.c
··· 18 18 19 19 static enum scx_test_status setup(void **ctx) 20 20 { 21 - skel = maximal__open_and_load(); 22 - if (!skel) { 23 - SCX_ERR("Failed to open and load skel"); 24 - return SCX_TEST_FAIL; 25 - } 21 + skel = maximal__open(); 22 + SCX_FAIL_IF(!skel, "Failed to open"); 23 + SCX_ENUM_INIT(skel); 24 + SCX_FAIL_IF(maximal__load(skel), "Failed to load skel"); 26 25 27 26 return SCX_TEST_PASS; 28 27 }
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dfl.c
··· 17 17 { 18 18 struct select_cpu_dfl *skel; 19 19 20 - skel = select_cpu_dfl__open_and_load(); 21 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 20 + skel = select_cpu_dfl__open(); 21 + SCX_FAIL_IF(!skel, "Failed to open"); 22 + SCX_ENUM_INIT(skel); 23 + SCX_FAIL_IF(select_cpu_dfl__load(skel), "Failed to load skel"); 24 + 22 25 *ctx = skel; 23 26 24 27 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.c
··· 17 17 { 18 18 struct select_cpu_dfl_nodispatch *skel; 19 19 20 - skel = select_cpu_dfl_nodispatch__open_and_load(); 21 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 20 + skel = select_cpu_dfl_nodispatch__open(); 21 + SCX_FAIL_IF(!skel, "Failed to open"); 22 + SCX_ENUM_INIT(skel); 23 + SCX_FAIL_IF(select_cpu_dfl_nodispatch__load(skel), "Failed to load skel"); 24 + 22 25 *ctx = skel; 23 26 24 27 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dispatch.c
··· 17 17 { 18 18 struct select_cpu_dispatch *skel; 19 19 20 - skel = select_cpu_dispatch__open_and_load(); 21 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 20 + skel = select_cpu_dispatch__open(); 21 + SCX_FAIL_IF(!skel, "Failed to open"); 22 + SCX_ENUM_INIT(skel); 23 + SCX_FAIL_IF(select_cpu_dispatch__load(skel), "Failed to load skel"); 24 + 22 25 *ctx = skel; 23 26 24 27 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.c
··· 15 15 { 16 16 struct select_cpu_dispatch_bad_dsq *skel; 17 17 18 - skel = select_cpu_dispatch_bad_dsq__open_and_load(); 19 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 18 + skel = select_cpu_dispatch_bad_dsq__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(select_cpu_dispatch_bad_dsq__load(skel), "Failed to load skel"); 22 + 20 23 *ctx = skel; 21 24 22 25 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.c
··· 15 15 { 16 16 struct select_cpu_dispatch_dbl_dsp *skel; 17 17 18 - skel = select_cpu_dispatch_dbl_dsp__open_and_load(); 19 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 18 + skel = select_cpu_dispatch_dbl_dsp__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(select_cpu_dispatch_dbl_dsp__load(skel), "Failed to load skel"); 22 + 20 23 *ctx = skel; 21 24 22 25 return SCX_TEST_PASS;
+5 -2
tools/testing/selftests/sched_ext/select_cpu_vtime.c
··· 15 15 { 16 16 struct select_cpu_vtime *skel; 17 17 18 - skel = select_cpu_vtime__open_and_load(); 19 - SCX_FAIL_IF(!skel, "Failed to open and load skel"); 18 + skel = select_cpu_vtime__open(); 19 + SCX_FAIL_IF(!skel, "Failed to open"); 20 + SCX_ENUM_INIT(skel); 21 + SCX_FAIL_IF(select_cpu_vtime__load(skel), "Failed to load skel"); 22 + 20 23 *ctx = skel; 21 24 22 25 return SCX_TEST_PASS;