summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJon Cruz <jonc@osg.samsung.com>2015-10-22 21:11:12 -0700
committerBryce Harrington <bryce@osg.samsung.com>2015-10-23 14:57:09 -0700
commitecf819b82e200177ef8f76097df0aeec1178a6a0 (patch)
tree64650839db0402146686110f179d617b89ca2ac4 /tools
parent2ffb0afecbf4dcef5899100bbd723fd4d0699c22 (diff)
downloadweston-ecf819b82e200177ef8f76097df0aeec1178a6a0.tar.gz
zunitc: made name of test fixture parameter explicit.
Instead of using the implicit name 'data', changed the test with fixture macro ZUC_TEST_F() to use an additional value to explicitly set the name to use for test data from the fixture. Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/zunitc/inc/zunitc/zunitc.h25
-rw-r--r--tools/zunitc/test/fixtures_test.c6
-rw-r--r--tools/zunitc/test/zunitc_test.c6
3 files changed, 26 insertions, 11 deletions
diff --git a/tools/zunitc/inc/zunitc/zunitc.h b/tools/zunitc/inc/zunitc/zunitc.h
index d04b599a..0fa78e3d 100644
--- a/tools/zunitc/inc/zunitc/zunitc.h
+++ b/tools/zunitc/inc/zunitc/zunitc.h
@@ -57,6 +57,7 @@ extern "C" {
/**
* Structure to use when defining a test fixture.
* @note likely pending refactoring as use cases are refined.
+ * @see ZUC_TEST_F()
*/
struct zuc_fixture {
/**
@@ -259,6 +260,9 @@ zuc_set_output_junit(bool enable);
/**
* Defines a test case that can be registered to run.
+ *
+ * @param tcase name to use as the containing test case.
+ * @param test name used for the test under a given test case.
*/
#define ZUC_TEST(tcase, test) \
static void zuctest_##tcase##_##test(void); \
@@ -277,10 +281,21 @@ zuc_set_output_junit(bool enable);
* Defines a test case that can be registered to run along with setup/teardown
* support per-test and/or per test case.
*
- * @note likely pending refactoring as use cases are refined.
- */
-#define ZUC_TEST_F(tcase, test) \
- static void zuctest_##tcase##_##test(void *data); \
+ * @note This defines a test that *uses* a fixture, it does not
+ * actually define a test fixture itself.
+ *
+ * @param tcase name to use as the containing test case/fixture.
+ * The name used must represent a test fixture instance. It also
+ * must not duplicate any name used in a non-fixture ZUC_TEST()
+ * test.
+ * @note the test case name must be the name of a fixture struct
+ * to be passed to the test.
+ * @param test name used for the test under a given test case.
+ * @param param name for the fixture data pointer.
+ * @see struct zuc_fixture
+ */
+#define ZUC_TEST_F(tcase, test, param) \
+ static void zuctest_##tcase##_##test(void *param); \
\
const struct zuc_registration zzz_##tcase##_##test \
__attribute__ ((section ("zuc_tsect"))) = \
@@ -290,7 +305,7 @@ zuc_set_output_junit(bool enable);
zuctest_##tcase##_##test \
}; \
\
- static void zuctest_##tcase##_##test(void *data)
+ static void zuctest_##tcase##_##test(void *param)
/**
diff --git a/tools/zunitc/test/fixtures_test.c b/tools/zunitc/test/fixtures_test.c
index 89c1e3e1..04a0ba93 100644
--- a/tools/zunitc/test/fixtures_test.c
+++ b/tools/zunitc/test/fixtures_test.c
@@ -43,7 +43,7 @@ static struct zuc_fixture fixture_minimal = {
.data = "for all good men to",
};
-ZUC_TEST_F(fixture_minimal, just_as_is)
+ZUC_TEST_F(fixture_minimal, just_as_is, data)
{
const char *str = data;
ZUC_ASSERT_NOT_NULL(str);
@@ -86,7 +86,7 @@ static struct zuc_fixture fixture_data0 = {
.tear_down = teardown_test_config
};
-ZUC_TEST_F(fixture_data0, base)
+ZUC_TEST_F(fixture_data0, base, data)
{
const char *str = data;
ZUC_ASSERT_NOT_NULL(str);
@@ -95,7 +95,7 @@ ZUC_TEST_F(fixture_data0, base)
}
/* Use the same fixture for a second test. */
-ZUC_TEST_F(fixture_data0, no_lower)
+ZUC_TEST_F(fixture_data0, no_lower, data)
{
int i;
const char *str = data;
diff --git a/tools/zunitc/test/zunitc_test.c b/tools/zunitc/test/zunitc_test.c
index 177c6bc8..8000aa84 100644
--- a/tools/zunitc/test/zunitc_test.c
+++ b/tools/zunitc/test/zunitc_test.c
@@ -219,7 +219,7 @@ struct zuc_fixture complex_test = {
* but the fixture should reset that.
*/
-ZUC_TEST_F(complex_test, bases_cenario)
+ZUC_TEST_F(complex_test, bases_cenario, data)
{
struct fixture_data *fdata = data;
ZUC_ASSERT_NOT_NULL(fdata);
@@ -231,7 +231,7 @@ ZUC_TEST_F(complex_test, bases_cenario)
ZUC_ASSERT_EQ(2, fdata->test_counter);
}
-ZUC_TEST_F(complex_test, something)
+ZUC_TEST_F(complex_test, something, data)
{
struct fixture_data *fdata = data;
ZUC_ASSERT_NOT_NULL(fdata);
@@ -243,7 +243,7 @@ ZUC_TEST_F(complex_test, something)
ZUC_ASSERT_EQ(2, fdata->test_counter);
}
-ZUC_TEST_F(complex_test, else_here)
+ZUC_TEST_F(complex_test, else_here, data)
{
struct fixture_data *fdata = data;
ZUC_ASSERT_NOT_NULL(fdata);