1 | /*
|
---|
2 | * TOPPERS Software
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
4 | *
|
---|
5 | * Copyright (C) 2005-2011 by Embedded and Real-Time Systems Laboratory
|
---|
6 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
7 | *
|
---|
8 | * ãLì ÒÍCȺÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
|
---|
9 | * Ai{\tgEFAðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»Eü
|
---|
10 | * ÏEÄzziȺCpÆÄÔj·é±Æð³Åø·éD
|
---|
11 | * (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
12 | * \¦C±Ìpð¨æѺL̳ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
13 | * XR[hÉÜÜêÄ¢é±ÆD
|
---|
14 | * (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
15 | * pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
16 | gip
|
---|
17 | * Ò}j
|
---|
18 | AÈÇjÉCãLÌì \¦C±Ìpð¨æѺL
|
---|
19 | * ̳ÛØKèðfÚ·é±ÆD
|
---|
20 | * (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
21 | * pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
22 | * ÆD
|
---|
23 | * (a) Äzzɺ¤hL
|
---|
24 | gipÒ}j
|
---|
25 | AÈÇjÉCãLÌ
|
---|
26 | * ì \¦C±Ìpð¨æѺL̳ÛØKèðfÚ·é±ÆD
|
---|
27 | * (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
28 | * ñ·é±ÆD
|
---|
29 | * (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
30 | * Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
31 | * ܽC{\tgEFAÌ[UܽÍGh[U©çÌ¢©Èé
|
---|
32 | * RÉîÿ©çàCãLì Ò¨æÑTOPPERSvWFNgð
|
---|
33 | * ÆÓ·é±ÆD
|
---|
34 | *
|
---|
35 | * {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
36 | * æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
|
---|
37 | * ÉηéK«àÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEF
|
---|
38 | * AÌpÉæè¼ÚIܽÍÔÚIɶ¶½¢©Èé¹QÉÖµÄàC»
|
---|
39 | * ÌÓCðíÈ¢D
|
---|
40 | *
|
---|
41 | * @(#) $Id: test_lib.c 2067 2011-05-05 00:46:29Z ertl-hiro $
|
---|
42 | */
|
---|
43 |
|
---|
44 | /*
|
---|
45 | * eXgvOpCu
|
---|
46 | */
|
---|
47 |
|
---|
48 | #include <kernel.h>
|
---|
49 | #include <sil.h>
|
---|
50 | #include <t_syslog.h>
|
---|
51 | #include <t_stdlib.h>
|
---|
52 | #include <log_output.h>
|
---|
53 | #include "syssvc/syslog.h"
|
---|
54 | #include "target_syssvc.h"
|
---|
55 | #include "test_lib.h"
|
---|
56 |
|
---|
57 | /*
|
---|
58 | * `FbN|Cg
|
---|
59 | */
|
---|
60 | static uint_t check_count = 0u;
|
---|
61 |
|
---|
62 | /*
|
---|
63 | * ©ÈffÖ
|
---|
64 | */
|
---|
65 | static BIT_FUNC check_bit_func = NULL;
|
---|
66 |
|
---|
67 | /*
|
---|
68 | * ©ÈffÖÌÝè
|
---|
69 | */
|
---|
70 | void
|
---|
71 | set_bit_func(BIT_FUNC bit_func)
|
---|
72 | {
|
---|
73 | check_bit_func = bit_func;
|
---|
74 | }
|
---|
75 |
|
---|
76 | /*
|
---|
77 | * VXeOÌoÍ
|
---|
78 | */
|
---|
79 | void
|
---|
80 | syslog_flush(void)
|
---|
81 | {
|
---|
82 | SYSLOG syslog;
|
---|
83 | ER_UINT rercd;
|
---|
84 |
|
---|
85 | /*
|
---|
86 | * Oobt@ÉL^³ê½OîñðCáxoÍ@\ðp¢Äo
|
---|
87 | * Í·éD
|
---|
88 | */
|
---|
89 | while ((rercd = syslog_rea_log(&syslog)) >= 0) {
|
---|
90 | if (rercd > 0) {
|
---|
91 | syslog_lostmsg((uint_t) rercd, target_fput_log);
|
---|
92 | }
|
---|
93 | if (syslog.logtype >= LOG_TYPE_COMMENT) {
|
---|
94 | syslog_print(&syslog, target_fput_log);
|
---|
95 | target_fput_log('\n');
|
---|
96 | }
|
---|
97 | }
|
---|
98 | }
|
---|
99 |
|
---|
100 | /*
|
---|
101 | * eXgvOÌI¹
|
---|
102 | */
|
---|
103 | void
|
---|
104 | test_finish(void)
|
---|
105 | {
|
---|
106 | SIL_PRE_LOC;
|
---|
107 |
|
---|
108 | SIL_LOC_INT();
|
---|
109 | syslog_flush();
|
---|
110 | ext_ker();
|
---|
111 |
|
---|
112 | /* ±±Öé±ÆÍȢ͸ */
|
---|
113 | SIL_UNL_INT();
|
---|
114 | }
|
---|
115 |
|
---|
116 | /*
|
---|
117 | * `FbN|Cg
|
---|
118 | */
|
---|
119 | void
|
---|
120 | check_point(uint_t count)
|
---|
121 | {
|
---|
122 | bool_t errorflag = false;
|
---|
123 | ER rercd;
|
---|
124 | SIL_PRE_LOC;
|
---|
125 |
|
---|
126 | /*
|
---|
127 | * ÝbNóÔÉ
|
---|
128 | */
|
---|
129 | SIL_LOC_INT();
|
---|
130 |
|
---|
131 | /*
|
---|
132 | * V[PX`FbN
|
---|
133 | */
|
---|
134 | if (++check_count == count) {
|
---|
135 | syslog_1(LOG_NOTICE, "Check point %d passed.", count);
|
---|
136 | }
|
---|
137 | else {
|
---|
138 | syslog_1(LOG_ERROR, "## Unexpected check point %d.", count);
|
---|
139 | errorflag = true;
|
---|
140 | }
|
---|
141 |
|
---|
142 | /*
|
---|
143 | * J[lÌàóÔ̸
|
---|
144 | */
|
---|
145 | if (check_bit_func != NULL) {
|
---|
146 | rercd = (*check_bit_func)();
|
---|
147 | if (rercd < 0) {
|
---|
148 | syslog_2(LOG_ERROR, "## Internal inconsistency detected (%s, %d).",
|
---|
149 | itron_strerror(rercd), SERCD(rercd));
|
---|
150 | errorflag = true;
|
---|
151 | }
|
---|
152 | }
|
---|
153 |
|
---|
154 | /*
|
---|
155 | * G[ªo³ê½êÍCeXgvOðI¹·éD
|
---|
156 | */
|
---|
157 | if (errorflag) {
|
---|
158 | test_finish();
|
---|
159 | }
|
---|
160 |
|
---|
161 | /*
|
---|
162 | * ÝbNóÔðð
|
---|
163 | */
|
---|
164 | SIL_UNL_INT();
|
---|
165 | }
|
---|
166 |
|
---|
167 | /*
|
---|
168 | * ®¹`FbN|Cg
|
---|
169 | */
|
---|
170 | void
|
---|
171 | check_finish(uint_t count)
|
---|
172 | {
|
---|
173 | check_point(count);
|
---|
174 | syslog_0(LOG_NOTICE, "All check points passed.");
|
---|
175 | test_finish();
|
---|
176 | }
|
---|
177 |
|
---|
178 | /*
|
---|
179 | * ð`FbNÌG[
|
---|
180 | */
|
---|
181 | void
|
---|
182 | _check_assert(const char *expr, const char *file, int_t line)
|
---|
183 | {
|
---|
184 | syslog_3(LOG_ERROR, "## Assertion `%s' failed at %s:%u.",
|
---|
185 | expr, file, line);
|
---|
186 | test_finish();
|
---|
187 | }
|
---|
188 |
|
---|
189 | /*
|
---|
190 | * G[R[h`FbNÌG[
|
---|
191 | */
|
---|
192 | void
|
---|
193 | _check_ercd(ER ercd, const char *file, int_t line)
|
---|
194 | {
|
---|
195 | syslog_3(LOG_ERROR, "## Unexpected error %s detected at %s:%u.",
|
---|
196 | itron_strerror(ercd), file, line);
|
---|
197 | test_finish();
|
---|
198 | }
|
---|