Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / sched_ext / enq_last_no_enq_fails.c
blob73e679953e27ae15d7341450b6137273db849179
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright (c) 2023 Meta Platforms, Inc. and affiliates.
4 * Copyright (c) 2023 David Vernet <dvernet@meta.com>
5 * Copyright (c) 2023 Tejun Heo <tj@kernel.org>
6 */
7 #include <bpf/bpf.h>
8 #include <scx/common.h>
9 #include <sys/wait.h>
10 #include <unistd.h>
11 #include "enq_last_no_enq_fails.bpf.skel.h"
12 #include "scx_test.h"
14 static enum scx_test_status setup(void **ctx)
16 struct enq_last_no_enq_fails *skel;
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;
23 *ctx = skel;
25 return SCX_TEST_PASS;
28 static enum scx_test_status run(void *ctx)
30 struct enq_last_no_enq_fails *skel = ctx;
31 struct bpf_link *link;
33 link = bpf_map__attach_struct_ops(skel->maps.enq_last_no_enq_fails_ops);
34 if (!link) {
35 SCX_ERR("Incorrectly failed at attaching scheduler");
36 return SCX_TEST_FAIL;
38 if (!skel->bss->exit_kind) {
39 SCX_ERR("Incorrectly stayed loaded");
40 return SCX_TEST_FAIL;
43 bpf_link__destroy(link);
45 return SCX_TEST_PASS;
48 static void cleanup(void *ctx)
50 struct enq_last_no_enq_fails *skel = ctx;
52 enq_last_no_enq_fails__destroy(skel);
55 struct scx_test enq_last_no_enq_fails = {
56 .name = "enq_last_no_enq_fails",
57 .description = "Verify we eject a scheduler if we specify "
58 "the SCX_OPS_ENQ_LAST flag without defining "
59 "ops.enqueue()",
60 .setup = setup,
61 .run = run,
62 .cleanup = cleanup,
64 REGISTER_SCX_TEST(&enq_last_no_enq_fails)