nolibc.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "../config-host.h"
  2. /* SPDX-License-Identifier: MIT */
  3. /*
  4. * Test liburing nolibc functionality.
  5. *
  6. * Currently, supported architectures are:
  7. * 1) x86
  8. * 2) x86-64
  9. * 3) aarch64
  10. *
  11. */
  12. #include "helpers.h"
  13. #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__)
  14. /*
  15. * This arch doesn't support nolibc.
  16. */
  17. int main(void)
  18. {
  19. return T_EXIT_SKIP;
  20. }
  21. #else /* #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) */
  22. #ifndef CONFIG_NOLIBC
  23. #define CONFIG_NOLIBC
  24. #endif
  25. #include <stdio.h>
  26. #include <unistd.h>
  27. #include "../src/lib.h"
  28. static int test_get_page_size(void)
  29. {
  30. long a, b;
  31. a = sysconf(_SC_PAGESIZE);
  32. b = get_page_size();
  33. if (a != b) {
  34. fprintf(stderr, "get_page_size() fails, %ld != %ld", a, b);
  35. return -1;
  36. }
  37. return 0;
  38. }
  39. int main(int argc, char *argv[])
  40. {
  41. int ret;
  42. if (argc > 1)
  43. return T_EXIT_SKIP;
  44. ret = test_get_page_size();
  45. if (ret)
  46. return T_EXIT_FAIL;
  47. return T_EXIT_PASS;
  48. }
  49. #endif /* #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) */