]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
2e7d35d2 | 2 | /* |
e721b882 | 3 | * Simple unit test library |
2e7d35d2 SG |
4 | * |
5 | * Copyright (c) 2013 Google, Inc | |
2e7d35d2 SG |
6 | */ |
7 | ||
8 | #include <common.h> | |
8109863f | 9 | #include <malloc.h> |
e721b882 JH |
10 | #include <test/test.h> |
11 | #include <test/ut.h> | |
2e7d35d2 | 12 | |
9ce8b402 SG |
13 | DECLARE_GLOBAL_DATA_PTR; |
14 | ||
e721b882 | 15 | void ut_fail(struct unit_test_state *uts, const char *fname, int line, |
2e7d35d2 SG |
16 | const char *func, const char *cond) |
17 | { | |
9ce8b402 | 18 | gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); |
2e7d35d2 | 19 | printf("%s:%d, %s(): %s\n", fname, line, func, cond); |
e721b882 | 20 | uts->fail_count++; |
2e7d35d2 SG |
21 | } |
22 | ||
e721b882 | 23 | void ut_failf(struct unit_test_state *uts, const char *fname, int line, |
2e7d35d2 SG |
24 | const char *func, const char *cond, const char *fmt, ...) |
25 | { | |
26 | va_list args; | |
27 | ||
9ce8b402 | 28 | gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD); |
2e7d35d2 SG |
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'); | |
e721b882 | 34 | uts->fail_count++; |
2e7d35d2 | 35 | } |
8109863f SG |
36 | |
37 | ulong ut_check_free(void) | |
38 | { | |
39 | struct mallinfo info = mallinfo(); | |
40 | ||
41 | return info.uordblks; | |
42 | } | |
43 | ||
44 | long ut_check_delta(ulong last) | |
45 | { | |
46 | return ut_check_free() - last; | |
47 | } | |
48 |