6
6
#include <stdio.h>
7
7
#include <stdlib.h>
8
8
#include <string.h>
9
+ #ifndef CBMC
9
10
#include <time.h>
10
11
#ifndef _WIN32
11
12
#include <sys/time.h>
21
22
#endif
22
23
#undef NDEBUG
23
24
#include <assert.h>
25
+ #endif
24
26
25
27
// deprecated in clang with C++14
26
28
#if defined _LIBCPP_STD_VER && __cplusplus < 201402L
42
44
#define CLANG_DIAG_RESTORE
43
45
#endif
44
46
47
+ #ifndef CBMC
45
48
#define POD
46
49
#define T int
47
50
#include <ctl/queue.h>
@@ -52,6 +55,7 @@ typedef uint16_t u16;
52
55
#define INCLUDE_ALGORITHM
53
56
#define INCLUDE_NUMERIC
54
57
#include <ctl/string.h>
58
+ #endif
55
59
56
60
// coverage counter for generic_iter: bitmask of 3 values
57
61
union gen_cov_u {
@@ -64,13 +68,13 @@ union gen_cov_u {
64
68
};
65
69
66
70
#ifdef LONG
67
- #define TEST_MAX_SIZE ( 4096)
71
+ #define TEST_MAX_SIZE 4096
68
72
#undef TEST_MAX_LOOPS
69
- #define TEST_MAX_LOOPS ( 8096)
73
+ #define TEST_MAX_LOOPS 8096
70
74
#else
71
- #define TEST_MAX_SIZE ( 512)
75
+ #define TEST_MAX_SIZE 512
72
76
#ifndef TEST_MAX_LOOPS
73
- # define TEST_MAX_LOOPS ( 512)
77
+ # define TEST_MAX_LOOPS 512
74
78
#endif
75
79
#endif
76
80
@@ -79,7 +83,16 @@ union gen_cov_u {
79
83
#define TEST_PASS (f ) printf("%s: PASS\n", f)
80
84
#define TEST_FAIL (f ) printf("%s: FAIL\n", f)
81
85
86
+ #ifndef CBMC
82
87
#define TEST_RAND (max ) (((max) == 0) ? 0 : (int)(rand() % (max)))
88
+ #else
89
+ # define DEQ_BUCKET_SIZE 4
90
+ # undef TEST_MAX_SIZE
91
+ # undef TEST_MAX_LOOPS
92
+ # define TEST_MAX_SIZE 4
93
+ # define TEST_MAX_LOOPS 1
94
+ # define TEST_RAND (max ) (((max) == 0) ? 0 : nondet_int())
95
+ #endif
83
96
84
97
#define TEST_PERF_RUNS (100)
85
98
#define TEST_PERF_CHUNKS (256)
@@ -116,6 +129,7 @@ static inline long TEST_TIME(void)
116
129
#define INIT_SRAND const unsigned int seed = 0;
117
130
#endif
118
131
132
+ #ifndef CBMC
119
133
#define INIT_TEST_LOOPS (n , generic ) \
120
134
unsigned loops = TEST_TOTAL + TEST_RAND(TEST_MAX_LOOPS - TEST_TOTAL); \
121
135
vec_u16 covvec = vec_u16_init(); \
@@ -138,7 +152,14 @@ static inline long TEST_TIME(void)
138
152
sscanf (env , "%u" , & loops ); \
139
153
} \
140
154
loops :
155
+ #else
156
+ #define INIT_TEST_LOOPS (n , generic ) \
157
+ unsigned loops = TEST_TOTAL; \
158
+ static int test = -1;
159
+ #define FINISH_TEST (FILE )
160
+ #endif
141
161
162
+ #ifndef CBMC
142
163
#define RECORD_WHICH covvec.vector[(u16)which]++
143
164
144
165
/* check if we covered all tests. If not redo the missing tests. */
@@ -289,7 +310,8 @@ void parse_TEST(char *env, int *test, queue_int *tests, const int number_ok, boo
289
310
str_free (& alts );
290
311
}
291
312
292
- #endif
313
+ #endif // CBMC
314
+ #endif // TEST_H
293
315
294
316
#ifndef MAX
295
317
#define MAX (a , b ) (a) > (b) ? (a) : (b)
0 commit comments