File: utest.h

package info (click to toggle)
bart-cuda 0.8.00-2
  • links: PTS, VCS
  • area: contrib
  • in suites: bookworm, sid
  • size: 7,752 kB
  • sloc: ansic: 100,267; python: 717; makefile: 576; sh: 564; cpp: 104
file content (48 lines) | stat: -rw-r--r-- 1,198 bytes parent folder | download | duplicates (2)
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
/* Copyright 2016. The Regents of the University of California.
 * Copyright 2016. Martin Uecker.
 * All rights reserved. Use of this source code is governed by
 * a BSD-style license which can be found in the LICENSE file.
 *
 * Authors:
 * 2016 Jonathan Tamir <jtamir@eecs.berkeley.edu>
 * 2016 Martin Uecker <martin.uecker@med.uni-goettingen.de>
 */


#ifndef _UTEST_H
#define _UTEST_H

#include <stdbool.h>

#include "misc/debug.h"
#include "misc/misc.h"


#define UT_ASSERT(test)	\
	return ((test) || (debug_printf(DP_ERROR, "%s:%d assertion `%s` failed.\n", __func__, __LINE__, #test), false))

#define UT_ASSERT2(test)	\
	if (!(test)) return (debug_printf(DP_ERROR, "%s:%d assertion `%s` failed.\n", __func__, __LINE__, #test), false)

#define UT_TOL 1E-6


typedef bool ut_test_f(void);

#if 0
#define UT_REGISTER_TEST(x) \
	ut_test_f* ptr_ ## x __attribute__((section(".utest"))) = &x;
#else
#define UT_REGISTER_TEST(x) 				\
	extern bool call_ ## x(void);			\
	extern bool call_ ## x(void) { return x(); };
#endif

#define UT_GPU_REGISTER_TEST(x) UT_REGISTER_TEST(x)

#define UT_UNUSED_TEST(x) 				\
	extern void unused_ ## x(void);			\
	extern void unused_ ## x(void) { x(); };


#endif