forked from Mirrors/freeswitch
Thu Feb 12 14:27:12 CST 2009 Pekka Pessi <first.last@nokia.com>
* s2tcase.c: allow multiple calls to s2_select_tests() git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11953 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
f10955584c
commit
9bbacf9669
@ -1 +1 @@
|
||||
Thu Feb 12 15:17:34 CST 2009
|
||||
Thu Feb 12 15:18:14 CST 2009
|
||||
|
@ -47,6 +47,8 @@ SOFIA_BEGIN_DECLS
|
||||
|
||||
void s2_tcase_add_test(TCase *, TFun, char const *name);
|
||||
|
||||
void s2_select_tests(char const *pattern);
|
||||
|
||||
SOFIA_END_DECLS
|
||||
|
||||
#endif /* S2CHECK_H */
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
@ -79,7 +80,7 @@ void s2_tcase_add_test(TCase *tc, TFun tf, char const *name)
|
||||
*/
|
||||
void s2_select_tests(char const *pattern)
|
||||
{
|
||||
size_t i;
|
||||
size_t i, n;
|
||||
char *cases, *s, **patterns;
|
||||
|
||||
if (!pattern)
|
||||
@ -91,10 +92,22 @@ void s2_select_tests(char const *pattern)
|
||||
for (i = 2, s = cases; (s = strchr(s, ',')); s++)
|
||||
i++;
|
||||
|
||||
patterns = calloc(i, sizeof *patterns);
|
||||
if (test_patterns != default_patterns) {
|
||||
patterns = (char **)test_patterns;
|
||||
for (n = 0; patterns[n]; n++)
|
||||
;
|
||||
patterns = realloc(patterns, (n + i) * (sizeof *patterns));
|
||||
}
|
||||
else {
|
||||
n = 0;
|
||||
patterns = malloc(i * (sizeof *patterns));
|
||||
}
|
||||
|
||||
assert(patterns);
|
||||
memset(&patterns[n], 0, i * (sizeof *patterns));
|
||||
|
||||
/* Split by commas */
|
||||
for (i = 0, s = cases;; i++) {
|
||||
for (i = n, s = cases;; i++) {
|
||||
patterns[i] = s;
|
||||
if (s == NULL)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user