1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2024 Meta Platforms, Inc. and affiliates. 4 * Copyright (c) 2024 David Vernet <dvernet@meta.com> 5 */ 6 #include <bpf/bpf.h> 7 #include <scx/common.h> 8 #include <sys/wait.h> 9 #include <unistd.h> 10 #include "maximal.bpf.skel.h" 11 #include "scx_test.h" 12 13 static enum scx_test_status setup(void **ctx) 14 { 15 struct maximal *skel; 16 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 22 bpf_map__set_autoattach(skel->maps.maximal_ops, false); 23 SCX_FAIL_IF(maximal__attach(skel), "Failed to attach skel"); 24 25 *ctx = skel; 26 27 return SCX_TEST_PASS; 28 } 29 30 static enum scx_test_status run(void *ctx) 31 { 32 struct maximal *skel = ctx; 33 struct bpf_link *link; 34 35 link = bpf_map__attach_struct_ops(skel->maps.maximal_ops); 36 SCX_FAIL_IF(!link, "Failed to attach scheduler"); 37 38 bpf_link__destroy(link); 39 40 return SCX_TEST_PASS; 41 } 42 43 static void cleanup(void *ctx) 44 { 45 struct maximal *skel = ctx; 46 47 maximal__destroy(skel); 48 } 49 50 struct scx_test maximal = { 51 .name = "maximal", 52 .description = "Verify we can load a scheduler with every callback defined", 53 .setup = setup, 54 .run = run, 55 .cleanup = cleanup, 56 }; 57 REGISTER_SCX_TEST(&maximal) 58