xref: /openbmc/u-boot/test/ut.c (revision e8f80a5a)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Simple unit test library
4  *
5  * Copyright (c) 2013 Google, Inc
6  */
7 
8 #include <common.h>
9 #include <test/test.h>
10 #include <test/ut.h>
11 
12 DECLARE_GLOBAL_DATA_PTR;
13 
ut_fail(struct unit_test_state * uts,const char * fname,int line,const char * func,const char * cond)14 void ut_fail(struct unit_test_state *uts, const char *fname, int line,
15 	     const char *func, const char *cond)
16 {
17 	gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
18 	printf("%s:%d, %s(): %s\n", fname, line, func, cond);
19 	uts->fail_count++;
20 }
21 
ut_failf(struct unit_test_state * uts,const char * fname,int line,const char * func,const char * cond,const char * fmt,...)22 void ut_failf(struct unit_test_state *uts, const char *fname, int line,
23 	      const char *func, const char *cond, const char *fmt, ...)
24 {
25 	va_list args;
26 
27 	gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
28 	printf("%s:%d, %s(): %s: ", fname, line, func, cond);
29 	va_start(args, fmt);
30 	vprintf(fmt, args);
31 	va_end(args);
32 	putc('\n');
33 	uts->fail_count++;
34 }
35