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