t5551: handle v2 protocol when checking curl trace
[git/debian.git] / reftable / test_framework.h
blob774cb275bf679440b804d86370c8858c9e0b1bd2
1 /*
2 Copyright 2020 Google LLC
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 */
9 #ifndef TEST_FRAMEWORK_H
10 #define TEST_FRAMEWORK_H
12 #include "system.h"
13 #include "reftable-error.h"
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(); \
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(); \
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(); \
42 #define RUN_TEST(f) \
43 fprintf(stderr, "running %s\n", #f); \
44 fflush(stderr); \
45 f();
47 void set_test_hash(uint8_t *p, int i);
49 /* Like strbuf_add, but suitable for passing to reftable_new_writer
51 ssize_t strbuf_add_void(void *b, const void *data, size_t sz);
53 #endif