test-driver.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Interfaces for the test driver.
  2. Copyright (C) 2016-2019 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. <http://www.gnu.org/licenses/>. */
  15. #ifndef SUPPORT_TEST_DRIVER_H
  16. #define SUPPORT_TEST_DRIVER_H
  17. #include <sys/cdefs.h>
  18. __BEGIN_DECLS
  19. struct test_config
  20. {
  21. void (*prepare_function) (int argc, char **argv);
  22. int (*test_function) (void);
  23. int (*test_function_argv) (int argc, char **argv);
  24. void (*cleanup_function) (void);
  25. void (*cmdline_function) (int);
  26. const void *options; /* Custom options if not NULL. */
  27. int timeout; /* Test timeout in seconds. */
  28. int expected_status; /* Expected exit status. */
  29. int expected_signal; /* If non-zero, expect termination by signal. */
  30. char no_mallopt; /* Boolean flag to disable mallopt. */
  31. char no_setvbuf; /* Boolean flag to disable setvbuf. */
  32. const char *optstring; /* Short command line options. */
  33. };
  34. enum
  35. {
  36. /* Test exit status which indicates that the feature is
  37. unsupported. */
  38. EXIT_UNSUPPORTED = 77,
  39. /* Default timeout is twenty seconds. Tests should normally
  40. complete faster than this, but if they don't, that's abnormal
  41. (a bug) anyways. */
  42. DEFAULT_TIMEOUT = 20,
  43. /* Used for command line argument parsing. */
  44. OPT_DIRECT = 1000,
  45. OPT_TESTDIR,
  46. };
  47. /* Options provided by the test driver. */
  48. #define TEST_DEFAULT_OPTIONS \
  49. { "verbose", no_argument, NULL, 'v' }, \
  50. { "direct", no_argument, NULL, OPT_DIRECT }, \
  51. { "test-dir", required_argument, NULL, OPT_TESTDIR }, \
  52. /* The directory the test should use for temporary files. */
  53. extern const char *test_dir;
  54. /* The number of --verbose arguments specified during program
  55. invocation. This variable can be used to control the verbosity of
  56. tests. */
  57. extern unsigned int test_verbose;
  58. int support_test_main (int argc, char **argv, const struct test_config *);
  59. __END_DECLS
  60. #endif /* SUPPORT_TEST_DRIVER_H */