maybe_null.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2024 Meta Platforms, Inc. and affiliates.
  4. */
  5. #include <bpf/bpf.h>
  6. #include <scx/common.h>
  7. #include <sys/wait.h>
  8. #include <unistd.h>
  9. #include "maybe_null.bpf.skel.h"
  10. #include "maybe_null_fail_dsp.bpf.skel.h"
  11. #include "maybe_null_fail_yld.bpf.skel.h"
  12. #include "scx_test.h"
  13. static enum scx_test_status run(void *ctx)
  14. {
  15. struct maybe_null *skel;
  16. struct maybe_null_fail_dsp *fail_dsp;
  17. struct maybe_null_fail_yld *fail_yld;
  18. skel = maybe_null__open_and_load();
  19. if (!skel) {
  20. SCX_ERR("Failed to open and load maybe_null skel");
  21. return SCX_TEST_FAIL;
  22. }
  23. maybe_null__destroy(skel);
  24. fail_dsp = maybe_null_fail_dsp__open_and_load();
  25. if (fail_dsp) {
  26. maybe_null_fail_dsp__destroy(fail_dsp);
  27. SCX_ERR("Should failed to open and load maybe_null_fail_dsp skel");
  28. return SCX_TEST_FAIL;
  29. }
  30. fail_yld = maybe_null_fail_yld__open_and_load();
  31. if (fail_yld) {
  32. maybe_null_fail_yld__destroy(fail_yld);
  33. SCX_ERR("Should failed to open and load maybe_null_fail_yld skel");
  34. return SCX_TEST_FAIL;
  35. }
  36. return SCX_TEST_PASS;
  37. }
  38. struct scx_test maybe_null = {
  39. .name = "maybe_null",
  40. .description = "Verify if PTR_MAYBE_NULL works for .dispatch",
  41. .run = run,
  42. };
  43. REGISTER_SCX_TEST(&maybe_null)