summaryrefslogtreecommitdiffstats
path: root/userspace/include/unit/io.h
diff options
context:
space:
mode:
authorAlex Waterman <alexw@nvidia.com>2018-06-27 17:45:07 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-08-10 02:11:06 -0400
commit691bf904451bfe2e4c44ea05319149996abbbbf1 (patch)
tree0fe66bd37989f9d619234b7f4d2be1df6ed61c85 /userspace/include/unit/io.h
parent6e746a97cc7ee2bc5a3adee04dd9c65b3921eee5 (diff)
gpu: nvgpu: unit: Add unit testing FW
Full documentation for this is in the unit testing confluence page. JIRA NVGPU-525 Bug 2261555 Change-Id: I463e6267eb0eb12b7313f8b275266e8faabe5ccf Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1683915 GVS: Gerrit_Virtual_Submit Reviewed-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'userspace/include/unit/io.h')
-rw-r--r--userspace/include/unit/io.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/userspace/include/unit/io.h b/userspace/include/unit/io.h
new file mode 100644
index 00000000..1fd0fa43
--- /dev/null
+++ b/userspace/include/unit/io.h
@@ -0,0 +1,88 @@
1/*
2 * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef __UNIT_IO_H__
24#define __UNIT_IO_H__
25
26struct unit_fw;
27struct unit_module;
28
29/*
30 * necessary for args(fw) macro. IO will always, in general, depend on args
31 * since the args will specify where IO should be directed to.
32 */
33#include <unit/args.h>
34
35#define core_msg(fw, msg, ...) \
36 core_vbs(fw, 0, msg, ##__VA_ARGS__)
37#define core_msg_color(fw, color, msg, ...) \
38 core_vbs_color(fw, color, 0, msg, ##__VA_ARGS__)
39
40#define core_vbs_color(fw, color, lvl, msg, ...) \
41 do { \
42 if ((lvl) > args(fw)->verbose_lvl) \
43 continue; \
44 \
45 /* Print if verbosity level is high enough. */ \
46 __core_print_stdout(fw, color, msg, ##__VA_ARGS__); \
47 } while (0)
48#define core_vbs(fw, lvl, msg, ...) \
49 core_vbs_color(fw, NULL, lvl, msg, ##__VA_ARGS__)
50
51#define core_err(fw, msg, ...) \
52 __core_print_stderr(fw, "(%s:%d) " msg, \
53 __func__, __LINE__, ##__VA_ARGS__)
54
55/*
56 * Output macro for unit tests to use.
57 */
58#define unit_info(unit, msg, ...) \
59 __unit_info_color(unit, NULL, msg, ##__VA_ARGS__)
60#define unit_err(unit, msg, ...) \
61 __unit_info_color(unit, C_RED, msg, ##__VA_ARGS__)
62
63/*
64 * Don't go overboard with these!!!
65 */
66#define C_RED "\x1B[31m"
67#define C_GREEN "\x1B[32m"
68#define C_YELLOW "\x1B[33m"
69#define C_BLUE "\x1B[34m"
70#define C_MAGENTA "\x1B[35m"
71#define C_CYAN "\x1B[36m"
72#define C_WHITE "\x1B[37m"
73#define C_RESET "\x1B[0m"
74
75/*
76 * Printing functions. Do not use these directly. Instead use the provided
77 * macros.
78 */
79__attribute__((format (printf, 3, 4)))
80void __core_print_stdout(struct unit_fw *fw, const char *color,
81 const char *fmt, ...);
82__attribute__((format (printf, 2, 3)))
83void __core_print_stderr(struct unit_fw *fw, const char *fmt, ...);
84__attribute__((format (printf, 3, 4)))
85void __unit_info_color(struct unit_module *unit, const char *color,
86 const char *fmt, ...);
87
88#endif