minimal.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 "minimal.bpf.skel.h"
  12. #include "scx_test.h"
  13. static enum scx_test_status setup(void **ctx)
  14. {
  15. struct minimal *skel;
  16. skel = minimal__open_and_load();
  17. if (!skel) {
  18. SCX_ERR("Failed to open and load skel");
  19. return SCX_TEST_FAIL;
  20. }
  21. *ctx = skel;
  22. return SCX_TEST_PASS;
  23. }
  24. static enum scx_test_status run(void *ctx)
  25. {
  26. struct minimal *skel = ctx;
  27. struct bpf_link *link;
  28. link = bpf_map__attach_struct_ops(skel->maps.minimal_ops);
  29. if (!link) {
  30. SCX_ERR("Failed to attach scheduler");
  31. return SCX_TEST_FAIL;
  32. }
  33. bpf_link__destroy(link);
  34. return SCX_TEST_PASS;
  35. }
  36. static void cleanup(void *ctx)
  37. {
  38. struct minimal *skel = ctx;
  39. minimal__destroy(skel);
  40. }
  41. struct scx_test minimal = {
  42. .name = "minimal",
  43. .description = "Verify we can load a fully minimal scheduler",
  44. .setup = setup,
  45. .run = run,
  46. .cleanup = cleanup,
  47. };
  48. REGISTER_SCX_TEST(&minimal)