blob: 55798041bafe937370fc69bc9899000ccf766efe [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Joe Hershberger3a77be52015-05-20 14:27:27 -05002/*
3 * Simple unit test library
4 *
5 * Copyright (c) 2013 Google, Inc
Joe Hershberger3a77be52015-05-20 14:27:27 -05006 */
7
8#include <common.h>
9#include <test/test.h>
10#include <test/ut.h>
11
Simon Glassfe6d12a2015-11-08 23:47:50 -070012DECLARE_GLOBAL_DATA_PTR;
13
Joe Hershberger3a77be52015-05-20 14:27:27 -050014void ut_fail(struct unit_test_state *uts, const char *fname, int line,
15 const char *func, const char *cond)
16{
Simon Glassfe6d12a2015-11-08 23:47:50 -070017 gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
Joe Hershberger3a77be52015-05-20 14:27:27 -050018 printf("%s:%d, %s(): %s\n", fname, line, func, cond);
19 uts->fail_count++;
20}
21
22void 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
Simon Glassfe6d12a2015-11-08 23:47:50 -070027 gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
Joe Hershberger3a77be52015-05-20 14:27:27 -050028 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}