GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
#include <string.h> |
||
2 |
#include <stdlib.h> |
||
3 |
#include <stdio.h> |
||
4 |
#include <criterion/criterion.h> |
||
5 |
|||
6 |
#include "alloc.h" |
||
7 |
#include "config.h" |
||
8 |
#include "extensions.h" |
||
9 |
|||
10 |
12 |
static void setup(void) { |
|
11 |
#ifdef USE_RPMALLOC |
||
12 |
12 |
rpmalloc_initialize(); |
|
13 |
#endif |
||
14 |
12 |
} |
|
15 |
|||
16 |
12 |
static void teardown(void) { |
|
17 |
#ifdef USE_RPMALLOC |
||
18 |
12 |
rpmalloc_finalize(); |
|
19 |
#endif |
||
20 |
12 |
} |
|
21 |
|||
22 |
#define WSS_EXTENSION_NO_FILE "resources/test-ext-no-file.so" |
||
23 |
#define WSS_EXTENSION_NO_ALLOC "resources/test-ext-no-set-allocators.so" |
||
24 |
#define WSS_EXTENSION_NO_INIT "resources/test-ext-no-init.so" |
||
25 |
#define WSS_EXTENSION_NO_OPEN "resources/test-ext-no-open.so" |
||
26 |
#define WSS_EXTENSION_NO_IN_FRAME "resources/test-ext-no-in-frame.so" |
||
27 |
#define WSS_EXTENSION_NO_IN_FRAMES "resources/test-ext-no-in-frames.so" |
||
28 |
#define WSS_EXTENSION_NO_OUT_FRAME "resources/test-ext-no-out-frame.so" |
||
29 |
#define WSS_EXTENSION_NO_OUT_FRAMES "resources/test-ext-no-out-frames.so" |
||
30 |
#define WSS_EXTENSION_NO_CLOSE "resources/test-ext-no-close.so" |
||
31 |
#define WSS_EXTENSION_NO_DESTROY "resources/test-ext-no-destroy.so" |
||
32 |
|||
33 |
TestSuite(WSS_load_extensions, .init = setup, .fini = teardown); |
||
34 |
|||
35 |
4 |
Test(WSS_load_extensions, no_config) { |
|
36 |
2 |
WSS_load_extensions(NULL); |
|
37 |
|||
38 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension(NULL)); |
39 |
|||
40 |
2 |
WSS_destroy_extensions(); |
|
41 |
2 |
} |
|
42 |
|||
43 |
4 |
Test(WSS_load_extensions, no_file) { |
|
44 |
2 |
size_t length = 1; |
|
45 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
46 |
|||
47 |
2 |
conf->extensions_length = 1; |
|
48 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
49 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_FILE)+1)); |
|
50 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_FILE); |
|
51 |
|||
52 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
53 |
2 |
conf->extensions_config[0] = NULL; |
|
54 |
|||
55 |
2 |
WSS_load_extensions(conf); |
|
56 |
|||
57 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-file")); |
58 |
|||
59 |
2 |
WSS_destroy_extensions(); |
|
60 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
61 |
2 |
WSS_config_free(conf); |
|
62 |
2 |
WSS_free((void**) &conf); |
|
63 |
2 |
} |
|
64 |
|||
65 |
4 |
Test(WSS_load_extensions, no_set_allocators) { |
|
66 |
2 |
size_t length = 1; |
|
67 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
68 |
|||
69 |
2 |
conf->extensions_length = 1; |
|
70 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
71 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_ALLOC)+1)); |
|
72 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_ALLOC); |
|
73 |
|||
74 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
75 |
2 |
conf->extensions_config[0] = NULL; |
|
76 |
|||
77 |
2 |
WSS_load_extensions(conf); |
|
78 |
|||
79 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-set-allocators")); |
80 |
|||
81 |
2 |
WSS_destroy_extensions(); |
|
82 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
83 |
2 |
WSS_config_free(conf); |
|
84 |
2 |
WSS_free((void**) &conf); |
|
85 |
2 |
} |
|
86 |
|||
87 |
4 |
Test(WSS_load_extensions, no_init) { |
|
88 |
2 |
size_t length = 1; |
|
89 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
90 |
|||
91 |
2 |
conf->extensions_length = 1; |
|
92 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
93 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_INIT)+1)); |
|
94 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_INIT); |
|
95 |
|||
96 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
97 |
2 |
conf->extensions_config[0] = NULL; |
|
98 |
|||
99 |
2 |
WSS_load_extensions(conf); |
|
100 |
|||
101 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-init")); |
102 |
|||
103 |
2 |
WSS_destroy_extensions(); |
|
104 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
105 |
2 |
WSS_config_free(conf); |
|
106 |
2 |
WSS_free((void**) &conf); |
|
107 |
2 |
} |
|
108 |
|||
109 |
4 |
Test(WSS_load_extensions, no_open) { |
|
110 |
2 |
size_t length = 1; |
|
111 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
112 |
|||
113 |
2 |
conf->extensions_length = 1; |
|
114 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
115 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_OPEN)+1)); |
|
116 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_OPEN); |
|
117 |
|||
118 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
119 |
2 |
conf->extensions_config[0] = NULL; |
|
120 |
|||
121 |
2 |
WSS_load_extensions(conf); |
|
122 |
|||
123 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-open")); |
124 |
|||
125 |
2 |
WSS_destroy_extensions(); |
|
126 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
127 |
2 |
WSS_config_free(conf); |
|
128 |
2 |
WSS_free((void**) &conf); |
|
129 |
2 |
} |
|
130 |
|||
131 |
4 |
Test(WSS_load_extensions, no_in_frame) { |
|
132 |
2 |
size_t length = 1; |
|
133 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
134 |
|||
135 |
2 |
conf->extensions_length = 1; |
|
136 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
137 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_IN_FRAME)+1)); |
|
138 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_IN_FRAME); |
|
139 |
|||
140 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
141 |
2 |
conf->extensions_config[0] = NULL; |
|
142 |
|||
143 |
2 |
WSS_load_extensions(conf); |
|
144 |
|||
145 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-in-frame")); |
146 |
|||
147 |
2 |
WSS_destroy_extensions(); |
|
148 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
149 |
2 |
WSS_config_free(conf); |
|
150 |
2 |
WSS_free((void**) &conf); |
|
151 |
2 |
} |
|
152 |
|||
153 |
4 |
Test(WSS_load_extensions, no_in_frames) { |
|
154 |
2 |
size_t length = 1; |
|
155 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
156 |
|||
157 |
2 |
conf->extensions_length = 1; |
|
158 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
159 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_IN_FRAMES)+1)); |
|
160 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_IN_FRAMES); |
|
161 |
|||
162 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
163 |
2 |
conf->extensions_config[0] = NULL; |
|
164 |
|||
165 |
2 |
WSS_load_extensions(conf); |
|
166 |
|||
167 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-in-frames")); |
168 |
|||
169 |
2 |
WSS_destroy_extensions(); |
|
170 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
171 |
2 |
WSS_config_free(conf); |
|
172 |
2 |
WSS_free((void**) &conf); |
|
173 |
2 |
} |
|
174 |
|||
175 |
|||
176 |
4 |
Test(WSS_load_extensions, no_out_frame) { |
|
177 |
2 |
size_t length = 1; |
|
178 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
179 |
|||
180 |
2 |
conf->extensions_length = 1; |
|
181 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
182 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_OUT_FRAME)+1)); |
|
183 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_OUT_FRAME); |
|
184 |
|||
185 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
186 |
2 |
conf->extensions_config[0] = NULL; |
|
187 |
|||
188 |
2 |
WSS_load_extensions(conf); |
|
189 |
|||
190 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-out-frame")); |
191 |
|||
192 |
2 |
WSS_destroy_extensions(); |
|
193 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
194 |
2 |
WSS_config_free(conf); |
|
195 |
2 |
WSS_free((void**) &conf); |
|
196 |
2 |
} |
|
197 |
|||
198 |
4 |
Test(WSS_load_extensions, no_out_frames) { |
|
199 |
2 |
size_t length = 1; |
|
200 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
201 |
|||
202 |
2 |
conf->extensions_length = 1; |
|
203 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
204 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_OUT_FRAMES)+1)); |
|
205 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_OUT_FRAMES); |
|
206 |
|||
207 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
208 |
2 |
conf->extensions_config[0] = NULL; |
|
209 |
|||
210 |
2 |
WSS_load_extensions(conf); |
|
211 |
|||
212 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-out-frames")); |
213 |
|||
214 |
2 |
WSS_destroy_extensions(); |
|
215 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
216 |
2 |
WSS_config_free(conf); |
|
217 |
2 |
WSS_free((void**) &conf); |
|
218 |
2 |
} |
|
219 |
|||
220 |
4 |
Test(WSS_load_extensions, no_close) { |
|
221 |
2 |
size_t length = 1; |
|
222 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
223 |
|||
224 |
2 |
conf->extensions_length = 1; |
|
225 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
226 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_CLOSE)+1)); |
|
227 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_CLOSE); |
|
228 |
|||
229 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
230 |
2 |
conf->extensions_config[0] = NULL; |
|
231 |
|||
232 |
2 |
WSS_load_extensions(conf); |
|
233 |
|||
234 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-close")); |
235 |
|||
236 |
2 |
WSS_destroy_extensions(); |
|
237 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
238 |
2 |
WSS_config_free(conf); |
|
239 |
2 |
WSS_free((void**) &conf); |
|
240 |
2 |
} |
|
241 |
|||
242 |
4 |
Test(WSS_load_extensions, no_destroy) { |
|
243 |
2 |
size_t length = 1; |
|
244 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
245 |
|||
246 |
2 |
conf->extensions_length = 1; |
|
247 |
2 |
conf->extensions = WSS_calloc(length, sizeof(char *)); |
|
248 |
2 |
conf->extensions[0] = WSS_malloc(sizeof(char)*(strlen(WSS_EXTENSION_NO_DESTROY)+1)); |
|
249 |
2 |
sprintf(conf->extensions[0], "%s", WSS_EXTENSION_NO_DESTROY); |
|
250 |
|||
251 |
2 |
conf->extensions_config = WSS_calloc(length, sizeof(char *)); |
|
252 |
2 |
conf->extensions_config[0] = NULL; |
|
253 |
|||
254 |
2 |
WSS_load_extensions(conf); |
|
255 |
|||
256 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL == WSS_find_extension("test-ext-no-destroy")); |
257 |
|||
258 |
2 |
WSS_destroy_extensions(); |
|
259 |
2 |
WSS_free((void**) &conf->extensions[0]); |
|
260 |
2 |
WSS_config_free(conf); |
|
261 |
2 |
WSS_free((void**) &conf); |
|
262 |
2 |
} |
|
263 |
|||
264 |
4 |
Test(WSS_load_extensions, successful) { |
|
265 |
2 |
wss_config_t *conf = (wss_config_t *) WSS_malloc(sizeof(wss_config_t)); |
|
266 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(WSS_SUCCESS == WSS_config_load(conf, "resources/test_wss.json")); |
267 |
|||
268 |
2 |
WSS_load_extensions(conf); |
|
269 |
|||
270 |
✓✗✗✓ ✗✗✗✗ ✗✓ |
2 |
cr_assert(NULL != WSS_find_extension("permessage-deflate")); |
271 |
|||
272 |
2 |
WSS_destroy_extensions(); |
|
273 |
2 |
WSS_config_free(conf); |
|
274 |
2 |
WSS_free((void**) &conf); |
|
275 |
2 |
} |
|
276 |
Generated by: GCOVR (Version 4.2) |