Line data Source code
1 : /** @file suite_libdebug-memory.c
2 : * @brief Check Libdebug memory functions
3 : * @author François Cerbelle (Fanfan), francois@cerbelle.net
4 : *
5 : * @internal
6 : * Created: 26/06/2024
7 : * Revision: none
8 : * Last modified: 2024-12-19 19:51
9 : * Compiler: gcc
10 : * Organization: Cerbelle.net
11 : * Copyright: Copyright (c) 2024, François Cerbelle
12 : *
13 : * This source code is released for free distribution under the terms of the
14 : * GNU General Public License as published by the Free Software Foundation.
15 : */
16 :
17 : #ifdef HAVE_CONFIG_H
18 : #include "config.h"
19 : #endif
20 :
21 : #define _XOPEN_SOURCE 500 /* snprintf */
22 : #ifdef NDEBUG
23 : #define _GNU_SOURCE /* asprintf */
24 : #endif
25 : #include "libdebug/memtrack.h" /* memtrack_dumpblocks */
26 : #include "oom.h" /* oomfill_setup */
27 : #include <check.h>
28 : #include <unistd.h> /* pid_t getpid() */
29 : #include <sys/stat.h> /* mkdir(), chdir(), mode_t */
30 : #include <stdio.h> /* fprintf */
31 : #include <stdlib.h> /* abort() */
32 : #include "checktools.inc"
33 :
34 : #include "libdebug/memory.h" /* libdebug's memory macros */
35 :
36 6 : START_TEST(memory_malloc_0) {
37 : char* l_result;
38 : #ifndef NDEBUG
39 : size_t l_RAMSize;
40 : size_t l_NbBlocks;
41 6 : l_NbBlocks = memtrack_getallocatedblocks();
42 6 : l_RAMSize = memtrack_getallocatedRAM();
43 : #endif
44 :
45 6 : l_result=NULL;
46 : oomfill_fill(_i,2);
47 6 : l_result = malloc(0);
48 : oomfill_free();
49 : #ifndef NDEBUG
50 : /* Enforced by memtrack, but not glibc malloc */
51 6 : ck_assert(NULL==l_result);
52 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
53 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
54 6 : ck_assert(0==memtrack_getblocksize(l_result));
55 : #endif
56 6 : free(l_result);
57 6 : }
58 : END_TEST
59 :
60 6 : START_TEST(memory_malloc_100) {
61 : char* l_result;
62 : #ifndef NDEBUG
63 : size_t l_RAMSize;
64 : size_t l_NbBlocks;
65 6 : l_NbBlocks = memtrack_getallocatedblocks();
66 6 : l_RAMSize = memtrack_getallocatedRAM();
67 : #endif
68 :
69 6 : l_result=NULL;
70 : oomfill_fill(_i,2);
71 6 : l_result = malloc(100);
72 : oomfill_free();
73 6 : ck_assert((NULL!=l_result)||(oomfill_enabled()));
74 6 : if (NULL!=l_result) {
75 : #ifndef NDEBUG
76 6 : ck_assert(l_RAMSize+100==memtrack_getallocatedRAM());
77 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
78 6 : ck_assert(100==memtrack_getblocksize(l_result));
79 : #endif
80 6 : free(l_result);
81 : }
82 6 : }
83 : END_TEST
84 :
85 6 : START_TEST(memory_malloc_oom) {
86 : char* l_result;
87 :
88 : #ifndef NDEBUG
89 : size_t l_RAMSize;
90 : size_t l_NbBlocks;
91 6 : l_NbBlocks = memtrack_getallocatedblocks();
92 6 : l_RAMSize = memtrack_getallocatedRAM();
93 : #endif
94 :
95 6 : l_result=NULL;
96 : oomfill_fill(_i,2);
97 6 : l_result = malloc(RAMLIMIT_SOFT/2);
98 : oomfill_free();
99 6 : ck_assert((NULL!=l_result)||(oomfill_enabled()));
100 6 : if (NULL!=l_result) {
101 : #ifndef NDEBUG
102 6 : ck_assert(l_RAMSize+RAMLIMIT_SOFT/2==memtrack_getallocatedRAM());
103 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
104 : #endif
105 6 : free(l_result);
106 : }
107 : #ifndef NDEBUG
108 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
109 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
110 : #endif
111 6 : }
112 : END_TEST
113 :
114 6 : START_TEST(memory_realloc_null_0) {
115 : char* l_result;
116 : char* l_ptr;
117 :
118 : #ifndef NDEBUG
119 : size_t l_RAMSize;
120 : size_t l_NbBlocks;
121 6 : l_NbBlocks = memtrack_getallocatedblocks();
122 6 : l_RAMSize = memtrack_getallocatedRAM();
123 : #endif
124 :
125 6 : l_result=NULL;
126 6 : l_ptr=NULL;
127 : oomfill_fill(_i,2);
128 6 : l_result = realloc(l_ptr,0);
129 : oomfill_free();
130 6 : ck_assert(NULL==l_ptr);
131 : #ifndef NDEBUG
132 : /* Enforced by memtrack, but not glibc malloc */
133 6 : ck_assert(NULL==l_result);
134 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
135 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
136 : #endif
137 6 : if (NULL!=l_result)
138 0 : free(l_result);
139 6 : }
140 : END_TEST
141 :
142 6 : START_TEST(memory_realloc_null_100) {
143 : char* l_result;
144 : char* l_ptr;
145 :
146 : #ifndef NDEBUG
147 : size_t l_RAMSize;
148 : size_t l_NbBlocks;
149 6 : l_NbBlocks = memtrack_getallocatedblocks();
150 6 : l_RAMSize = memtrack_getallocatedRAM();
151 : #endif
152 :
153 6 : l_result=NULL;
154 6 : l_ptr=NULL;
155 : oomfill_fill(_i,2);
156 6 : l_result = realloc(l_ptr,100);
157 : oomfill_free();
158 6 : ck_assert((NULL!=l_result)||(oomfill_enabled()));
159 6 : ck_assert(NULL==l_ptr);
160 6 : if (NULL!=l_result) {
161 : #ifndef NDEBUG
162 6 : ck_assert(l_RAMSize+100==memtrack_getallocatedRAM());
163 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
164 6 : ck_assert(100==memtrack_getblocksize(l_result));
165 : #endif
166 6 : free(l_result);
167 : }
168 6 : }
169 : END_TEST
170 :
171 6 : START_TEST(memory_realloc_null_oom) {
172 : char* l_result;
173 : char* l_ptr;
174 :
175 : #ifndef NDEBUG
176 : size_t l_RAMSize;
177 : size_t l_NbBlocks;
178 6 : l_NbBlocks = memtrack_getallocatedblocks();
179 6 : l_RAMSize = memtrack_getallocatedRAM();
180 : #endif
181 :
182 6 : l_result=NULL;
183 6 : l_ptr=NULL;
184 : oomfill_fill(_i,2);
185 6 : l_result = realloc(l_ptr,RAMLIMIT_SOFT/2);
186 : oomfill_free();
187 6 : ck_assert((NULL!=l_result)||(oomfill_enabled()));
188 6 : if (NULL!=l_result) {
189 : #ifndef NDEBUG
190 6 : ck_assert(l_RAMSize+RAMLIMIT_SOFT/2==memtrack_getallocatedRAM());
191 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
192 : #endif
193 6 : free(l_result);
194 : }
195 6 : ck_assert(NULL==l_ptr);
196 : #ifndef NDEBUG
197 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
198 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
199 : #endif
200 6 : }
201 : END_TEST
202 :
203 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
204 6 : START_TEST(memory_realloc_invalid_0) {
205 : char* l_result;
206 : char* l_ptr;
207 :
208 : /* This test is supposed to trigger a SIGABRT(6) and will crash the
209 : * whole testsuite if not caught or not in a child process */
210 6 : forktest_only;
211 :
212 4 : l_ptr=(void*)999;
213 : #ifdef ENABLE_GCOV
214 : if (oomfill_enabled())
215 : __gcov_dump();
216 : #endif
217 : oomfill_fill(_i,2);
218 4 : l_result=realloc(l_ptr,0);
219 : /* Never reached, dead code */
220 : (void)l_result;
221 : }
222 : END_TEST
223 : #endif
224 :
225 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
226 6 : START_TEST(memory_realloc_invalid_100) {
227 : char* l_result;
228 : char* l_ptr;
229 :
230 : /* This test is supposed to trigger a SIGABRT(6) and will crash the
231 : * whole testsuite if not caught or not in a child process */
232 6 : forktest_only;
233 :
234 4 : l_ptr=(void*)999;
235 : #ifdef ENABLE_GCOV
236 : if (oomfill_enabled())
237 : __gcov_dump();
238 : #endif
239 : oomfill_fill(_i,2);
240 4 : l_result=realloc(l_ptr,100);
241 : /* Never reached, dead code */
242 : (void)l_result;
243 : }
244 : END_TEST
245 : #endif
246 :
247 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
248 6 : START_TEST(memory_realloc_invalid_oom) {
249 : void* l_result;
250 : char* l_ptr;
251 :
252 : /* This test is supposed to trigger a SIGABRT(6) and will crash the
253 : * whole testsuite if not caught or not in a child process */
254 6 : forktest_only;
255 :
256 4 : l_ptr=(void*)999;
257 : #ifdef ENABLE_GCOV
258 : if (oomfill_enabled())
259 : __gcov_dump();
260 : #endif
261 : oomfill_fill(_i,2);
262 4 : l_result=realloc(l_ptr,RAMLIMIT_SOFT*2);
263 : /* Never reached, dead code */
264 : (void)l_result;
265 : }
266 : END_TEST
267 : #endif
268 :
269 6 : START_TEST(memory_realloc_valid_0) {
270 : void* l_result;
271 : char* l_ptr;
272 : #ifndef NDEBUG
273 : size_t l_RAMSize;
274 : size_t l_NbBlocks;
275 6 : l_NbBlocks = memtrack_getallocatedblocks();
276 6 : l_RAMSize = memtrack_getallocatedRAM();
277 : #endif
278 :
279 6 : l_ptr=malloc(100);
280 : #ifndef NDEBUG
281 6 : ck_assert(l_RAMSize+100==memtrack_getallocatedRAM());
282 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
283 : #endif
284 : oomfill_fill(_i,2);
285 6 : l_result=realloc(l_ptr,0);
286 : oomfill_free();
287 : (void)l_result;
288 : /* Behaves as free, result can be NULL or not, depending on implementations */
289 : #ifndef NDEBUG
290 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
291 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
292 : #endif
293 6 : }
294 : END_TEST
295 :
296 6 : START_TEST(memory_realloc_valid_updown) {
297 : char* l_result;
298 : char* l_ptr;
299 : #ifndef NDEBUG
300 : size_t l_RAMSize;
301 : size_t l_NbBlocks;
302 6 : l_NbBlocks = memtrack_getallocatedblocks();
303 6 : l_RAMSize = memtrack_getallocatedRAM();
304 : #endif
305 :
306 6 : l_result=NULL;
307 6 : l_ptr=malloc(100);
308 : #ifndef NDEBUG
309 6 : ck_assert(l_RAMSize+100==memtrack_getallocatedRAM());
310 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
311 : #endif
312 : oomfill_fill(_i,2);
313 6 : l_result=realloc(l_ptr,1000);
314 : oomfill_free();
315 6 : ck_assert((l_result!=NULL)||(oomfill_enabled()));
316 : /* Repair for next test outside of OOM context */
317 6 : if (NULL==l_result)
318 0 : l_result = realloc(l_ptr,1000);
319 : #ifndef NDEBUG
320 6 : ck_assert(l_RAMSize+1000==memtrack_getallocatedRAM());
321 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
322 6 : ck_assert(1000==memtrack_getblocksize(l_result));
323 : #endif
324 :
325 6 : l_ptr=l_result;
326 : oomfill_fill(_i,2);
327 6 : l_result=realloc(l_ptr,10);
328 : oomfill_free();
329 6 : ck_assert((l_result!=NULL)||(oomfill_enabled()));
330 : /* Repair for next test outside of OOM context */
331 6 : if (NULL==l_result)
332 0 : l_result = realloc(l_ptr,10);
333 : #ifndef NDEBUG
334 6 : ck_assert(l_RAMSize+10==memtrack_getallocatedRAM());
335 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
336 6 : ck_assert(10==memtrack_getblocksize(l_result));
337 : #endif
338 :
339 6 : free(l_result);
340 6 : }
341 : END_TEST
342 :
343 6 : START_TEST(memory_realloc_valid_oom) {
344 : char* l_result;
345 : char* l_ptr;
346 : #ifndef NDEBUG
347 : size_t l_RAMSize;
348 : size_t l_NbBlocks;
349 6 : l_NbBlocks = memtrack_getallocatedblocks();
350 6 : l_RAMSize = memtrack_getallocatedRAM();
351 : #endif
352 :
353 6 : l_result=NULL;
354 6 : l_ptr=malloc(100);
355 : #ifndef NDEBUG
356 6 : ck_assert(l_RAMSize+100==memtrack_getallocatedRAM());
357 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
358 : #endif
359 : oomfill_fill(_i,2);
360 6 : l_result = realloc(l_ptr,RAMLIMIT_SOFT/2);
361 : oomfill_free();
362 6 : ck_assert((NULL!=l_result)||(oomfill_enabled()));
363 6 : if (NULL!=l_result) {
364 : #ifndef NDEBUG
365 6 : ck_assert(l_RAMSize+RAMLIMIT_SOFT/2==memtrack_getallocatedRAM());
366 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
367 6 : ck_assert(RAMLIMIT_SOFT/2==memtrack_getblocksize(l_result));
368 : #endif
369 6 : l_ptr=l_result;
370 : } else {
371 : #ifndef NDEBUG
372 0 : ck_assert(l_RAMSize+100==memtrack_getallocatedRAM());
373 0 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
374 0 : ck_assert(100==memtrack_getblocksize(l_ptr));
375 : #endif
376 : }
377 6 : ck_assert(NULL!=l_ptr);
378 :
379 : /* CppCheck detects a double free here for l_ptr, first freed at realloc.
380 : * But if realloc fails at runtime (this is wanted), l_ptr is left
381 : * untouched, thus not freed */
382 6 : free(l_ptr);
383 : /* CppCheck detects a memory leak here for l_result, allocated at realloc.
384 : * But if realloc fails at runtime (which is wanted here), l_result is NULL,
385 : * confirmed by the assertion, and do not need to be freed */
386 6 : }
387 : END_TEST
388 :
389 6 : START_TEST(memory_calloc_0_0) {
390 : char* l_result;
391 : #ifndef NDEBUG
392 : size_t l_RAMSize;
393 : size_t l_NbBlocks;
394 6 : l_NbBlocks = memtrack_getallocatedblocks();
395 6 : l_RAMSize = memtrack_getallocatedRAM();
396 : #endif
397 :
398 6 : l_result=NULL;
399 : oomfill_fill(_i,2);
400 6 : l_result = calloc(0,0);
401 : oomfill_free();
402 : #ifndef NDEBUG
403 : /* Enforced by memtrack, but not glibc malloc */
404 6 : ck_assert(NULL==l_result);
405 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
406 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
407 6 : ck_assert(0==memtrack_getblocksize(l_result));
408 : #endif
409 :
410 6 : free(l_result);
411 6 : }
412 : END_TEST
413 :
414 6 : START_TEST(memory_calloc_0_100) {
415 : char* l_result;
416 : #ifndef NDEBUG
417 : size_t l_RAMSize;
418 : size_t l_NbBlocks;
419 6 : l_NbBlocks = memtrack_getallocatedblocks();
420 6 : l_RAMSize = memtrack_getallocatedRAM();
421 : #endif
422 :
423 6 : l_result=NULL;
424 : oomfill_fill(_i,2);
425 6 : l_result = calloc(0,100);
426 : oomfill_free();
427 : #ifndef NDEBUG
428 : /* Enforced by memtrack, but not glibc malloc */
429 6 : ck_assert(NULL==l_result);
430 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
431 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
432 6 : ck_assert(0==memtrack_getblocksize(l_result));
433 : #endif
434 :
435 6 : free(l_result);
436 6 : }
437 : END_TEST
438 :
439 6 : START_TEST(memory_calloc_100_0) {
440 : char* l_result;
441 : #ifndef NDEBUG
442 : size_t l_RAMSize;
443 : size_t l_NbBlocks;
444 6 : l_NbBlocks = memtrack_getallocatedblocks();
445 6 : l_RAMSize = memtrack_getallocatedRAM();
446 : #endif
447 :
448 6 : l_result=NULL;
449 : oomfill_fill(_i,2);
450 6 : l_result = calloc(100,0);
451 : oomfill_free();
452 : #ifndef NDEBUG
453 : /* Enforced by memtrack, but not glibc malloc */
454 6 : ck_assert(NULL==l_result);
455 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
456 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
457 6 : ck_assert(0==memtrack_getblocksize(l_result));
458 : #endif
459 :
460 6 : free(l_result);
461 6 : }
462 : END_TEST
463 :
464 6 : START_TEST(memory_calloc_100_100) {
465 : char* l_result;
466 : #ifndef NDEBUG
467 : size_t l_RAMSize;
468 : size_t l_NbBlocks;
469 6 : l_NbBlocks = memtrack_getallocatedblocks();
470 6 : l_RAMSize = memtrack_getallocatedRAM();
471 : #endif
472 :
473 6 : l_result=NULL;
474 : oomfill_fill(_i,2);
475 6 : l_result = calloc(100,100);
476 : oomfill_free();
477 6 : ck_assert((NULL!=l_result)||(oomfill_enabled()));
478 6 : if (NULL!=l_result) {
479 : #ifndef NDEBUG
480 6 : ck_assert(l_RAMSize+10000==memtrack_getallocatedRAM());
481 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
482 6 : ck_assert(10000==memtrack_getblocksize(l_result));
483 : #endif
484 :
485 6 : free(l_result);
486 : }
487 6 : }
488 : END_TEST
489 :
490 6 : START_TEST(memory_calloc_oom) {
491 : char* l_result;
492 : #ifndef NDEBUG
493 : size_t l_RAMSize;
494 : size_t l_NbBlocks;
495 6 : l_NbBlocks = memtrack_getallocatedblocks();
496 6 : l_RAMSize = memtrack_getallocatedRAM();
497 : #endif
498 :
499 6 : l_result=NULL;
500 : oomfill_fill(_i,2);
501 6 : l_result = calloc(RAMLIMIT_SOFT/2/1024,1024);
502 : oomfill_free();
503 6 : ck_assert((NULL!=l_result)||(oomfill_enabled()));
504 6 : if (NULL!=l_result) {
505 : #ifndef NDEBUG
506 6 : ck_assert(l_RAMSize+RAMLIMIT_SOFT/2==memtrack_getallocatedRAM());
507 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
508 : #endif
509 6 : free(l_result);
510 : }
511 : #ifndef NDEBUG
512 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
513 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
514 : #endif
515 6 : }
516 : END_TEST
517 :
518 6 : START_TEST(memory_free_null) {
519 : char* l_ptr;
520 : #ifndef NDEBUG
521 : size_t l_RAMSize;
522 : size_t l_NbBlocks;
523 6 : l_NbBlocks = memtrack_getallocatedblocks();
524 6 : l_RAMSize = memtrack_getallocatedRAM();
525 : #endif
526 :
527 6 : l_ptr=NULL;
528 : oomfill_fill(_i,2);
529 6 : free(l_ptr);
530 : oomfill_free();
531 6 : ck_assert(NULL==l_ptr);
532 : #ifndef NDEBUG
533 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
534 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
535 : #endif
536 6 : }
537 : END_TEST
538 :
539 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
540 6 : START_TEST(memory_free_invalid) {
541 : char* l_ptr;
542 :
543 6 : l_ptr=(void*)999;
544 : /* This test is supposed to trigger a SIGABRT(6) and will crash the
545 : * whole testsuite if not caught or not in a child process */
546 6 : forktest_only;
547 :
548 : #ifdef ENABLE_GCOV
549 : if (oomfill_enabled())
550 : __gcov_dump();
551 : #endif
552 : oomfill_fill(_i,2);
553 4 : free(l_ptr);
554 : }
555 : END_TEST
556 : #endif
557 :
558 6 : START_TEST(memory_free_valid) {
559 : char* l_ptr;
560 : #ifndef NDEBUG
561 : size_t l_RAMSize;
562 : size_t l_NbBlocks;
563 6 : l_NbBlocks = memtrack_getallocatedblocks();
564 6 : l_RAMSize = memtrack_getallocatedRAM();
565 : #endif
566 :
567 6 : l_ptr=malloc(100);
568 : #ifndef NDEBUG
569 6 : ck_assert(l_RAMSize+100==memtrack_getallocatedRAM());
570 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
571 : #endif
572 : oomfill_fill(_i,2);
573 6 : free(l_ptr);
574 : oomfill_free();
575 6 : ck_assert(NULL!=l_ptr);
576 : #ifndef NDEBUG
577 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
578 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
579 : #endif
580 6 : }
581 : END_TEST
582 :
583 : #ifndef NDEBUG /* strdup(NULL) caught by gcc */
584 6 : START_TEST(memory_strdup_null) {
585 : void* l_result;
586 : size_t l_RAMSize;
587 : size_t l_NbBlocks;
588 :
589 6 : l_NbBlocks = memtrack_getallocatedblocks();
590 6 : l_RAMSize = memtrack_getallocatedRAM();
591 :
592 : /* This test is supposed to trigger a SIGABRT(6) and will crash the
593 : * whole testsuite if not caught or not in a child process */
594 6 : forktest_only;
595 :
596 4 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
597 4 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
598 : oomfill_fill(_i,2);
599 : /* CppCheck warns about null pointer dereference, normal for this test */
600 4 : l_result=strdup(NULL);
601 : /* Never reached, dead code */
602 : (void)l_result;
603 : }
604 : END_TEST
605 : #endif
606 :
607 6 : START_TEST(memory_strdup_empty) {
608 : char* l_result;
609 : #ifndef NDEBUG
610 : size_t l_RAMSize;
611 : size_t l_NbBlocks;
612 6 : l_NbBlocks = memtrack_getallocatedblocks();
613 6 : l_RAMSize = memtrack_getallocatedRAM();
614 : #endif
615 :
616 6 : l_result=NULL;
617 : #ifndef NDEBUG
618 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
619 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
620 : #endif
621 : oomfill_fill(_i,2);
622 6 : l_result=strdup("");
623 : oomfill_free();
624 6 : ck_assert((NULL!=l_result)||(oomfill_enabled()));
625 6 : if (NULL!=l_result) {
626 : #ifndef NDEBUG
627 6 : ck_assert(l_RAMSize+1==memtrack_getallocatedRAM());
628 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
629 : #endif
630 6 : free(l_result);
631 : } else {
632 : #ifndef NDEBUG
633 0 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
634 0 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
635 : #endif
636 : }
637 6 : }
638 : END_TEST
639 :
640 6 : START_TEST(memory_strdup_value) {
641 6 : char *szLongString =
642 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
643 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
644 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
645 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
646 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
647 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
648 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
649 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
650 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
651 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
652 : ;
653 : char* l_result;
654 : #ifndef NDEBUG
655 : size_t l_RAMSize;
656 : size_t l_NbBlocks;
657 6 : l_NbBlocks = memtrack_getallocatedblocks();
658 6 : l_RAMSize = memtrack_getallocatedRAM();
659 : #endif
660 :
661 6 : l_result=NULL;
662 : #ifndef NDEBUG
663 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
664 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
665 : #endif
666 : oomfill_fill(_i,2);
667 6 : l_result=strdup(szLongString);
668 : oomfill_free();
669 6 : ck_assert((NULL!=l_result)||(oomfill_enabled()));
670 6 : if (NULL!=l_result) {
671 : #ifndef NDEBUG
672 6 : ck_assert(l_RAMSize+strlen(szLongString)+1==memtrack_getallocatedRAM());
673 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
674 : #endif
675 6 : free(l_result);
676 : } else {
677 : #ifndef NDEBUG
678 0 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
679 0 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
680 : #endif
681 : }
682 6 : }
683 : END_TEST
684 :
685 6 : START_TEST(memory_strdup_invalid) {
686 : void* l_result;
687 : #ifndef NDEBUG
688 : size_t l_RAMSize;
689 : size_t l_NbBlocks;
690 6 : l_NbBlocks = memtrack_getallocatedblocks();
691 6 : l_RAMSize = memtrack_getallocatedRAM();
692 : #endif
693 :
694 : /* This test is supposed to trigger a SIGABRT(6) and will crash the
695 : * whole testsuite if not caught or not in a child process */
696 6 : forktest_only;
697 :
698 : #ifndef NDEBUG
699 4 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
700 4 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
701 : #endif
702 : oomfill_fill(_i,2);
703 4 : l_result=strdup((void*)999);
704 : /* Never reached, dead code */
705 : (void)l_result;
706 : }
707 : END_TEST
708 :
709 : #ifdef HAVE_LIBOOM
710 : START_TEST(memory_strdup_oom) {
711 : char *szLongString;
712 : size_t szSize;
713 : char* l_result;
714 : #ifndef NDEBUG
715 : size_t l_RAMSize;
716 : size_t l_NbBlocks;
717 : l_NbBlocks = memtrack_getallocatedblocks();
718 : l_RAMSize = memtrack_getallocatedRAM();
719 : #endif
720 :
721 : l_result=NULL;
722 : szSize=RAMLIMIT_HARD;
723 : /* Find szSize value such as malloc(szSize) works, malloc(2*szSize) fails */
724 : while ((szSize>0)&&(NULL==(szLongString=malloc(szSize))))
725 : szSize /= 2;
726 : szLongString = memset(szLongString,'A',szSize-1);
727 : szLongString[szSize-1]=0;
728 : #ifndef NDEBUG
729 : ck_assert(l_RAMSize+szSize==memtrack_getallocatedRAM());
730 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
731 : #endif
732 : oomfill_fill(_i,2);
733 : l_result=strdup(szLongString);
734 : oomfill_free();
735 : ck_assert(NULL==l_result);
736 : #ifndef NDEBUG
737 : ck_assert(l_RAMSize+szSize==memtrack_getallocatedRAM());
738 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
739 : #endif
740 : free(szLongString);
741 : }
742 : END_TEST
743 : #endif /* HAVE_LIBOOM */
744 :
745 6 : START_TEST(memory_asprintf) {
746 : int l_result;
747 : char* l_ptr;
748 6 : char *szLongString =
749 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
750 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
751 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
752 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
753 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
754 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
755 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
756 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
757 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
758 : "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
759 : ;
760 : #ifndef NDEBUG
761 : size_t l_RAMSize;
762 : size_t l_NbBlocks;
763 6 : l_NbBlocks = memtrack_getallocatedblocks();
764 6 : l_RAMSize = memtrack_getallocatedRAM();
765 : #endif
766 :
767 : /* String empty */
768 6 : l_result=0;
769 6 : l_ptr = NULL;
770 : #ifndef NDEBUG
771 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
772 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
773 : #endif
774 :
775 : oomfill_fill(_i,2);
776 6 : l_result = asprintf(&l_ptr,"%s","");
777 : oomfill_free();
778 6 : ck_assert((0==l_result)||(oomfill_enabled()));
779 6 : if (0==l_result) {
780 6 : ck_assert(NULL!=l_ptr);
781 6 : ck_assert(0==strcmp("",l_ptr));
782 : #ifndef NDEBUG
783 6 : ck_assert(l_RAMSize+1==memtrack_getallocatedRAM());
784 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
785 6 : ck_assert(1==memtrack_getblocksize(l_ptr));
786 : #endif
787 6 : free(l_ptr);
788 : }
789 :
790 : /* String value */
791 6 : l_result=0;
792 6 : l_ptr = NULL;
793 : #ifndef NDEBUG
794 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
795 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
796 : #endif
797 :
798 : oomfill_fill(_i,2);
799 6 : l_result = asprintf(&l_ptr,"%s",szLongString);
800 : oomfill_free();
801 6 : ck_assert((strlen(szLongString)==(size_t)l_result)||(oomfill_enabled()));
802 6 : if (strlen(szLongString)==(size_t)l_result) {
803 6 : ck_assert(NULL!=l_ptr);
804 6 : ck_assert(0==strcmp(szLongString,l_ptr));
805 : #ifndef NDEBUG
806 6 : ck_assert(l_RAMSize+1+strlen(szLongString)==memtrack_getallocatedRAM());
807 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
808 6 : ck_assert(1+strlen(szLongString)==memtrack_getblocksize(l_ptr));
809 : #endif
810 6 : free(l_ptr);
811 : }
812 :
813 : /* Numeric value */
814 6 : l_result=0;
815 6 : l_ptr = NULL;
816 : #ifndef NDEBUG
817 6 : ck_assert(l_RAMSize==memtrack_getallocatedRAM());
818 6 : ck_assert(l_NbBlocks==memtrack_getallocatedblocks());
819 : #endif
820 :
821 : oomfill_fill(_i,2);
822 6 : l_result = asprintf(&l_ptr,"%d",123);
823 : oomfill_free();
824 6 : ck_assert((3==l_result)||(oomfill_enabled()));
825 6 : if (3==l_result) {
826 6 : ck_assert(NULL!=l_ptr);
827 6 : ck_assert(0==strcmp("123",l_ptr));
828 : #ifndef NDEBUG
829 6 : ck_assert(l_RAMSize+4==memtrack_getallocatedRAM());
830 6 : ck_assert(l_NbBlocks+1==memtrack_getallocatedblocks());
831 6 : ck_assert(4==memtrack_getblocksize(l_ptr));
832 : #endif
833 6 : free(l_ptr);
834 : }
835 6 : }
836 : END_TEST
837 :
838 6 : START_TEST(memory_memreport) {
839 : oomfill_fill(_i,2);
840 6 : memreport();
841 : oomfill_free();
842 6 : }
843 : END_TEST
844 :
845 : /************************************************************************/
846 78 : void memory_checked_uninitialized_setup() {
847 78 : signals_catch();
848 78 : forktest_gprofdir();
849 78 : }
850 66 : void memory_checked_uninitialized_teardown() {
851 66 : signals_release();
852 : #ifndef NDEBUG
853 66 : ck_assert(0==memtrack_getallocatedblocks());
854 : #endif /* NDEBUG */
855 66 : }
856 :
857 : #define DATASIZE 5
858 : #define DATACOUNT 5
859 : char* data[DATACOUNT];
860 78 : void memory_checked_withdata_setup() {
861 : unsigned int i;
862 78 : signals_catch();
863 78 : forktest_gprofdir();
864 468 : for (i=0; i<DATACOUNT; i++)
865 390 : data[i]=malloc(DATASIZE);
866 78 : }
867 66 : void memory_checked_withdata_teardown() {
868 : unsigned int i;
869 66 : signals_release();
870 396 : for (i=0; i<DATACOUNT; i++)
871 330 : free(data[i]);
872 66 : }
873 : /************************************************************************/
874 390 : void memory_unchecked_common_setup() {
875 390 : forktest_init();
876 390 : }
877 286 : void memory_unchecked_common_teardown() {
878 286 : }
879 : #ifdef HAVE_LIBOOM
880 : void memory_unchecked_oom_setup() {
881 : oomfill_enable(RAMLIMIT_SOFT);
882 : memory_unchecked_common_setup();
883 : }
884 : void memory_unchecked_oom_teardown() {
885 : oomfill_disable();
886 : memory_unchecked_common_teardown();
887 : }
888 : #endif /* HAVE_LIBOOM */
889 :
890 : /************************************************************************/
891 365 : Suite* libdebug_memory_suite() {
892 : Suite *s;
893 : TCase *tc;
894 :
895 365 : s = suite_create("LibDebug-Memory");
896 365 : tc = tcase_create("Uninitialized");
897 365 : tcase_add_checked_fixture(tc, memory_checked_uninitialized_setup, memory_checked_uninitialized_teardown);
898 365 : tcase_add_unchecked_fixture(tc, memory_unchecked_common_setup, memory_unchecked_common_teardown);
899 365 : suite_add_tcase(s, tc);
900 365 : tcase_add_test(tc, memory_malloc_0);
901 365 : tcase_add_test(tc, memory_malloc_100);
902 365 : tcase_add_test(tc, memory_malloc_oom);
903 365 : tcase_add_test(tc, memory_realloc_null_0);
904 365 : tcase_add_test(tc, memory_realloc_null_100);
905 365 : tcase_add_test(tc, memory_realloc_null_oom);
906 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
907 365 : tcase_add_test_raise_signal(tc, memory_realloc_invalid_0,6);
908 365 : tcase_add_test_raise_signal(tc, memory_realloc_invalid_100,6);
909 365 : tcase_add_test_raise_signal(tc, memory_realloc_invalid_oom,6);
910 : #endif
911 365 : tcase_add_test(tc, memory_realloc_valid_0);
912 365 : tcase_add_test(tc, memory_realloc_valid_updown);
913 365 : tcase_add_test(tc, memory_realloc_valid_oom);
914 365 : tcase_add_test(tc, memory_calloc_0_0);
915 365 : tcase_add_test(tc, memory_calloc_0_100);
916 365 : tcase_add_test(tc, memory_calloc_100_0);
917 365 : tcase_add_test(tc, memory_calloc_100_100);
918 365 : tcase_add_test(tc, memory_calloc_oom);
919 365 : tcase_add_test(tc, memory_free_null);
920 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
921 365 : tcase_add_test_raise_signal(tc, memory_free_invalid,6);
922 : #endif
923 365 : tcase_add_test(tc, memory_free_valid);
924 : #ifndef NDEBUG /* strdup(NULL) caught by gcc */
925 365 : tcase_add_test_raise_signal(tc, memory_strdup_null,11);
926 : #endif
927 365 : tcase_add_test(tc, memory_strdup_empty);
928 365 : tcase_add_test(tc, memory_strdup_value);
929 365 : tcase_add_test_raise_signal(tc, memory_strdup_invalid,11);
930 365 : tcase_add_test(tc, memory_asprintf);
931 365 : tcase_add_test(tc, memory_memreport);
932 :
933 365 : tc = tcase_create("WithData");
934 365 : tcase_add_checked_fixture(tc, memory_checked_withdata_setup, memory_checked_withdata_teardown);
935 365 : tcase_add_unchecked_fixture(tc, memory_unchecked_common_setup, memory_unchecked_common_teardown);
936 365 : suite_add_tcase(s, tc);
937 365 : tcase_add_test(tc, memory_malloc_0);
938 365 : tcase_add_test(tc, memory_malloc_100);
939 365 : tcase_add_test(tc, memory_malloc_oom);
940 365 : tcase_add_test(tc, memory_realloc_null_0);
941 365 : tcase_add_test(tc, memory_realloc_null_100);
942 365 : tcase_add_test(tc, memory_realloc_null_oom);
943 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
944 365 : tcase_add_test_raise_signal(tc, memory_realloc_invalid_0,6);
945 365 : tcase_add_test_raise_signal(tc, memory_realloc_invalid_100,6);
946 365 : tcase_add_test_raise_signal(tc, memory_realloc_invalid_oom,6);
947 : #endif
948 365 : tcase_add_test(tc, memory_realloc_valid_0);
949 365 : tcase_add_test(tc, memory_realloc_valid_updown);
950 365 : tcase_add_test(tc, memory_realloc_valid_oom);
951 365 : tcase_add_test(tc, memory_calloc_0_0);
952 365 : tcase_add_test(tc, memory_calloc_0_100);
953 365 : tcase_add_test(tc, memory_calloc_100_0);
954 365 : tcase_add_test(tc, memory_calloc_100_100);
955 365 : tcase_add_test(tc, memory_calloc_oom);
956 365 : tcase_add_test(tc, memory_free_null);
957 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
958 365 : tcase_add_test_raise_signal(tc, memory_free_invalid,6);
959 : #endif
960 365 : tcase_add_test(tc, memory_free_valid);
961 : #ifndef NDEBUG /* strdup(NULL) caught by gcc */
962 365 : tcase_add_test_raise_signal(tc, memory_strdup_null,11);
963 : #endif
964 365 : tcase_add_test(tc, memory_strdup_empty);
965 365 : tcase_add_test(tc, memory_strdup_value);
966 365 : tcase_add_test_raise_signal(tc, memory_strdup_invalid,11);
967 365 : tcase_add_test(tc, memory_asprintf);
968 365 : tcase_add_test(tc, memory_memreport);
969 :
970 : #ifdef HAVE_LIBOOM
971 : tc = tcase_create("Uninitialized-OOM");
972 : tcase_set_tags(tc,"oom");
973 : tcase_add_checked_fixture(tc, memory_checked_uninitialized_setup, memory_checked_uninitialized_teardown);
974 : tcase_add_unchecked_fixture(tc, memory_unchecked_oom_setup, memory_unchecked_oom_teardown);
975 : suite_add_tcase(s, tc);
976 : tcase_add_loop_test(tc, memory_malloc_0, 0, 10);
977 : tcase_add_loop_test(tc, memory_malloc_100, 0, 10);
978 : tcase_add_loop_test(tc, memory_malloc_oom, 0, 10);
979 : tcase_add_loop_test(tc, memory_realloc_null_0, 0, 10);
980 : tcase_add_loop_test(tc, memory_realloc_null_100, 0, 10);
981 : tcase_add_loop_test(tc, memory_realloc_null_oom, 0, 10);
982 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
983 : tcase_add_loop_test_raise_signal(tc, memory_realloc_invalid_0,6, 0, 10);
984 : tcase_add_loop_test_raise_signal(tc, memory_realloc_invalid_100,6, 0, 10);
985 : tcase_add_loop_test_raise_signal(tc, memory_realloc_invalid_oom,6, 0, 10);
986 : #endif
987 : tcase_add_loop_test(tc, memory_realloc_valid_0, 0, 10);
988 : tcase_add_loop_test(tc, memory_realloc_valid_updown, 0, 10);
989 : tcase_add_loop_test(tc, memory_realloc_valid_oom, 0, 10);
990 : tcase_add_loop_test(tc, memory_calloc_0_0, 0, 10);
991 : tcase_add_loop_test(tc, memory_calloc_0_100, 0, 10);
992 : tcase_add_loop_test(tc, memory_calloc_100_0, 0, 10);
993 : tcase_add_loop_test(tc, memory_calloc_100_100, 0, 10);
994 : tcase_add_loop_test(tc, memory_calloc_oom, 0, 10);
995 : tcase_add_loop_test(tc, memory_free_null, 0, 10);
996 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
997 : tcase_add_loop_test_raise_signal(tc, memory_free_invalid,6, 0, 10);
998 : #endif
999 : tcase_add_loop_test(tc, memory_free_valid, 0, 10);
1000 : #ifndef NDEBUG /* strdup(NULL) caught by gcc */
1001 : tcase_add_loop_test_raise_signal(tc, memory_strdup_null,11, 0, 10);
1002 : #endif
1003 : tcase_add_loop_test(tc, memory_strdup_empty, 0, 10);
1004 : tcase_add_loop_test(tc, memory_strdup_value, 0, 10);
1005 : tcase_add_loop_test_raise_signal(tc, memory_strdup_invalid,11, 0, 10);
1006 : tcase_add_loop_test(tc, memory_strdup_oom, 0, 10);
1007 : tcase_add_loop_test(tc, memory_asprintf, 0, 10);
1008 : tcase_add_loop_test(tc, memory_memreport, 0, 10);
1009 :
1010 : tc = tcase_create("WithData-OOM");
1011 : tcase_set_tags(tc,"oom");
1012 : tcase_add_checked_fixture(tc, memory_checked_withdata_setup, memory_checked_withdata_teardown);
1013 : tcase_add_unchecked_fixture(tc, memory_unchecked_oom_setup, memory_unchecked_oom_teardown);
1014 : suite_add_tcase(s, tc);
1015 : tcase_add_loop_test(tc, memory_malloc_0, 0, 10);
1016 : tcase_add_loop_test(tc, memory_malloc_100, 0, 10);
1017 : tcase_add_loop_test(tc, memory_malloc_oom, 0, 10);
1018 : tcase_add_loop_test(tc, memory_realloc_null_0, 0, 10);
1019 : tcase_add_loop_test(tc, memory_realloc_null_100, 0, 10);
1020 : tcase_add_loop_test(tc, memory_realloc_null_oom, 0, 10);
1021 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
1022 : tcase_add_loop_test_raise_signal(tc, memory_realloc_invalid_0,6, 0, 10);
1023 : tcase_add_loop_test_raise_signal(tc, memory_realloc_invalid_100,6, 0, 10);
1024 : tcase_add_loop_test_raise_signal(tc, memory_realloc_invalid_oom,6, 0, 10);
1025 : #endif
1026 : tcase_add_loop_test(tc, memory_realloc_valid_0, 0, 10);
1027 : tcase_add_loop_test(tc, memory_realloc_valid_updown, 0, 10);
1028 : tcase_add_loop_test(tc, memory_realloc_valid_oom, 0, 10);
1029 : tcase_add_loop_test(tc, memory_calloc_0_0, 0, 10);
1030 : tcase_add_loop_test(tc, memory_calloc_0_100, 0, 10);
1031 : tcase_add_loop_test(tc, memory_calloc_100_0, 0, 10);
1032 : tcase_add_loop_test(tc, memory_calloc_100_100, 0, 10);
1033 : tcase_add_loop_test(tc, memory_calloc_oom, 0, 10);
1034 : tcase_add_loop_test(tc, memory_free_null, 0, 10);
1035 : #ifndef NDEBUG /* Free non-heap pointer caught by gcc */
1036 : tcase_add_loop_test_raise_signal(tc, memory_free_invalid,6, 0, 10);
1037 : #endif
1038 : tcase_add_loop_test(tc, memory_free_valid, 0, 10);
1039 : #ifndef NDEBUG /* strdup(NULL) caught by gcc */
1040 : tcase_add_loop_test_raise_signal(tc, memory_strdup_null,11, 0, 10);
1041 : #endif
1042 : tcase_add_loop_test(tc, memory_strdup_empty, 0, 10);
1043 : tcase_add_loop_test(tc, memory_strdup_value, 0, 10);
1044 : tcase_add_loop_test_raise_signal(tc, memory_strdup_invalid,11, 0, 10);
1045 : tcase_add_loop_test(tc, memory_strdup_oom, 0, 10);
1046 : tcase_add_loop_test(tc, memory_asprintf, 0, 10);
1047 : tcase_add_loop_test(tc, memory_memreport, 0, 10);
1048 : #endif /* HAVE_LIBOOM */
1049 :
1050 365 : return s;
1051 : }
1052 :
1053 : /* vim: set tw=80: */
|