maximal.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. static enum scx_test_status setup(void **ctx)
  13. {
  14. struct maximal *skel;
  15. skel = maximal__open();
  16. SCX_FAIL_IF(!skel, "Failed to open");
  17. SCX_ENUM_INIT(skel);
  18. SCX_FAIL_IF(maximal__load(skel), "Failed to load skel");
  19. *ctx = skel;
  20. return SCX_TEST_PASS;
  21. }
  22. static enum scx_test_status run(void *ctx)
  23. {
  24. struct maximal *skel = ctx;
  25. struct bpf_link *link;
  26. link = bpf_map__attach_struct_ops(skel->maps.maximal_ops);
  27. SCX_FAIL_IF(!link, "Failed to attach scheduler");
  28. bpf_link__destroy(link);
  29. return SCX_TEST_PASS;
  30. }
  31. static void cleanup(void *ctx)
  32. {
  33. struct maximal *skel = ctx;
  34. maximal__destroy(skel);
  35. }
  36. struct scx_test maximal = {
  37. .name = "maximal",
  38. .description = "Verify we can load a scheduler with every callback defined",
  39. .setup = setup,
  40. .run = run,
  41. .cleanup = cleanup,
  42. };
  43. REGISTER_SCX_TEST(&maximal)