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:
Michael Jerris 2009-02-12 21:18:20 +00:00
parent f10955584c
commit 9bbacf9669
3 changed files with 19 additions and 4 deletions

View File

@ -1 +1 @@
Thu Feb 12 15:17:34 CST 2009
Thu Feb 12 15:18:14 CST 2009

View File

@ -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 */

View File

@ -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;