diff options
| author | Nick Barnes | 2001-10-31 14:40:56 +0000 |
|---|---|---|
| committer | Nick Barnes | 2001-10-31 14:40:56 +0000 |
| commit | 7acfca905d76140f4cc0b09c9a12de237de364cd (patch) | |
| tree | 3ed8babfa3a73d30f29e08ca5d5adcda4ca4e826 /mps/code/testlib.h | |
| parent | b7ce4893f9902d57cd67ac9a92fa6c3d5a8fc833 (diff) | |
| download | emacs-7acfca905d76140f4cc0b09c9a12de237de364cd.tar.gz emacs-7acfca905d76140f4cc0b09c9a12de237de364cd.zip | |
Branch imports for masters.
Copied from Perforce
Change: 23678
ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/testlib.h')
| -rw-r--r-- | mps/code/testlib.h | 153 |
1 files changed, 153 insertions, 0 deletions
diff --git a/mps/code/testlib.h b/mps/code/testlib.h new file mode 100644 index 00000000000..0db0824c983 --- /dev/null +++ b/mps/code/testlib.h | |||
| @@ -0,0 +1,153 @@ | |||
| 1 | /* impl.h.testlib: TEST LIBRARY INTERFACE | ||
| 2 | * | ||
| 3 | * $HopeName: MMsrc!testlib.h(trunk.21) $ | ||
| 4 | * Copyright (C) 2000 Harlequin Limited. All rights reserved. | ||
| 5 | * | ||
| 6 | * .purpose: A library of functions that may be of use to unit tests. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef testlib_h | ||
| 10 | #define testlib_h | ||
| 11 | |||
| 12 | #include "mps.h" | ||
| 13 | #include "misc.h" /* for STR */ | ||
| 14 | |||
| 15 | /* Include system header hackery. */ | ||
| 16 | #include "mpstd.h" | ||
| 17 | #ifdef MPS_OS_SU | ||
| 18 | #include "ossu.h" | ||
| 19 | #endif | ||
| 20 | #ifdef MPS_OS_XC | ||
| 21 | #include "osxc.h" | ||
| 22 | #endif | ||
| 23 | |||
| 24 | #include <stdio.h> | ||
| 25 | |||
| 26 | |||
| 27 | /* Suppress Visual C warnings at warning level 4, */ | ||
| 28 | /* see mail.richard.1997-09-25.13-26. */ | ||
| 29 | /* Essentially the same settings are done in config.h. */ | ||
| 30 | |||
| 31 | #ifdef MPS_BUILD_MV | ||
| 32 | |||
| 33 | /* "unreferenced inline function has been removed" (windows.h) */ | ||
| 34 | #pragma warning(disable: 4514) | ||
| 35 | |||
| 36 | /* "constant conditional" (MPS_END) */ | ||
| 37 | #pragma warning(disable: 4127) | ||
| 38 | |||
| 39 | /* MSVC 2.0 generates a warning when using NOCHECK or UNUSED */ | ||
| 40 | #ifdef _MSC_VER | ||
| 41 | #if _MSC_VER < 1000 | ||
| 42 | #pragma warning(disable: 4705) | ||
| 43 | #endif | ||
| 44 | #else /* _MSC_VER */ | ||
| 45 | #error "Expected _MSC_VER to be defined for builder.mv" | ||
| 46 | #endif /* _MSC_VER */ | ||
| 47 | |||
| 48 | |||
| 49 | /* MSVC 10.00 on PowerPC generates erroneous warnings about */ | ||
| 50 | /* uninitialized local variables, if you take their address. */ | ||
| 51 | #ifdef MPS_ARCH_PP | ||
| 52 | #pragma warning(disable: 4701) | ||
| 53 | #endif | ||
| 54 | |||
| 55 | /* In white-hot versions, absolutely no checking is done. This leads to | ||
| 56 | * many spurious warnings because parameters are suddenly unused, etc. | ||
| 57 | * We aren't interested in these. | ||
| 58 | */ | ||
| 59 | |||
| 60 | #if defined(CONFIG_VAR_WI) | ||
| 61 | |||
| 62 | /* "unreferenced formal parameter" */ | ||
| 63 | #pragma warning(disable: 4100) | ||
| 64 | |||
| 65 | /* "unreferenced local function has been removed" */ | ||
| 66 | #pragma warning(disable: 4505) | ||
| 67 | |||
| 68 | #endif | ||
| 69 | |||
| 70 | |||
| 71 | #endif /* MPS_BUILD_MV */ | ||
| 72 | |||
| 73 | |||
| 74 | /* testlib_unused -- declares that a variable is unused | ||
| 75 | * | ||
| 76 | * It should be used to prevent compiler warnings about unused | ||
| 77 | * variables. Care should be exercised; the fact that a variable | ||
| 78 | * is unused may need justification. | ||
| 79 | */ | ||
| 80 | |||
| 81 | #define testlib_unused(v) ((void)(v)) | ||
| 82 | |||
| 83 | |||
| 84 | /* die -- succeed or die | ||
| 85 | * | ||
| 86 | * If the first argument is not ResOK then prints the second | ||
| 87 | * argument on stderr and exits the program. Otherwise does nothing. | ||
| 88 | * | ||
| 89 | * Typical use: | ||
| 90 | * die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), "APCreate"); | ||
| 91 | */ | ||
| 92 | |||
| 93 | extern void die(mps_res_t res, const char *s); | ||
| 94 | |||
| 95 | |||
| 96 | /* die_expect -- get expected result or die | ||
| 97 | * | ||
| 98 | * If the first argument is not thename as the second argument, | ||
| 99 | * prints the third argument on stderr and exits the program. | ||
| 100 | * Otherwise does nothing. | ||
| 101 | * | ||
| 102 | * Typical use: | ||
| 103 | * die_expect(res, MPS_RES_COMMIT_LIMIT, "Commit limit allocation"); | ||
| 104 | */ | ||
| 105 | |||
| 106 | extern void die_expect(mps_res_t res, mps_res_t expected, const char *s); | ||
| 107 | |||
| 108 | |||
| 109 | /* cdie -- succeed or die | ||
| 110 | * | ||
| 111 | * If the first argument is not true (non-zero) then prints the second | ||
| 112 | * argument on stderr and exits the program. Otherwise does nothing. | ||
| 113 | * | ||
| 114 | * Typical use: | ||
| 115 | * cdie(foo != NULL, "No foo"); | ||
| 116 | */ | ||
| 117 | |||
| 118 | extern void cdie(int res, const char *s); | ||
| 119 | |||
| 120 | |||
| 121 | /* error, verror -- die with message */ | ||
| 122 | |||
| 123 | extern void error(const char *format, ...); | ||
| 124 | extern void verror(const char *format, va_list args); | ||
| 125 | |||
| 126 | |||
| 127 | /* Insist -- like assert, but even in release varieties */ | ||
| 128 | |||
| 129 | #define Insist(cond) insist1(cond, #cond) | ||
| 130 | |||
| 131 | #define insist1(cond, condstring) \ | ||
| 132 | cdie(cond, condstring "\n" __FILE__ "\n" STR(__LINE__)) | ||
| 133 | |||
| 134 | |||
| 135 | /* rnd -- random number generator | ||
| 136 | * | ||
| 137 | * rnd() generates a sequence of integers in the range [0, 2^31-2]. | ||
| 138 | */ | ||
| 139 | |||
| 140 | extern unsigned long rnd(void); | ||
| 141 | |||
| 142 | |||
| 143 | /* randomize -- randomize the generator, or initialize to replay | ||
| 144 | * | ||
| 145 | * randomize(argc, argv) randomizes the rnd generator (using time(3)) | ||
| 146 | * and prints out the randomization seed, or takes a seed (as a command- | ||
| 147 | * line argument) and initializes the generator to the same state. | ||
| 148 | */ | ||
| 149 | |||
| 150 | extern void randomize(int argc, char **argv); | ||
| 151 | |||
| 152 | |||
| 153 | #endif /* testlib_h */ | ||