]>
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 | ||
15 | #define EXPECT_ERR(c) \ | |
16 | if (c != 0) { \ | |
17 | fflush(stderr); \ | |
18 | fflush(stdout); \ | |
19 | fprintf(stderr, "%s: %d: error == %d (%s), want 0\n", \ | |
20 | __FILE__, __LINE__, c, reftable_error_str(c)); \ | |
21 | abort(); \ | |
22 | } | |
23 | ||
24 | #define EXPECT_STREQ(a, b) \ | |
25 | if (strcmp(a, b)) { \ | |
26 | fflush(stderr); \ | |
27 | fflush(stdout); \ | |
28 | fprintf(stderr, "%s:%d: %s (%s) != %s (%s)\n", __FILE__, \ | |
29 | __LINE__, #a, a, #b, b); \ | |
30 | abort(); \ | |
31 | } | |
32 | ||
33 | #define EXPECT(c) \ | |
34 | if (!(c)) { \ | |
35 | fflush(stderr); \ | |
36 | fflush(stdout); \ | |
37 | fprintf(stderr, "%s: %d: failed assertion %s\n", __FILE__, \ | |
38 | __LINE__, #c); \ | |
39 | abort(); \ | |
40 | } | |
41 | ||
42 | #define RUN_TEST(f) \ | |
43 | fprintf(stderr, "running %s\n", #f); \ | |
44 | fflush(stderr); \ | |
45 | f(); | |
46 | ||
47 | void set_test_hash(uint8_t *p, int i); | |
48 | ||
49 | /* Like strbuf_add, but suitable for passing to reftable_new_writer | |
50 | */ | |
51 | ssize_t strbuf_add_void(void *b, const void *data, size_t sz); | |
52 | ||
53 | #endif |