maximal.c 1.0 KB

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