libs/gst/check/gstcheck.*: Allow runtime selection of unit tests to run via the GST_CHECKS environment variable (test...

Original commit message from CVS:
* libs/gst/check/gstcheck.c:
* libs/gst/check/gstcheck.h:
Allow runtime selection of unit tests to run via the GST_CHECKS
environment variable (test case function names, comma-separated).
This commit is contained in:
Tim-Philipp Müller 2007-10-16 16:12:36 +00:00
parent 2b4644f737
commit eb1af0ddab
3 changed files with 48 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2007-10-16 Tim-Philipp Müller <tim at centricular dot net>
* libs/gst/check/gstcheck.c:
* libs/gst/check/gstcheck.h:
Allow runtime selection of unit tests to run via the GST_CHECKS
environment variable (test case function names, comma-separated).
2007-10-16 Stefan Kost <ensonic@users.sf.net>
* gst/gststructure.c:

View file

@ -329,3 +329,28 @@ gst_check_run_suite (Suite * suite, const gchar * name, const gchar * fname)
srunner_free (sr);
return nf;
}
gboolean
_gst_check_run_test_func (const gchar * func_name)
{
const gchar *gst_checks;
gboolean res = FALSE;
gchar **funcs, **f;
gst_checks = g_getenv ("GST_CHECKS");
/* no filter specified => run all checks */
if (gst_checks == NULL || *gst_checks == '\0')
return TRUE;
/* only run specified functions */
funcs = g_strsplit (gst_checks, ",", -1);
for (f = funcs; f != NULL && *f != NULL; ++f) {
if (strcmp (*f, func_name) == 0) {
res = TRUE;
break;
}
}
g_strfreev (funcs);
return res;
}

View file

@ -396,6 +396,22 @@ int main (int argc, char **argv) \
return gst_check_run_suite (s, # name, __FILE__); \
}
/* Hack to allow run-time selection of unit tests to run via the
* GST_CHECKS environment variable (test function names, comma-separated) */
gboolean _gst_check_run_test_func (const gchar * func_name);
static inline void
__gst_tcase_add_test (TCase * tc, TFun tf, const gchar * func_name)
{
if (_gst_check_run_test_func (func_name)) {
tcase_add_test (tc, tf);
}
}
#undef tcase_add_test
#define tcase_add_test(tc,tf) __gst_tcase_add_test(tc,tf,G_STRINGIFY(tf))
G_END_DECLS
#endif /* __GST_CHECK_H__ */