Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Joe Hershberger | e721b88 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Simple unit test library |
| 4 | * |
| 5 | * Copyright (c) 2013 Google, Inc |
Joe Hershberger | e721b88 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <test/test.h> |
| 10 | #include <test/ut.h> |
| 11 | |
Simon Glass | 9ce8b40 | 2015-11-08 23:47:50 -0700 | [diff] [blame] | 12 | DECLARE_GLOBAL_DATA_PTR; |
| 13 | |
Joe Hershberger | e721b88 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 14 | void ut_fail(struct unit_test_state *uts, const char *fname, int line, |
| 15 | const char *func, const char *cond) |
| 16 | { |
Simon Glass | 9ce8b40 | 2015-11-08 23:47:50 -0700 | [diff] [blame] | 17 | gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); |
Joe Hershberger | e721b88 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 18 | printf("%s:%d, %s(): %s\n", fname, line, func, cond); |
| 19 | uts->fail_count++; |
| 20 | } |
| 21 | |
| 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 | |
Simon Glass | 9ce8b40 | 2015-11-08 23:47:50 -0700 | [diff] [blame] | 27 | gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); |
Joe Hershberger | e721b88 | 2015-05-20 14:27:27 -0500 | [diff] [blame] | 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 | } |