| 1 | /* Interfaces for the test driver. | 
|---|
| 2 | Copyright (C) 2016-2020 Free Software Foundation, Inc. | 
|---|
| 3 | This file is part of the GNU C Library. | 
|---|
| 4 |  | 
|---|
| 5 | The GNU C Library is free software; you can redistribute it and/or | 
|---|
| 6 | modify it under the terms of the GNU Lesser General Public | 
|---|
| 7 | License as published by the Free Software Foundation; either | 
|---|
| 8 | version 2.1 of the License, or (at your option) any later version. | 
|---|
| 9 |  | 
|---|
| 10 | The GNU C Library is distributed in the hope that it will be useful, | 
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 13 | Lesser General Public License for more details. | 
|---|
| 14 |  | 
|---|
| 15 | You should have received a copy of the GNU Lesser General Public | 
|---|
| 16 | License along with the GNU C Library; if not, see | 
|---|
| 17 | <https://www.gnu.org/licenses/>.  */ | 
|---|
| 18 |  | 
|---|
| 19 | #ifndef SUPPORT_TEST_DRIVER_H | 
|---|
| 20 | #define SUPPORT_TEST_DRIVER_H | 
|---|
| 21 |  | 
|---|
| 22 | #include <sys/cdefs.h> | 
|---|
| 23 |  | 
|---|
| 24 | __BEGIN_DECLS | 
|---|
| 25 |  | 
|---|
| 26 | struct test_config | 
|---|
| 27 | { | 
|---|
| 28 | void (*prepare_function) (int argc, char **argv); | 
|---|
| 29 | int (*test_function) (void); | 
|---|
| 30 | int (*test_function_argv) (int argc, char **argv); | 
|---|
| 31 | void (*cleanup_function) (void); | 
|---|
| 32 | void (*cmdline_function) (int); | 
|---|
| 33 | const void *options;   /* Custom options if not NULL.  */ | 
|---|
| 34 | int timeout;           /* Test timeout in seconds.  */ | 
|---|
| 35 | int expected_status;   /* Expected exit status.  */ | 
|---|
| 36 | int expected_signal;   /* If non-zero, expect termination by signal.  */ | 
|---|
| 37 | char no_mallopt;       /* Boolean flag to disable mallopt.  */ | 
|---|
| 38 | char no_setvbuf;       /* Boolean flag to disable setvbuf.  */ | 
|---|
| 39 | const char *optstring; /* Short command line options.  */ | 
|---|
| 40 | }; | 
|---|
| 41 |  | 
|---|
| 42 | enum | 
|---|
| 43 | { | 
|---|
| 44 | /* Test exit status which indicates that the feature is | 
|---|
| 45 | unsupported. */ | 
|---|
| 46 | EXIT_UNSUPPORTED = 77, | 
|---|
| 47 |  | 
|---|
| 48 | /* Default timeout is twenty seconds.  Tests should normally | 
|---|
| 49 | complete faster than this, but if they don't, that's abnormal | 
|---|
| 50 | (a bug) anyways.  */ | 
|---|
| 51 | DEFAULT_TIMEOUT = 20, | 
|---|
| 52 |  | 
|---|
| 53 | /* Used for command line argument parsing.  */ | 
|---|
| 54 | OPT_DIRECT = 1000, | 
|---|
| 55 | OPT_TESTDIR, | 
|---|
| 56 | }; | 
|---|
| 57 |  | 
|---|
| 58 | /* Options provided by the test driver.  */ | 
|---|
| 59 | #define TEST_DEFAULT_OPTIONS                            \ | 
|---|
| 60 | { "verbose", no_argument, NULL, 'v' },                \ | 
|---|
| 61 | { "direct", no_argument, NULL, OPT_DIRECT },          \ | 
|---|
| 62 | { "test-dir", required_argument, NULL, OPT_TESTDIR }, \ | 
|---|
| 63 |  | 
|---|
| 64 | /* The directory the test should use for temporary files.  */ | 
|---|
| 65 | extern const char *test_dir; | 
|---|
| 66 |  | 
|---|
| 67 | /* The number of --verbose arguments specified during program | 
|---|
| 68 | invocation.  This variable can be used to control the verbosity of | 
|---|
| 69 | tests.  */ | 
|---|
| 70 | extern unsigned int test_verbose; | 
|---|
| 71 |  | 
|---|
| 72 | /* Output that is only emitted if at least one --verbose argument was | 
|---|
| 73 | specified. */ | 
|---|
| 74 | #define verbose_printf(...)                      \ | 
|---|
| 75 | do {                                           \ | 
|---|
| 76 | if (test_verbose > 0)                        \ | 
|---|
| 77 | printf (__VA_ARGS__);                      \ | 
|---|
| 78 | } while (0); | 
|---|
| 79 |  | 
|---|
| 80 | int support_test_main (int argc, char **argv, const struct test_config *); | 
|---|
| 81 |  | 
|---|
| 82 | __END_DECLS | 
|---|
| 83 |  | 
|---|
| 84 | #endif /* SUPPORT_TEST_DRIVER_H */ | 
|---|
| 85 |  | 
|---|