summaryrefslogtreecommitdiff
path: root/410user/libtest/report.h
blob: 496754b77b4f853ebe61577854061e5fafa97078 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/** @file 410user/libtest/report.h
 *  @brief Test reporting interface
 *  @author elly1 U2009
 */

#ifndef LIBTEST_REPORT_H
#define LIBTEST_REPORT_H

extern const char* test_name;     /* Defined by the test in question with
                                   * DEF_TEST_NAME() */

enum {
    START_CMPLT = 0,
    START_ABORT = 1,
    START_4EVER = 2,
};

/** @brief Formats a test start message into a buffer.
 *  @param buf Buffer to format into.
 *  @param len Length of the buffer.
 *  @param type Type of test start.
 *  @return Void.
 */
extern void format_start(char *buf, int len, int type);

/** @brief Reports the start of a test.
 *  @param type Type of test start.
 */
extern void report_start(int type);

enum {
    END_SUCCESS = 0,
    END_FAIL = 1,
};

/** @brief Formats a test end message into a buffer.
 *  @param buf Buffer to format into.
 *  @param len Length of the buffer.
 *  @param type Type of test ending.
 *  @return Void.
 */
extern void format_end(char *buf, int len, int type);

/** @brief Reports the end of a test.
 *  @param type Type of test end.
 */
extern void report_end(int type);

/** @brief Formats a miscellaneous message into a buffer.
 *  @param buf Buffer to format into.
 *  @param len Length of the buffer.
 *  @param msg Message to format.
 *  @return Void.
 */
extern void format_misc(char *buf, int len, const char *msg);

/** @brief Report a miscellaneous happenstance.
 *  @param msg Happenstance.
 *  @return Void.
 */
extern void report_misc(const char *msg);

/** @brief Report an arbitrary formatted message.
 *  @param fmt Format.
 *  @param ... Varargs.
 *  @return Void.
 */
extern void report_fmt(const char *fmt, ...);

/** @brief Formats an error message into a buffer.
 *  @param buf Buffer to format into.
 *  @param len Length of the buffer.
 *  @param msg Message to format.
 *  @param code Error code.
 *  @return Void.
 */
extern void format_err(char *buf, int len, const char *msg, int code);

/** @brief Report an error.
 *  @param msg Error message.
 *  @param code Error code.
 *  @return Void.
 */
extern void report_err(const char *msg, int code);

/** @brief Report an error, and fail out.
 *  @param msg Error message.
 *  @param code Error code.
 *  @return Void.
 */
extern void report_fatal(const char *msg, int code);

/** @brief Require that an expression succeed.
 *  @param exp Expression, as a string.
 *  @param line Line number of the expression.
 *  @param v Expression value.
 *  @return Void.
 */
extern void report_on_err(const char *exp, int line, int v);

/** @brief Fail the test if an expression fails.
 *  @param exp Expression, as a string.
 *  @param line Line number of the expression.
 *  @param v Expression value.
 *  @return Void.
 */
extern void fatal_on_err(const char *exp, int line, int v);

#endif /* !LIBTEST_REPORT_H */