1 : /*
2 : * This file is part of MIN Test Framework. Copyright © 2008 Nokia Corporation
3 : * and/or its subsidiary(-ies).
4 : * Contact: Konrad Marek Zapalowicz
5 : * Contact e-mail: DG.MIN-Support@nokia.com
6 : *
7 : * This program is free software: you can redistribute it and/or modify it
8 : * under the terms of the GNU General Public License as published by the Free
9 : * Software Foundation, version 2 of the License.
10 : *
11 : * This program is distributed in the hope that it will be useful, but WITHOUT
12 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 : * more details. You should have received a copy of the GNU General Public
15 : * License along with this program. If not, see
16 : * <http://www.gnu.org/licenses/>.
17 : */
18 :
19 :
20 : /**
21 : * @file min_logger.test
22 : * @version 0.1
23 : * @brief This file contains test for MIN Logger.
24 : */
25 :
26 : /* ------------------------------------------------------------------------- */
27 : /* INCLUDES */
28 : #include <check.h>
29 :
30 : /* ------------------------------------------------------------------------- */
31 : /* CONSTANTS */
32 : /* None */
33 :
34 : /* ------------------------------------------------------------------------- */
35 : /* MACROS */
36 : /* None */
37 :
38 : /* ------------------------------------------------------------------------- */
39 : /* DATA TYPES */
40 : /* None */
41 :
42 : /* ------------------------------------------------------------------------- */
43 : /* LOCAL FUNCTION PROTOTYPES */
44 : /* None */
45 :
46 : /* ------------------------------------------------------------------------- */
47 : /* FORWARD DECLARATIONS */
48 : /* None */
49 :
50 : /* ------------------------------------------------------------------------- */
51 : /* STRUCTURES */
52 : /* None */
53 :
54 : /* ------------------------------------------------------------------------- */
55 : /* ==================== LOCAL FUNCTIONS ==================================== */
56 : /* None */
57 :
58 : /* ------------------------------------------------------------------------- */
59 : /* ============================= TESTS ===================================== */
60 : /* ------------------------------------------------------------------------- */
61 1 : START_TEST(test_mnl_output_type)
62 : {
63 : MinLogger sl;
64 : struct logger_typeinfo_t lt;
65 : struct output_typeinfo_t ot;
66 1 : lt.type_ = ESTxt;
67 1 : lt.output_ = dl_list_create();
68 1 : ot.output_type_ = ESFile;
69 1 : dl_list_add(lt.output_,(void*)&ot);
70 1 : sl.endpoint_ = dl_list_create();
71 1 : dl_list_add(sl.endpoint_, (void*)< );
72 1 : fail_unless( mnl_output_type(&sl) == ESFile
73 : , "MinLoggerOutput type differs from expected [%d]"
74 : , mnl_output_type(&sl) );
75 : }
76 1 : END_TEST
77 : /* ------------------------------------------------------------------------- */
78 1 : START_TEST(test_mnl_output_type2)
79 : {
80 : MinLogger sl;
81 : struct logger_typeinfo_t lt;
82 : struct output_typeinfo_t ot;
83 1 : lt.type_ = ESTxt;
84 1 : lt.output_ = dl_list_create();
85 1 : ot.output_type_ = ESSyslog;
86 1 : dl_list_add(lt.output_,(void*)&ot);
87 1 : sl.endpoint_ = dl_list_create();
88 1 : dl_list_add(sl.endpoint_, (void*)< );
89 1 : fail_unless( mnl_output_type(&sl) == ESSyslog
90 : , "MinLoggerOutput type differs from expected [%d]"
91 : , mnl_output_type(&sl) );
92 : }
93 1 : END_TEST
94 : /* ------------------------------------------------------------------------- */
95 1 : START_TEST(test_mnl_output_type3)
96 : {
97 : MinLogger sl;
98 : struct logger_typeinfo_t lt;
99 : struct output_typeinfo_t ot;
100 : struct output_typeinfo_t ot2;
101 1 : lt.type_ = ESTxt;
102 1 : lt.output_ = dl_list_create();
103 1 : ot.output_type_ = ESFile;
104 1 : ot2.output_type_ = ESSyslog;
105 1 : dl_list_add(lt.output_,(void*)&ot);
106 1 : dl_list_add(lt.output_,(void*)&ot2);
107 1 : sl.endpoint_ = dl_list_create();
108 1 : dl_list_add(sl.endpoint_, (void*)< );
109 1 : fail_unless( mnl_output_type(&sl) == (ESFile|ESSyslog)
110 : , "MinLoggerOutput type differs from expected [%d]"
111 : , mnl_output_type(&sl) );
112 : }
113 1 : END_TEST
114 : /* ------------------------------------------------------------------------- */
115 1 : START_TEST(test_mnl_logger_type)
116 : {
117 : MinLogger sl;
118 : struct logger_typeinfo_t lt;
119 1 : lt.type_ = ESTxt;
120 1 : sl.endpoint_ = dl_list_create();
121 1 : dl_list_add(sl.endpoint_, (void*)< );
122 1 : fail_unless( mnl_logger_type(&sl) == ESTxt
123 : , "MinLogger type differs from expected [%d]"
124 : , mnl_logger_type(&sl) );
125 : }
126 1 : END_TEST
127 : /* ------------------------------------------------------------------------- */
128 1 : START_TEST(test_mnl_logger_type2)
129 : {
130 : MinLogger sl;
131 : struct logger_typeinfo_t lt;
132 1 : lt.type_ = ESHtml;
133 1 : sl.endpoint_ = dl_list_create();
134 1 : dl_list_add(sl.endpoint_, (void*)< );
135 1 : fail_unless( mnl_logger_type(&sl) == ESHtml
136 : , "MinLogger type differs from expected [%d]"
137 : , mnl_logger_type(&sl) );
138 : }
139 1 : END_TEST
140 : /* ------------------------------------------------------------------------- */
141 1 : START_TEST(test_mnl_logger_type3)
142 : {
143 : MinLogger sl;
144 : struct logger_typeinfo_t lt;
145 : struct logger_typeinfo_t lt2;
146 1 : lt.type_ = ESTxt;
147 1 : lt2.type_ = ESHtml;
148 1 : sl.endpoint_ = dl_list_create();
149 1 : dl_list_add(sl.endpoint_, (void*)< );
150 1 : dl_list_add(sl.endpoint_, (void*)<2 );
151 1 : fail_unless( mnl_logger_type(&sl) == (ESTxt|ESHtml)
152 : , "MinLogger type differs from expected [%d]"
153 : , mnl_logger_type(&sl) );
154 : }
155 1 : END_TEST
156 : /* ------------------------------------------------------------------------- */
157 1 : START_TEST(test_html_logger_nostyle)
158 : {
159 : MinHtmlLogger* shl;
160 1 : TSChar test_path[] = "/tmp/";
161 1 : TSChar test_file[] = "test_html_logger_nostyle";
162 1 : int result = 0;
163 :
164 1 : shl = mhl_create( test_path /* path */
165 : , test_file /* file */
166 : , ESHtml /* logger type */
167 : , ESFile /* output */
168 : , 1 /* overwrite */
169 : , 0 /* withtimestamp */
170 : , 0 /* withlinebreak */
171 : , 0 /* witheventranking */
172 : , 0 /* pididtologfile */
173 : , 0 /* createlogdir */
174 : , 0 /* staticbuffersize */
175 : , 0 ); /* unicode */
176 :
177 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
178 : , ESNoStyle
179 : , "This is raw text without style." );
180 :
181 1 : mhl_destroy( &shl );
182 :
183 1 : fail_unless( result == 0,
184 : "mhl_send() failed" );
185 : }
186 1 : END_TEST
187 : /* ------------------------------------------------------------------------- */
188 1 : START_TEST(test_html_logger_bold)
189 : {
190 : MinHtmlLogger* shl;
191 1 : TSChar test_path[] = "/tmp/";
192 1 : TSChar test_file[] = "test_html_logger_bold";
193 1 : int result = 0;
194 :
195 1 : shl = mhl_create( test_path /* path */
196 : , test_file /* file */
197 : , ESHtml /* logger type */
198 : , ESFile /* output */
199 : , 1 /* overwrite */
200 : , 0 /* withtimestamp */
201 : , 0 /* withlinebreak */
202 : , 0 /* witheventranking */
203 : , 0 /* pididtologfile */
204 : , 0 /* createlogdir */
205 : , 0 /* staticbuffersize */
206 : , 0 ); /* unicode */
207 :
208 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
209 : , ESBold
210 : , "This is bold text." );
211 :
212 1 : mhl_destroy( &shl );
213 :
214 1 : fail_unless( result == 0,
215 : "mhl_send() failed" );
216 : }
217 1 : END_TEST
218 : /* ------------------------------------------------------------------------- */
219 1 : START_TEST(test_html_logger_cursive)
220 : {
221 : MinHtmlLogger* shl;
222 1 : TSChar test_path[] = "/tmp/";
223 1 : TSChar test_file[] = "test_html_logger_cursive";
224 1 : int result = 0;
225 :
226 1 : shl = mhl_create( test_path /* path */
227 : , test_file /* file */
228 : , ESHtml /* logger type */
229 : , ESFile /* output */
230 : , 1 /* overwrite */
231 : , 0 /* withtimestamp */
232 : , 0 /* withlinebreak */
233 : , 0 /* witheventranking */
234 : , 0 /* pididtologfile */
235 : , 0 /* createlogdir */
236 : , 0 /* staticbuffersize */
237 : , 0 ); /* unicode */
238 :
239 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
240 : , ESCursive
241 : , "This is cursive text." );
242 :
243 1 : mhl_destroy( &shl );
244 :
245 1 : fail_unless( result == 0,
246 : "mhl_send() failed" );
247 : }
248 1 : END_TEST
249 : /* ------------------------------------------------------------------------- */
250 1 : START_TEST(test_html_logger_underline)
251 : {
252 : MinHtmlLogger* shl;
253 1 : TSChar test_path[] = "/tmp/";
254 1 : TSChar test_file[] = "test_html_logger_underline";
255 1 : int result = 0;
256 :
257 1 : shl = mhl_create( test_path /* path */
258 : , test_file /* file */
259 : , ESHtml /* logger type */
260 : , ESFile /* output */
261 : , 1 /* overwrite */
262 : , 0 /* withtimestamp */
263 : , 0 /* withlinebreak */
264 : , 0 /* witheventranking */
265 : , 0 /* pididtologfile */
266 : , 0 /* createlogdir */
267 : , 0 /* staticbuffersize */
268 : , 0 ); /* unicode */
269 :
270 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
271 : , ESUnderline
272 : , "This is underlined text." );
273 :
274 1 : mhl_destroy( &shl );
275 :
276 1 : fail_unless( result == 0,
277 : "mhl_send() failed" );
278 : }
279 1 : END_TEST
280 : /* ------------------------------------------------------------------------- */
281 1 : START_TEST(test_html_logger_blue)
282 : {
283 : MinHtmlLogger* shl;
284 1 : TSChar test_path[] = "/tmp/";
285 1 : TSChar test_file[] = "test_html_logger_blue";
286 1 : int result = 0;
287 :
288 1 : shl = mhl_create( test_path /* path */
289 : , test_file /* file */
290 : , ESHtml /* logger type */
291 : , ESFile /* output */
292 : , 1 /* overwrite */
293 : , 0 /* withtimestamp */
294 : , 0 /* withlinebreak */
295 : , 0 /* witheventranking */
296 : , 0 /* pididtologfile */
297 : , 0 /* createlogdir */
298 : , 0 /* staticbuffersize */
299 : , 0 ); /* unicode */
300 :
301 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
302 : , ESBlue
303 : , "This is blue text." );
304 :
305 1 : mhl_destroy( &shl );
306 :
307 1 : fail_unless( result == 0,
308 : "mhl_send() failed" );
309 : }
310 1 : END_TEST
311 : /* ------------------------------------------------------------------------- */
312 1 : START_TEST(test_html_logger_green)
313 : {
314 : MinHtmlLogger* shl;
315 1 : TSChar test_path[] = "/tmp/";
316 1 : TSChar test_file[] = "test_html_logger_green";
317 1 : int result = 0;
318 :
319 1 : shl = mhl_create( test_path /* path */
320 : , test_file /* file */
321 : , ESHtml /* logger type */
322 : , ESFile /* output */
323 : , 1 /* overwrite */
324 : , 0 /* withtimestamp */
325 : , 0 /* withlinebreak */
326 : , 0 /* witheventranking */
327 : , 0 /* pididtologfile */
328 : , 0 /* createlogdir */
329 : , 0 /* staticbuffersize */
330 : , 0 ); /* unicode */
331 :
332 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
333 : , ESGreen
334 : , "This is green text." );
335 :
336 1 : mhl_destroy( &shl );
337 :
338 1 : fail_unless( result == 0,
339 : "mhl_send() failed" );
340 : }
341 1 : END_TEST
342 : /* ------------------------------------------------------------------------- */
343 1 : START_TEST(test_html_logger_red)
344 : {
345 : MinHtmlLogger* shl;
346 1 : TSChar test_path[] = "/tmp/";
347 1 : TSChar test_file[] = "test_html_logger_red";
348 1 : int result = 0;
349 :
350 1 : shl = mhl_create( test_path /* path */
351 : , test_file /* file */
352 : , ESHtml /* logger type */
353 : , ESFile /* output */
354 : , 1 /* overwrite */
355 : , 0 /* withtimestamp */
356 : , 0 /* withlinebreak */
357 : , 0 /* witheventranking */
358 : , 0 /* pididtologfile */
359 : , 0 /* createlogdir */
360 : , 0 /* staticbuffersize */
361 : , 0 ); /* unicode */
362 :
363 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
364 : , ESRed
365 : , "This is red text." );
366 :
367 1 : mhl_destroy( &shl );
368 :
369 1 : fail_unless( result == 0,
370 : "mhl_send() failed" );
371 : }
372 1 : END_TEST
373 : /* ------------------------------------------------------------------------- */
374 1 : START_TEST(test_html_logger_important)
375 : {
376 : MinHtmlLogger* shl;
377 1 : TSChar test_path[] = "/tmp/";
378 1 : TSChar test_file[] = "test_html_logger_important";
379 1 : int result = 0;
380 :
381 1 : shl = mhl_create( test_path /* path */
382 : , test_file /* file */
383 : , ESHtml /* logger type */
384 : , ESFile /* output */
385 : , 1 /* overwrite */
386 : , 0 /* withtimestamp */
387 : , 0 /* withlinebreak */
388 : , 0 /* witheventranking */
389 : , 0 /* pididtologfile */
390 : , 0 /* createlogdir */
391 : , 0 /* staticbuffersize */
392 : , 0 ); /* unicode */
393 :
394 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
395 : , ESImportant
396 : , "This is important." );
397 :
398 1 : mhl_destroy( &shl );
399 :
400 1 : fail_unless( result == 0,
401 : "mhl_send() failed" );
402 : }
403 1 : END_TEST
404 : /* ------------------------------------------------------------------------- */
405 1 : START_TEST(test_html_logger_warning)
406 : {
407 : MinHtmlLogger* shl;
408 1 : TSChar test_path[] = "/tmp/";
409 1 : TSChar test_file[] = "test_html_logger_warning";
410 1 : int result = 0;
411 :
412 1 : shl = mhl_create( test_path /* path */
413 : , test_file /* file */
414 : , ESHtml /* logger type */
415 : , ESFile /* output */
416 : , 1 /* overwrite */
417 : , 0 /* withtimestamp */
418 : , 0 /* withlinebreak */
419 : , 0 /* witheventranking */
420 : , 0 /* pididtologfile */
421 : , 0 /* createlogdir */
422 : , 0 /* staticbuffersize */
423 : , 0 ); /* unicode */
424 :
425 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
426 : , ESWarning
427 : , "This is warning." );
428 :
429 1 : mhl_destroy( &shl );
430 :
431 1 : fail_unless( result == 0,
432 : "mhl_send() failed" );
433 : }
434 1 : END_TEST
435 : /* ------------------------------------------------------------------------- */
436 1 : START_TEST(test_html_logger_error)
437 : {
438 : MinHtmlLogger* shl;
439 1 : TSChar test_path[] = "/tmp/";
440 1 : TSChar test_file[] = "test_html_logger_error";
441 1 : int result = 0;
442 :
443 1 : shl = mhl_create( test_path /* path */
444 : , test_file /* file */
445 : , ESHtml /* logger type */
446 : , ESFile /* output */
447 : , 1 /* overwrite */
448 : , 0 /* withtimestamp */
449 : , 0 /* withlinebreak */
450 : , 0 /* witheventranking */
451 : , 0 /* pididtologfile */
452 : , 0 /* createlogdir */
453 : , 0 /* staticbuffersize */
454 : , 0 ); /* unicode */
455 :
456 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
457 : , ESError
458 : , "This is error." );
459 :
460 1 : mhl_destroy( &shl );
461 :
462 1 : fail_unless( result == 0,
463 : "mhl_send() failed" );
464 : }
465 1 : END_TEST
466 : /* ------------------------------------------------------------------------- */
467 1 : START_TEST(test_html_logger_mixing_styles_1)
468 : {
469 : MinHtmlLogger* shl;
470 1 : TSChar test_path[] = "/tmp/";
471 1 : TSChar test_file[] = "test_html_logger_mixing_styles";
472 1 : int result = 0;
473 :
474 1 : shl = mhl_create( test_path /* path */
475 : , test_file /* file */
476 : , ESHtml /* logger type */
477 : , ESFile /* output */
478 : , 1 /* overwrite */
479 : , 0 /* withtimestamp */
480 : , 0 /* withlinebreak */
481 : , 0 /* witheventranking */
482 : , 0 /* pididtologfile */
483 : , 0 /* createlogdir */
484 : , 0 /* staticbuffersize */
485 : , 0 ); /* unicode */
486 :
487 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
488 : , ESBlue | ESBold | ESUnderline | ESCursive
489 : , "This is underlined, cursive, bold blue text." );
490 :
491 1 : mhl_destroy( &shl );
492 :
493 1 : fail_unless( result == 0,
494 : "mhl_send() failed" );
495 : }
496 1 : END_TEST
497 : /* ------------------------------------------------------------------------- */
498 1 : START_TEST(test_html_logger_mixing_styles_2)
499 : {
500 : MinHtmlLogger* shl;
501 1 : TSChar test_path[] = "/tmp/";
502 1 : TSChar test_file[] = "test_html_logger_mixing_styles_2";
503 1 : int result = 0;
504 :
505 1 : shl = mhl_create( test_path /* path */
506 : , test_file /* file */
507 : , ESHtml /* logger type */
508 : , ESFile /* output */
509 : , 1 /* overwrite */
510 : , 0 /* withtimestamp */
511 : , 1 /* withlinebreak */
512 : , 0 /* witheventranking */
513 : , 0 /* pididtologfile */
514 : , 0 /* createlogdir */
515 : , 0 /* staticbuffersize */
516 : , 0 ); /* unicode */
517 :
518 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
519 : , ESImportant | ESCursive | ESUnderline | ESGreen
520 : , "Red important text, then underlined cursive green text." );
521 :
522 1 : mhl_destroy( &shl );
523 :
524 1 : fail_unless( result == 0,
525 : "mhl_send() failed" );
526 : }
527 1 : END_TEST
528 : /* ------------------------------------------------------------------------- */
529 1 : START_TEST(test_html_logger_mixing_styles_3)
530 : {
531 : MinHtmlLogger* shl;
532 1 : TSChar test_path[] = "/tmp/";
533 1 : TSChar test_file[] = "test_html_logger_mixing_styles_3";
534 1 : int result = 0;
535 :
536 1 : shl = mhl_create( test_path /* path */
537 : , test_file /* file */
538 : , ESHtml /* logger type */
539 : , ESFile /* output */
540 : , 1 /* overwrite */
541 : , 0 /* withtimestamp */
542 : , 1 /* withlinebreak */
543 : , 0 /* witheventranking */
544 : , 0 /* pididtologfile */
545 : , 0 /* createlogdir */
546 : , 0 /* staticbuffersize */
547 : , 0 ); /* unicode */
548 :
549 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
550 : , ESImportant | ESWarning | ESError
551 : , "Important.. Warning.. Error.." );
552 :
553 1 : mhl_destroy( &shl );
554 :
555 1 : fail_unless( result == 0,
556 : "mhl_send() failed" );
557 : }
558 1 : END_TEST
559 : /* ------------------------------------------------------------------------- */
560 1 : START_TEST(test_html_logger_title_with_pid)
561 : {
562 : MinHtmlLogger* shl;
563 1 : TSChar test_path[] = "/tmp/";
564 1 : TSChar test_file[] = "test_html_logger_title_with_pid";
565 1 : int result = 0;
566 :
567 1 : shl = mhl_create( test_path /* path */
568 : , test_file /* file */
569 : , ESHtml /* logger type */
570 : , ESFile /* output */
571 : , 1 /* overwrite */
572 : , 0 /* withtimestamp */
573 : , 0 /* withlinebreak */
574 : , 0 /* witheventranking */
575 : , 1 /* pididtologfile */
576 : , 0 /* createlogdir */
577 : , 0 /* staticbuffersize */
578 : , 0 ); /* unicode */
579 :
580 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
581 : , ESNoStyle
582 : , "This is title with pid." );
583 :
584 1 : mhl_destroy( &shl );
585 :
586 1 : fail_unless( result == 0,
587 : "mhl_send() failed" );
588 : }
589 1 : END_TEST
590 : /* ------------------------------------------------------------------------- */
591 1 : START_TEST(test_html_logger_multiple_lines_with_linebreak)
592 : {
593 : MinHtmlLogger* shl;
594 1 : TSChar test_path[] = "/tmp/";
595 1 : TSChar test_file[] = "test_html_logger_multiple_lines_with_linebreak";
596 1 : int result = 0;
597 :
598 1 : shl = mhl_create( test_path /* path */
599 : , test_file /* file */
600 : , ESHtml /* logger type */
601 : , ESFile /* output */
602 : , 1 /* overwrite */
603 : , 0 /* withtimestamp */
604 : , 1 /* withlinebreak */
605 : , 0 /* witheventranking */
606 : , 0 /* pididtologfile */
607 : , 0 /* createlogdir */
608 : , 0 /* staticbuffersize */
609 : , 0 ); /* unicode */
610 :
611 1 : mhl_send( (struct logger_typeinfo_t*)shl
612 : , ESNoStyle
613 : , "Here is a.." );
614 :
615 1 : mhl_send( (struct logger_typeinfo_t*)shl
616 : , ESNoStyle
617 : , "lot of.." );
618 :
619 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
620 : , ESNoStyle
621 : , "text with linebreaks." );
622 :
623 1 : mhl_destroy( &shl );
624 :
625 1 : fail_unless( result == 0,
626 : "mhl_send() failed" );
627 : }
628 1 : END_TEST
629 : /* ------------------------------------------------------------------------- */
630 1 : START_TEST(test_html_logger_multiple_lines_without_linebreak)
631 : {
632 : MinHtmlLogger* shl;
633 1 : TSChar test_path[] = "/tmp/";
634 1 : TSChar test_file[] = "test_html_logger_multiple_lines_without_linebreak";
635 1 : int result = 0;
636 :
637 1 : shl = mhl_create( test_path /* path */
638 : , test_file /* file */
639 : , ESHtml /* logger type */
640 : , ESFile /* output */
641 : , 1 /* overwrite */
642 : , 0 /* withtimestamp */
643 : , 0 /* withlinebreak */
644 : , 0 /* witheventranking */
645 : , 0 /* pididtologfile */
646 : , 0 /* createlogdir */
647 : , 0 /* staticbuffersize */
648 : , 0 ); /* unicode */
649 :
650 1 : mhl_send( (struct logger_typeinfo_t*)shl
651 : , ESNoStyle
652 : , "Here is a.." );
653 :
654 1 : mhl_send( (struct logger_typeinfo_t*)shl
655 : , ESNoStyle
656 : , "lot of.." );
657 :
658 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
659 : , ESNoStyle
660 : , "text without linebreaks." );
661 :
662 1 : mhl_destroy( &shl );
663 :
664 1 : fail_unless( result == 0,
665 : "mhl_send() failed" );
666 : }
667 1 : END_TEST
668 : /* ------------------------------------------------------------------------- */
669 1 : START_TEST(test_html_logger_with_timestamp)
670 : {
671 : MinHtmlLogger* shl;
672 1 : TSChar test_path[] = "/tmp/";
673 1 : TSChar test_file[] = "test_html_logger_with_timestamp";
674 1 : int result = 0;
675 :
676 1 : shl = mhl_create( test_path /* path */
677 : , test_file /* file */
678 : , ESHtml /* logger type */
679 : , ESFile /* output */
680 : , 1 /* overwrite */
681 : , 1 /* withtimestamp */
682 : , 0 /* withlinebreak */
683 : , 0 /* witheventranking */
684 : , 0 /* pididtologfile */
685 : , 0 /* createlogdir */
686 : , 0 /* staticbuffersize */
687 : , 0 ); /* unicode */
688 :
689 1 : result = mhl_send( (struct logger_typeinfo_t*)shl
690 : , ESNoStyle
691 : , "This is text with timestamp." );
692 :
693 1 : mhl_destroy( &shl );
694 :
695 1 : fail_unless( result == 0,
696 : "mhl_send() failed" );
697 : }
698 1 : END_TEST
699 : /* ------------------------------------------------------------------------- */
700 1 : START_TEST(test_data_logger)
701 : {
702 : MinDataLogger* sdl;
703 1 : TSChar test_path[] = "/tmp/";
704 1 : TSChar test_file[] = "test_data_logger";
705 1 : int result = 0;
706 :
707 1 : sdl = mdl_create( test_path /* path */
708 : , test_file /* file */
709 : , ESData /* logger type */
710 : , ESFile /* output */
711 : , 1 /* overwrite */
712 : , 0 /* withtimestamp */
713 : , 0 /* withlinebreak */
714 : , 0 /* witheventranking */
715 : , 0 /* pididtologfile */
716 : , 0 /* createlogdir */
717 : , 0 /* staticbuffersize */
718 : , 0 ); /* unicode */
719 :
720 1 : result = mdl_send( (struct logger_typeinfo_t*)sdl
721 : , 0
722 : , "logging via data logger..." );
723 :
724 1 : mdl_destroy( &sdl );
725 :
726 1 : fail_unless( result == 0,
727 : "mdl_send() failed" );
728 : }
729 1 : END_TEST
730 : /* ------------------------------------------------------------------------- */
731 : /* ------------------------------------------------------------------------- */
732 : /* ------------------------------------------------------------------------- */
733 : /* ------------------------------------------------------------------------- */
734 : /* ------------------------------------------------------------------------- */
735 : /* ------------------------------------------------------------------------- */
736 : /* ------------------------------------------------------------------------- */
737 : /* ------------------------------------------------------------------------- */
738 : /* ------------------------------------------------------------------------- */
739 : /* ========================== FUNCTIONS ==================================== */
740 : /* ------------------------------------------------------------------------- */
741 : Suite* min_logger_suite()
742 25 : {
743 25 : Suite * s = suite_create ("min_logger");
744 :
745 : /* Core test case */
746 25 : TCase *tc_core = tcase_create ("Core");
747 :
748 : /* mnl_output_type */
749 25 : tcase_add_test (tc_core, test_mnl_output_type);
750 25 : tcase_add_test (tc_core, test_mnl_output_type2);
751 25 : tcase_add_test (tc_core, test_mnl_output_type3);
752 :
753 : /* mnl_logger_type */
754 25 : tcase_add_test (tc_core, test_mnl_logger_type);
755 25 : tcase_add_test (tc_core, test_mnl_logger_type2);
756 25 : tcase_add_test (tc_core, test_mnl_logger_type3);
757 :
758 : /* html logger */
759 25 : tcase_add_test (tc_core, test_html_logger_nostyle);
760 25 : tcase_add_test (tc_core, test_html_logger_bold);
761 25 : tcase_add_test (tc_core, test_html_logger_cursive);
762 25 : tcase_add_test (tc_core, test_html_logger_underline);
763 25 : tcase_add_test (tc_core, test_html_logger_blue);
764 25 : tcase_add_test (tc_core, test_html_logger_green);
765 25 : tcase_add_test (tc_core, test_html_logger_red);
766 25 : tcase_add_test (tc_core, test_html_logger_important);
767 25 : tcase_add_test (tc_core, test_html_logger_warning);
768 25 : tcase_add_test (tc_core, test_html_logger_error);
769 25 : tcase_add_test (tc_core, test_html_logger_mixing_styles_1);
770 25 : tcase_add_test (tc_core, test_html_logger_mixing_styles_2);
771 25 : tcase_add_test (tc_core, test_html_logger_mixing_styles_3);
772 25 : tcase_add_test (tc_core, test_html_logger_title_with_pid);
773 25 : tcase_add_test (tc_core, test_html_logger_multiple_lines_with_linebreak);
774 25 : tcase_add_test (tc_core, test_html_logger_multiple_lines_without_linebreak);
775 25 : tcase_add_test (tc_core, test_html_logger_with_timestamp);
776 :
777 : /* data logger */
778 25 : tcase_add_test (tc_core, test_data_logger);
779 :
780 25 : suite_add_tcase (s, tc_core);
781 :
782 25 : return s;
783 : }
784 : /* ------------------------------------------------------------------------- */
785 : int min_logger_tests()
786 0 : {
787 0 : int number_failed = 0;
788 0 : Suite * s = min_logger_suite ();
789 0 : SRunner * sr = srunner_create (s);
790 0 : srunner_run_all(sr, CK_NORMAL);
791 0 : number_failed = srunner_ntests_failed(sr);
792 0 : srunner_free(sr);
793 0 : return number_failed;
794 : }
795 : /* ------------------------------------------------------------------------- */
796 : /* End of file */
|