]> Git Repo - J-linux.git/blob - tools/testing/selftests/sched_ext/select_cpu_vtime.c
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / tools / testing / selftests / sched_ext / select_cpu_vtime.c
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2024 Meta Platforms, Inc. and affiliates.
4  * Copyright (c) 2024 David Vernet <[email protected]>
5  * Copyright (c) 2024 Tejun Heo <[email protected]>
6  */
7 #include <bpf/bpf.h>
8 #include <scx/common.h>
9 #include <sys/wait.h>
10 #include <unistd.h>
11 #include "select_cpu_vtime.bpf.skel.h"
12 #include "scx_test.h"
13
14 static enum scx_test_status setup(void **ctx)
15 {
16         struct select_cpu_vtime *skel;
17
18         skel = select_cpu_vtime__open_and_load();
19         SCX_FAIL_IF(!skel, "Failed to open and load skel");
20         *ctx = skel;
21
22         return SCX_TEST_PASS;
23 }
24
25 static enum scx_test_status run(void *ctx)
26 {
27         struct select_cpu_vtime *skel = ctx;
28         struct bpf_link *link;
29
30         SCX_ASSERT(!skel->bss->consumed);
31
32         link = bpf_map__attach_struct_ops(skel->maps.select_cpu_vtime_ops);
33         SCX_FAIL_IF(!link, "Failed to attach scheduler");
34
35         sleep(1);
36
37         SCX_ASSERT(skel->bss->consumed);
38
39         bpf_link__destroy(link);
40
41         return SCX_TEST_PASS;
42 }
43
44 static void cleanup(void *ctx)
45 {
46         struct select_cpu_vtime *skel = ctx;
47
48         select_cpu_vtime__destroy(skel);
49 }
50
51 struct scx_test select_cpu_vtime = {
52         .name = "select_cpu_vtime",
53         .description = "Test doing direct vtime-dispatching from "
54                        "ops.select_cpu(), to a non-built-in DSQ",
55         .setup = setup,
56         .run = run,
57         .cleanup = cleanup,
58 };
59 REGISTER_SCX_TEST(&select_cpu_vtime)
This page took 0.026078 seconds and 4 git commands to generate.