]>
Commit | Line | Data |
---|---|---|
ef8a6c62 HWN |
1 | /* |
2 | Copyright 2020 Google LLC | |
3 | ||
4 | Use of this source code is governed by a BSD-style | |
5 | license that can be found in the LICENSE file or at | |
6 | https://developers.google.com/open-source/licenses/bsd | |
7 | */ | |
8 | ||
9 | #ifndef TEST_FRAMEWORK_H | |
10 | #define TEST_FRAMEWORK_H | |
11 | ||
12 | #include "system.h" | |
13 | #include "reftable-error.h" | |
14 | ||
e32b8ece PS |
15 | #define EXPECT_ERR(c) \ |
16 | do { \ | |
17 | if (c != 0) { \ | |
18 | fflush(stderr); \ | |
19 | fflush(stdout); \ | |
20 | fprintf(stderr, "%s: %d: error == %d (%s), want 0\n", \ | |
21 | __FILE__, __LINE__, c, reftable_error_str(c)); \ | |
22 | abort(); \ | |
23 | } \ | |
24 | } while (0) | |
25 | ||
26 | #define EXPECT_STREQ(a, b) \ | |
27 | do { \ | |
28 | if (strcmp(a, b)) { \ | |
29 | fflush(stderr); \ | |
30 | fflush(stdout); \ | |
31 | fprintf(stderr, "%s:%d: %s (%s) != %s (%s)\n", __FILE__, \ | |
32 | __LINE__, #a, a, #b, b); \ | |
33 | abort(); \ | |
34 | } \ | |
35 | } while (0) | |
36 | ||
37 | #define EXPECT(c) \ | |
38 | do { \ | |
39 | if (!(c)) { \ | |
40 | fflush(stderr); \ | |
41 | fflush(stdout); \ | |
42 | fprintf(stderr, "%s: %d: failed assertion %s\n", __FILE__, \ | |
43 | __LINE__, #c); \ | |
44 | abort(); \ | |
45 | } \ | |
46 | } while (0) | |
ef8a6c62 HWN |
47 | |
48 | #define RUN_TEST(f) \ | |
49 | fprintf(stderr, "running %s\n", #f); \ | |
50 | fflush(stderr); \ | |
51 | f(); | |
52 | ||
53 | void set_test_hash(uint8_t *p, int i); | |
54 | ||
55 | /* Like strbuf_add, but suitable for passing to reftable_new_writer | |
56 | */ | |
57 | ssize_t strbuf_add_void(void *b, const void *data, size_t sz); | |
58 | ||
59 | #endif |