File Index
Files and directories
Sign in
FILE

select_cpu_dispatch_bad_dsq.c

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.c C
 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 "select_cpu_dispatch_bad_dsq.bpf.skel.h"
12#include "scx_test.h"
13
14static enum scx_test_status setup(void **ctx)
15{
16	struct select_cpu_dispatch_bad_dsq *skel;
17
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
23	*ctx = skel;
24
25	return SCX_TEST_PASS;
26}
27
28static enum scx_test_status run(void *ctx)
29{
30	struct select_cpu_dispatch_bad_dsq *skel = ctx;
31	struct bpf_link *link;
32
33	link = bpf_map__attach_struct_ops(skel->maps.select_cpu_dispatch_bad_dsq_ops);
34	SCX_FAIL_IF(!link, "Failed to attach scheduler");
35
36	sleep(1);
37
38	SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_ERROR));
39	bpf_link__destroy(link);
40
41	return SCX_TEST_PASS;
42}
43
44static void cleanup(void *ctx)
45{
46	struct select_cpu_dispatch_bad_dsq *skel = ctx;
47
48	select_cpu_dispatch_bad_dsq__destroy(skel);
49}
50
51struct scx_test select_cpu_dispatch_bad_dsq = {
52	.name = "select_cpu_dispatch_bad_dsq",
53	.description = "Verify graceful failure if we direct-dispatch to a "
54		       "bogus DSQ in ops.select_cpu()",
55	.setup = setup,
56	.run = run,
57	.cleanup = cleanup,
58};
59REGISTER_SCX_TEST(&select_cpu_dispatch_bad_dsq)
~/ Read-only file preview.