Skip to content

Commit 74ca334

Browse files
arighihtejun
authored andcommitted
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: 8da7bf2 ("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>
1 parent 2279563 commit 74ca334

19 files changed

+88
-67
lines changed

tools/testing/selftests/sched_ext/create_dsq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ static enum scx_test_status setup(void **ctx)
1414
{
1515
struct create_dsq *skel;
1616

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+
2222
*ctx = skel;
2323

2424
return SCX_TEST_PASS;

tools/testing/selftests/sched_ext/ddsp_bogus_dsq_fail.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ static enum scx_test_status setup(void **ctx)
1515
{
1616
struct ddsp_bogus_dsq_fail *skel;
1717

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+
2023
*ctx = skel;
2124

2225
return SCX_TEST_PASS;

tools/testing/selftests/sched_ext/ddsp_vtimelocal_fail.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ static enum scx_test_status setup(void **ctx)
1414
{
1515
struct ddsp_vtimelocal_fail *skel;
1616

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+
1922
*ctx = skel;
2023

2124
return SCX_TEST_PASS;

tools/testing/selftests/sched_ext/dsp_local_on.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ static enum scx_test_status setup(void **ctx)
1515

1616
skel = dsp_local_on__open();
1717
SCX_FAIL_IF(!skel, "Failed to open");
18+
SCX_ENUM_INIT(skel);
1819

1920
skel->rodata->nr_cpus = libbpf_num_possible_cpus();
2021
SCX_FAIL_IF(dsp_local_on__load(skel), "Failed to load skel");

tools/testing/selftests/sched_ext/enq_last_no_enq_fails.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ static enum scx_test_status setup(void **ctx)
1515
{
1616
struct enq_last_no_enq_fails *skel;
1717

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+
2323
*ctx = skel;
2424

2525
return SCX_TEST_PASS;

tools/testing/selftests/sched_ext/enq_select_cpu_fails.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ static enum scx_test_status setup(void **ctx)
1515
{
1616
struct enq_select_cpu_fails *skel;
1717

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+
2323
*ctx = skel;
2424

2525
return SCX_TEST_PASS;

tools/testing/selftests/sched_ext/exit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ static enum scx_test_status run(void *ctx)
2323
char buf[16];
2424

2525
skel = exit__open();
26+
SCX_ENUM_INIT(skel);
2627
skel->rodata->exit_point = tc;
2728
exit__load(skel);
2829
link = bpf_map__attach_struct_ops(skel->maps.exit_ops);

tools/testing/selftests/sched_ext/hotplug.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ static enum scx_test_status test_hotplug(bool onlining, bool cbs_defined)
4949

5050
SCX_ASSERT(is_cpu_online());
5151

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");
5456

5557
/* Testing the offline -> online path, so go offline before starting */
5658
if (onlining)

tools/testing/selftests/sched_ext/init_enable_count.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,6 @@
1515

1616
#define SCHED_EXT 7
1717

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-
3418
static enum scx_test_status run_test(bool global)
3519
{
3620
struct init_enable_count *skel;
@@ -40,7 +24,14 @@ static enum scx_test_status run_test(bool global)
4024
struct sched_param param = {};
4125
pid_t pids[num_pre_forks];
4226

43-
skel = open_load_prog(global);
27+
skel = init_enable_count__open();
28+
SCX_FAIL_IF(!skel, "Failed to open");
29+
SCX_ENUM_INIT(skel);
30+
31+
if (!global)
32+
skel->struct_ops.init_enable_count_ops->flags |= SCX_OPS_SWITCH_PARTIAL;
33+
34+
SCX_FAIL_IF(init_enable_count__load(skel), "Failed to load skel");
4435

4536
/*
4637
* Fork a bunch of children before we attach the scheduler so that we

tools/testing/selftests/sched_ext/maximal.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ static enum scx_test_status setup(void **ctx)
1414
{
1515
struct maximal *skel;
1616

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+
1922
*ctx = skel;
2023

2124
return SCX_TEST_PASS;

0 commit comments

Comments
 (0)