create_dsq.c 1.1 KB

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