File: test_framework.h

package info (click to toggle)
git 1%3A2.39.5-0%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 56,868 kB
  • sloc: ansic: 276,518; sh: 234,536; perl: 30,909; tcl: 22,191; makefile: 4,185; python: 3,412; javascript: 772; csh: 45; ruby: 43; lisp: 12
file content (53 lines) | stat: -rw-r--r-- 1,944 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Copyright 2020 Google LLC

Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file or at
https://developers.google.com/open-source/licenses/bsd
*/

#ifndef TEST_FRAMEWORK_H
#define TEST_FRAMEWORK_H

#include "system.h"
#include "reftable-error.h"

#define EXPECT_ERR(c)                                                  \
	if (c != 0) {                                                  \
		fflush(stderr);                                        \
		fflush(stdout);                                        \
		fprintf(stderr, "%s: %d: error == %d (%s), want 0\n",  \
			__FILE__, __LINE__, c, reftable_error_str(c)); \
		abort();                                               \
	}

#define EXPECT_STREQ(a, b)                                               \
	if (strcmp(a, b)) {                                              \
		fflush(stderr);                                          \
		fflush(stdout);                                          \
		fprintf(stderr, "%s:%d: %s (%s) != %s (%s)\n", __FILE__, \
			__LINE__, #a, a, #b, b);                         \
		abort();                                                 \
	}

#define EXPECT(c)                                                          \
	if (!(c)) {                                                        \
		fflush(stderr);                                            \
		fflush(stdout);                                            \
		fprintf(stderr, "%s: %d: failed assertion %s\n", __FILE__, \
			__LINE__, #c);                                     \
		abort();                                                   \
	}

#define RUN_TEST(f)                          \
	fprintf(stderr, "running %s\n", #f); \
	fflush(stderr);                      \
	f();

void set_test_hash(uint8_t *p, int i);

/* Like strbuf_add, but suitable for passing to reftable_new_writer
 */
ssize_t strbuf_add_void(void *b, const void *data, size_t sz);

#endif