1 : /*
2 : * This file is part of MIN Test Framework. Copyright © 2008 Nokia Corporation
3 : * and/or its subsidiary(-ies).
4 : * Contact: Sampo Saaristo
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 check_logger.tests
22 : * @version 0.1
23 : * @brief This file contains implementation of tests for Logger Mechanism
24 : */
25 :
26 : /* ------------------------------------------------------------------------- */
27 :
28 : #include <stdlib.h>
29 : #include <check.h>
30 : #include "min_logger.h"
31 :
32 : /* ------------------------------------------------------------------------- */
33 : /* EXTERNAL DATA STRUCTURES */
34 : /* None */
35 :
36 : /* ------------------------------------------------------------------------- */
37 : /* EXTERNAL GLOBAL VARIABLES */
38 : /* None */
39 :
40 : /* ------------------------------------------------------------------------- */
41 : /* EXTERNAL FUNCTION PROTOTYPES */
42 :
43 : /* ------------------------------------------------------------------------- */
44 : /* GLOBAL VARIABLES */
45 : /* None */
46 :
47 : /* ------------------------------------------------------------------------- */
48 : /* CONSTANTS */
49 : /* None */
50 :
51 : /* ------------------------------------------------------------------------- */
52 : /* MACROS */
53 : /* None */
54 :
55 : /* ------------------------------------------------------------------------- */
56 : /* LOCAL GLOBAL VARIABLES */
57 : /* None */
58 :
59 : /* ------------------------------------------------------------------------- */
60 : /* LOCAL CONSTANTS AND MACROS */
61 : /* None */
62 :
63 : /* ------------------------------------------------------------------------- */
64 : /* MODULE DATA STRUCTURES */
65 : /* None */
66 :
67 : /* ------------------------------------------------------------------------- */
68 : /* LOCAL FUNCTION PROTOTYPES */
69 : /* None */
70 :
71 : /* ------------------------------------------------------------------------- */
72 : /* FORWARD DECLARATIONS */
73 : /* None */
74 :
75 : /* ==================== LOCAL FUNCTIONS ==================================== */
76 :
77 1 : START_TEST (test_logger_open)
78 : {
79 : int log_open_retval;
80 :
81 1 : log_open_retval = min_log_open ("min_logger_test", 1);
82 1 : fail_unless (log_open_retval == 0, "failed to open log");
83 1 : min_log_close();
84 : }
85 1 : END_TEST
86 :
87 1 : START_TEST (test_logger_open_null_arg)
88 : {
89 : int log_open_retval;
90 :
91 1 : log_open_retval = min_log_open (NULL, 1);
92 1 : fail_unless (log_open_retval == 0, "failed to log with NULL");
93 1 : min_log_close();
94 : }
95 1 : END_TEST
96 :
97 1 : START_TEST (test_logger_open_inv_dlevel)
98 : {
99 : int log_open_retval;
100 :
101 1 : log_open_retval = min_log_open ("min_logger_test", 4);
102 1 : fail_unless (log_open_retval == 0, "should react to invalid debug level");
103 1 : min_log_close();
104 : }
105 1 : END_TEST
106 :
107 1 : START_TEST (test_logger_close)
108 : {
109 : int log_close_retval;
110 :
111 1 : log_close_retval = min_log_close ();
112 1 : fail_unless (log_close_retval == 0, "failed to close log");
113 : }
114 1 : END_TEST
115 :
116 1 : START_TEST (test_logger_log)
117 : {
118 : int log_retval;
119 :
120 1 : log_retval = min_info ("min test");
121 1 : fail_unless (log_retval == 0, "failed to log");
122 : }
123 1 : END_TEST
124 :
125 :
126 1 : START_TEST (test_logger_log_null_arg)
127 : {
128 : int log_retval;
129 :
130 1 : log_retval = min_err (NULL);
131 1 : fail_unless (log_retval == 0, "failed to log");
132 : }
133 1 : END_TEST
134 :
135 1 : START_TEST (test_logger_warn)
136 : {
137 : int log_retval;
138 :
139 1 : log_retval = min_warn ("TEST warning");
140 1 : fail_unless (log_retval == 0, "failed to log");
141 : }
142 1 : END_TEST
143 :
144 1 : START_TEST (test_debug)
145 : {
146 1 : int log_retval = 0;
147 :
148 1 : log_retval = min_debug (__FUNCTION__, __LINE__, __FILE__,
149 : "testing debug");
150 :
151 1 : fail_unless (log_retval == 0, "failed to log");
152 : }
153 1 : END_TEST
154 :
155 : Suite *logger_suite (void)
156 124 : {
157 124 : Suite *s = suite_create ("logger");
158 :
159 : /* Core test case */
160 124 : TCase *tc_core = tcase_create ("Core");
161 124 : tcase_add_test (tc_core, test_logger_open);
162 124 : tcase_add_test (tc_core, test_logger_open_inv_dlevel);
163 124 : tcase_add_test (tc_core, test_logger_open_null_arg);
164 :
165 124 : tcase_add_test (tc_core, test_logger_close);
166 124 : tcase_add_test (tc_core, test_logger_log);
167 124 : tcase_add_test (tc_core, test_logger_log_null_arg);
168 124 : tcase_add_test (tc_core, test_logger_warn);
169 124 : tcase_add_test (tc_core, test_debug);
170 :
171 124 : suite_add_tcase (s, tc_core);
172 :
173 124 : return s;
174 : }
175 :
176 :
177 : /* ================= OTHER EXPORTED FUNCTIONS ============================== */
178 : /* None */
179 :
180 : /* End of file */
|