Commit 757235af authored by Pekka Pessi's avatar Pekka Pessi

s2tcase.c: allow multiple calls to s2_select_tests()

Ignore-this: ae389020a9cb4dd53d82d808426a23d2

darcs-hash:20090212202712-db55f-24434ef4b7df832d948a1b21d330d6fa960ea117.gz
parent f2c80a7a
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment