test-skeleton.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* Legacy test skeleton.
  2. Copyright (C) 1998-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. /* This test skeleton is to support running existing tests. New tests
  16. should use <support/test-driver.c> instead; see the documentation
  17. in that file for instructions, and <support/README-testing.c> for a
  18. minimal example. */
  19. /* This list of headers is needed so that tests which include
  20. "../test-skeleton.c" at the beginning still compile. */
  21. #include <assert.h>
  22. #include <errno.h>
  23. #include <fcntl.h>
  24. #include <getopt.h>
  25. #include <paths.h>
  26. #include <search.h>
  27. #include <signal.h>
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include <unistd.h>
  32. #include <sys/resource.h>
  33. #include <sys/wait.h>
  34. #include <sys/param.h>
  35. #include <time.h>
  36. #include <stdint.h>
  37. #include <support/support.h>
  38. #include <support/check.h>
  39. #include <support/xsignal.h>
  40. #include <support/temp_file.h>
  41. /* TEST_FUNCTION is no longer used. */
  42. static int
  43. legacy_test_function (int argc __attribute__ ((unused)),
  44. char **argv __attribute__ ((unused)))
  45. {
  46. #ifdef TEST_FUNCTION
  47. return TEST_FUNCTION;
  48. # undef TEST_FUNCTION
  49. #else
  50. return do_test (argc, argv);
  51. #endif
  52. }
  53. #define TEST_FUNCTION_ARGV legacy_test_function
  54. /* PREPARE is a function name in the new skeleton. */
  55. #ifdef PREPARE
  56. static void
  57. legacy_prepare_function (int argc __attribute__ ((unused)),
  58. char **argv __attribute__ ((unused)))
  59. {
  60. PREPARE (argc, argv);
  61. }
  62. # undef PREPARE
  63. # define PREPARE legacy_prepare_function
  64. #endif
  65. /* CLEANUP_HANDLER is a function name in the new skeleton. */
  66. #ifdef CLEANUP_HANDLER
  67. static void
  68. legacy_cleanup_handler_function (void)
  69. {
  70. CLEANUP_HANDLER;
  71. }
  72. # undef CLEANUP_HANDLER
  73. # define CLEANUP_HANDLER legacy_cleanup_handler_function
  74. #endif
  75. /* CMDLINE_PROCESS is a function name in the new skeleton. */
  76. #ifdef CMDLINE_PROCESS
  77. static void
  78. legacy_cmdline_process_function (int c)
  79. {
  80. switch (c)
  81. {
  82. CMDLINE_PROCESS
  83. }
  84. }
  85. # undef CMDLINE_PROCESS
  86. # define CMDLINE_PROCESS legacy_cmdline_process_function
  87. #endif
  88. /* Include the new test-skeleton. */
  89. #include <support/test-driver.c>
  90. /* The following functionality is only available if <pthread.h> was
  91. included before this file. */
  92. #ifdef _PTHREAD_H
  93. # include <support/xthread.h>
  94. #endif /* _PTHREAD_H */