selftests/sched_ext: Fix enum resolution
Subsystems (3)
Andrea Righi
reviewerPATCH 1/1 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 <[email protected]>
Signed-off-by Andrea Righi <[email protected]>
--- .../testing/selftests/sched_ext/create_dsq.c | 10 ++++---- .../selftests/sched_ext/ddsp_bogus_dsq_fail.c | 7 ++++-- .../sched_ext/ddsp_vtimelocal_fail.c | 7 ++++-- .../selftests/sched_ext/dsp_local_on.c | 1 + .../sched_ext/enq_last_no_enq_fails.c | 10 ++++---- .../sched_ext/enq_select_cpu_fails.c | 10 ++++---- tools/testing/selftests/sched_ext/exit.c | 1 + tools/testing/selftests/sched_ext/hotplug.c | 6 +++-- .../selftests/sched_ext/init_enable_count.c | 25 ++++++------------- tools/testing/selftests/sched_ext/maximal.c | 7 ++++-- tools/testing/selftests/sched_ext/minimal.c | 10 ++++---- tools/testing/selftests/sched_ext/prog_run.c | 10 ++++---- .../testing/selftests/sched_ext/reload_loop.c | 9 +++---- .../selftests/sched_ext/select_cpu_dfl.c | 7 ++++-- .../sched_ext/select_cpu_dfl_nodispatch.c | 7 ++++-- .../selftests/sched_ext/select_cpu_dispatch.c | 7 ++++-- .../sched_ext/select_cpu_dispatch_bad_dsq.c | 7 ++++-- .../sched_ext/select_cpu_dispatch_dbl_dsp.c | 7 ++++-- .../selftests/sched_ext/select_cpu_vtime.c | 7 ++++-- 19 files changed, 88 insertions(+), 67 deletions(-)
tools/testing/selftests/sched_ext/create_dsq.c +5 -5
@@ -14,11 +14,11 @@ static enum scx_test_status setup(void **ctx) {struct create_dsq *skel; - skel =create_dsq__open_and_load (); -if (!skel) { -SCX_ERR ("Failed to open and load skel" ); -return SCX_TEST_FAIL ; - } + skel =create_dsq__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (create_dsq__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.c +5 -2
@@ -15,8 +15,11 @@ static enum scx_test_status setup(void **ctx) {struct ddsp_bogus_dsq_fail *skel; - skel =ddsp_bogus_dsq_fail__open_and_load (); -SCX_FAIL_IF (!skel,"Failed to open and load skel" ); + skel =ddsp_bogus_dsq_fail__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (ddsp_bogus_dsq_fail__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.c +5 -2
@@ -14,8 +14,11 @@ static enum scx_test_status setup(void **ctx) {struct ddsp_vtimelocal_fail *skel; - skel =ddsp_vtimelocal_fail__open_and_load (); -SCX_FAIL_IF (!skel,"Failed to open and load skel" ); + skel =ddsp_vtimelocal_fail__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (ddsp_vtimelocal_fail__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/dsp_local_on.c +1 -0
@@ -15,6 +15,7 @@ static enum scx_test_status setup(void **ctx) skel =dsp_local_on__open ();SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); skel->rodata->nr_cpus =libbpf_num_possible_cpus ();SCX_FAIL_IF (dsp_local_on__load (skel),"Failed to load skel" );
tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c +5 -5
@@ -15,11 +15,11 @@ static enum scx_test_status setup(void **ctx) {struct enq_last_no_enq_fails *skel; - skel =enq_last_no_enq_fails__open_and_load (); -if (!skel) { -SCX_ERR ("Failed to open and load skel" ); -return SCX_TEST_FAIL ; - } + skel =enq_last_no_enq_fails__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (enq_last_no_enq_fails__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/enq_select_cpu_fails.c +5 -5
@@ -15,11 +15,11 @@ static enum scx_test_status setup(void **ctx) {struct enq_select_cpu_fails *skel; - skel =enq_select_cpu_fails__open_and_load (); -if (!skel) { -SCX_ERR ("Failed to open and load skel" ); -return SCX_TEST_FAIL ; - } + skel =enq_select_cpu_fails__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (enq_select_cpu_fails__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/exit.c +1 -0
@@ -23,6 +23,7 @@ static enum scx_test_status run(void *ctx)char buf[16 ]; skel =exit__open (); +SCX_ENUM_INIT (skel); skel->rodata->exit_point = tc;exit__load (skel); link =bpf_map__attach_struct_ops (skel->maps.exit_ops);
tools/testing/selftests/sched_ext/hotplug.c +4 -2
@@ -49,8 +49,10 @@ static enum scx_test_status test_hotplug(bool onlining, bool cbs_defined)SCX_ASSERT (is_cpu_online ()); - skel =hotplug__open_and_load (); -SCX_ASSERT (skel); + skel =hotplug__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (hotplug__load (skel),"Failed to load skel" );/* Testing the offline -> online path, so go offline before starting */ if (onlining)
tools/testing/selftests/sched_ext/init_enable_count.c +8 -17
@@ -15,22 +15,6 @@#define SCHED_EXT 7 -static struct init_enable_count * -open_load_prog (bool global) -{ -struct init_enable_count *skel; - - skel =init_enable_count__open (); -SCX_BUG_ON (!skel,"Failed to open skel" ); - -if (!global) - skel->struct_ops.init_enable_count_ops->flags |=SCX_OPS_SWITCH_PARTIAL ; - -SCX_BUG_ON (init_enable_count__load (skel),"Failed to load skel" ); - -return skel; -} -static enum scx_test_status run_test (bool global) {struct init_enable_count *skel;
@@ -40,7 +24,14 @@ static enum scx_test_status run_test(bool global)struct sched_param param = {};pid_t pids[num_pre_forks]; - skel =open_load_prog (global); + skel =init_enable_count__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); + +if (!global) + skel->struct_ops.init_enable_count_ops->flags |=SCX_OPS_SWITCH_PARTIAL ; + +SCX_FAIL_IF (init_enable_count__load (skel),"Failed to load skel" );/* * Fork a bunch of children before we attach the scheduler so that we
tools/testing/selftests/sched_ext/maximal.c +5 -2
@@ -14,8 +14,11 @@ static enum scx_test_status setup(void **ctx) {struct maximal *skel; - skel =maximal__open_and_load (); -SCX_FAIL_IF (!skel,"Failed to open and load skel" ); + skel =maximal__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (maximal__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/minimal.c +5 -5
@@ -15,11 +15,11 @@ static enum scx_test_status setup(void **ctx) {struct minimal *skel; - skel =minimal__open_and_load (); -if (!skel) { -SCX_ERR ("Failed to open and load skel" ); -return SCX_TEST_FAIL ; - } + skel =minimal__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (minimal__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/prog_run.c +5 -5
@@ -15,11 +15,11 @@ static enum scx_test_status setup(void **ctx) {struct prog_run *skel; - skel =prog_run__open_and_load (); -if (!skel) { -SCX_ERR ("Failed to open and load skel" ); -return SCX_TEST_FAIL ; - } + skel =prog_run__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (prog_run__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/reload_loop.c +4 -5
@@ -18,11 +18,10 @@ bool force_exit = false;static enum scx_test_status setup (void **ctx) { - skel =maximal__open_and_load (); -if (!skel) { -SCX_ERR ("Failed to open and load skel" ); -return SCX_TEST_FAIL ; - } + skel =maximal__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (maximal__load (skel),"Failed to load skel" );return SCX_TEST_PASS ; }
tools/testing/selftests/sched_ext/select_cpu_dfl.c +5 -2
@@ -17,8 +17,11 @@ static enum scx_test_status setup(void **ctx) {struct select_cpu_dfl *skel; - skel =select_cpu_dfl__open_and_load (); -SCX_FAIL_IF (!skel,"Failed to open and load skel" ); + skel =select_cpu_dfl__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (select_cpu_dfl__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/select_cpu_dfl_nodispatch.c +5 -2
@@ -17,8 +17,11 @@ static enum scx_test_status setup(void **ctx) {struct select_cpu_dfl_nodispatch *skel; - skel =select_cpu_dfl_nodispatch__open_and_load (); -SCX_FAIL_IF (!skel,"Failed to open and load skel" ); + skel =select_cpu_dfl_nodispatch__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (select_cpu_dfl_nodispatch__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/select_cpu_dispatch.c +5 -2
@@ -17,8 +17,11 @@ static enum scx_test_status setup(void **ctx) {struct select_cpu_dispatch *skel; - skel =select_cpu_dispatch__open_and_load (); -SCX_FAIL_IF (!skel,"Failed to open and load skel" ); + skel =select_cpu_dispatch__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (select_cpu_dispatch__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.c +5 -2
@@ -15,8 +15,11 @@ static enum scx_test_status setup(void **ctx) {struct select_cpu_dispatch_bad_dsq *skel; - skel =select_cpu_dispatch_bad_dsq__open_and_load (); -SCX_FAIL_IF (!skel,"Failed to open and load skel" ); + skel =select_cpu_dispatch_bad_dsq__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (select_cpu_dispatch_bad_dsq__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/select_cpu_dispatch_dbl_dsp.c +5 -2
@@ -15,8 +15,11 @@ static enum scx_test_status setup(void **ctx) {struct select_cpu_dispatch_dbl_dsp *skel; - skel =select_cpu_dispatch_dbl_dsp__open_and_load (); -SCX_FAIL_IF (!skel,"Failed to open and load skel" ); + skel =select_cpu_dispatch_dbl_dsp__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (select_cpu_dispatch_dbl_dsp__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
tools/testing/selftests/sched_ext/select_cpu_vtime.c +5 -2
@@ -15,8 +15,11 @@ static enum scx_test_status setup(void **ctx) {struct select_cpu_vtime *skel; - skel =select_cpu_vtime__open_and_load (); -SCX_FAIL_IF (!skel,"Failed to open and load skel" ); + skel =select_cpu_vtime__open (); +SCX_FAIL_IF (!skel,"Failed to open" ); +SCX_ENUM_INIT (skel); +SCX_FAIL_IF (select_cpu_vtime__load (skel),"Failed to load skel" ); + *ctx = skel;return SCX_TEST_PASS ;
Signature · 1 line
2.48.1
Quoted 10 lines · Andrea Righi
All scx enums are now automatically generated from
vmlinux.hand they must be initialized using theSCX_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 <[email protected]>Signed-off-by Andrea Righi <[email protected]>
Applied to sched_ext/for-6.14-fixes.
Thanks.
Signature · 1 line
tejun