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>
This commit is contained in:
committed by
Bryce Harrington
parent
2ffb0afecb
commit
ecf819b82e
+21
-21
@@ -166,7 +166,7 @@ static struct zuc_fixture config_test_t4 = {
|
|||||||
.set_up = setup_test_config_failing,
|
.set_up = setup_test_config_failing,
|
||||||
};
|
};
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t0, comment_only)
|
ZUC_TEST_F(config_test_t0, comment_only, data)
|
||||||
{
|
{
|
||||||
struct weston_config *config = data;
|
struct weston_config *config = data;
|
||||||
ZUC_ASSERT_NOT_NULL(config);
|
ZUC_ASSERT_NOT_NULL(config);
|
||||||
@@ -174,7 +174,7 @@ ZUC_TEST_F(config_test_t0, comment_only)
|
|||||||
|
|
||||||
/** @todo individual t1 tests should have more descriptive names. */
|
/** @todo individual t1 tests should have more descriptive names. */
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test001)
|
ZUC_TEST_F(config_test_t1, test001, data)
|
||||||
{
|
{
|
||||||
struct weston_config_section *section;
|
struct weston_config_section *section;
|
||||||
struct weston_config *config = data;
|
struct weston_config *config = data;
|
||||||
@@ -184,7 +184,7 @@ ZUC_TEST_F(config_test_t1, test001)
|
|||||||
ZUC_ASSERT_NULL(section);
|
ZUC_ASSERT_NULL(section);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test002)
|
ZUC_TEST_F(config_test_t1, test002, data)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int r;
|
int r;
|
||||||
@@ -201,7 +201,7 @@ out_free:
|
|||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test003)
|
ZUC_TEST_F(config_test_t1, test003, data)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int r;
|
int r;
|
||||||
@@ -216,7 +216,7 @@ ZUC_TEST_F(config_test_t1, test003)
|
|||||||
ZUC_ASSERT_NULL(s);
|
ZUC_ASSERT_NULL(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test004)
|
ZUC_TEST_F(config_test_t1, test004, data)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int r;
|
int r;
|
||||||
@@ -233,7 +233,7 @@ out_free:
|
|||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test005)
|
ZUC_TEST_F(config_test_t1, test005, data)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int r;
|
int r;
|
||||||
@@ -251,7 +251,7 @@ out_free:
|
|||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test006)
|
ZUC_TEST_F(config_test_t1, test006, data)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
int32_t n;
|
int32_t n;
|
||||||
@@ -265,7 +265,7 @@ ZUC_TEST_F(config_test_t1, test006)
|
|||||||
ZUC_ASSERT_EQ(5252, n);
|
ZUC_ASSERT_EQ(5252, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test007)
|
ZUC_TEST_F(config_test_t1, test007, data)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
int32_t n;
|
int32_t n;
|
||||||
@@ -280,7 +280,7 @@ ZUC_TEST_F(config_test_t1, test007)
|
|||||||
ZUC_ASSERT_EQ(700, n);
|
ZUC_ASSERT_EQ(700, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test008)
|
ZUC_TEST_F(config_test_t1, test008, data)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
uint32_t u;
|
uint32_t u;
|
||||||
@@ -293,7 +293,7 @@ ZUC_TEST_F(config_test_t1, test008)
|
|||||||
ZUC_ASSERT_EQ(5252, u);
|
ZUC_ASSERT_EQ(5252, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test009)
|
ZUC_TEST_F(config_test_t1, test009, data)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
uint32_t u;
|
uint32_t u;
|
||||||
@@ -307,7 +307,7 @@ ZUC_TEST_F(config_test_t1, test009)
|
|||||||
ZUC_ASSERT_EQ(600, u);
|
ZUC_ASSERT_EQ(600, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test010)
|
ZUC_TEST_F(config_test_t1, test010, data)
|
||||||
{
|
{
|
||||||
int r, b;
|
int r, b;
|
||||||
struct weston_config_section *section;
|
struct weston_config_section *section;
|
||||||
@@ -319,7 +319,7 @@ ZUC_TEST_F(config_test_t1, test010)
|
|||||||
ZUC_ASSERT_EQ(0, b);
|
ZUC_ASSERT_EQ(0, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test011)
|
ZUC_TEST_F(config_test_t1, test011, data)
|
||||||
{
|
{
|
||||||
int r, b;
|
int r, b;
|
||||||
struct weston_config_section *section;
|
struct weston_config_section *section;
|
||||||
@@ -331,7 +331,7 @@ ZUC_TEST_F(config_test_t1, test011)
|
|||||||
ZUC_ASSERT_EQ(1, b);
|
ZUC_ASSERT_EQ(1, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test012)
|
ZUC_TEST_F(config_test_t1, test012, data)
|
||||||
{
|
{
|
||||||
int r, b;
|
int r, b;
|
||||||
struct weston_config_section *section;
|
struct weston_config_section *section;
|
||||||
@@ -343,7 +343,7 @@ ZUC_TEST_F(config_test_t1, test012)
|
|||||||
ZUC_ASSERT_EQ(1, b);
|
ZUC_ASSERT_EQ(1, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test013)
|
ZUC_TEST_F(config_test_t1, test013, data)
|
||||||
{
|
{
|
||||||
int r, b;
|
int r, b;
|
||||||
struct weston_config_section *section;
|
struct weston_config_section *section;
|
||||||
@@ -356,7 +356,7 @@ ZUC_TEST_F(config_test_t1, test013)
|
|||||||
ZUC_ASSERT_EQ(-1, b);
|
ZUC_ASSERT_EQ(-1, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test014)
|
ZUC_TEST_F(config_test_t1, test014, data)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int r;
|
int r;
|
||||||
@@ -374,7 +374,7 @@ out_free:
|
|||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test015)
|
ZUC_TEST_F(config_test_t1, test015, data)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int r;
|
int r;
|
||||||
@@ -392,7 +392,7 @@ out_free:
|
|||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test016)
|
ZUC_TEST_F(config_test_t1, test016, data)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
int r;
|
int r;
|
||||||
@@ -412,7 +412,7 @@ out_free:
|
|||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t1, test017)
|
ZUC_TEST_F(config_test_t1, test017, data)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
int i;
|
int i;
|
||||||
@@ -427,19 +427,19 @@ ZUC_TEST_F(config_test_t1, test017)
|
|||||||
ZUC_ASSERT_EQ(5, i);
|
ZUC_ASSERT_EQ(5, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t2, doesnt_parse)
|
ZUC_TEST_F(config_test_t2, doesnt_parse, data)
|
||||||
{
|
{
|
||||||
struct weston_config *config = data;
|
struct weston_config *config = data;
|
||||||
ZUC_ASSERT_NULL(config);
|
ZUC_ASSERT_NULL(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t3, doesnt_parse)
|
ZUC_TEST_F(config_test_t3, doesnt_parse, data)
|
||||||
{
|
{
|
||||||
struct weston_config *config = data;
|
struct weston_config *config = data;
|
||||||
ZUC_ASSERT_NULL(config);
|
ZUC_ASSERT_NULL(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZUC_TEST_F(config_test_t4, doesnt_parse)
|
ZUC_TEST_F(config_test_t4, doesnt_parse, data)
|
||||||
{
|
{
|
||||||
struct weston_config *config = data;
|
struct weston_config *config = data;
|
||||||
ZUC_ASSERT_NULL(config);
|
ZUC_ASSERT_NULL(config);
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* Structure to use when defining a test fixture.
|
* Structure to use when defining a test fixture.
|
||||||
* @note likely pending refactoring as use cases are refined.
|
* @note likely pending refactoring as use cases are refined.
|
||||||
|
* @see ZUC_TEST_F()
|
||||||
*/
|
*/
|
||||||
struct zuc_fixture {
|
struct zuc_fixture {
|
||||||
/**
|
/**
|
||||||
@@ -259,6 +260,9 @@ zuc_set_output_junit(bool enable);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a test case that can be registered to run.
|
* 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) \
|
#define ZUC_TEST(tcase, test) \
|
||||||
static void zuctest_##tcase##_##test(void); \
|
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
|
* Defines a test case that can be registered to run along with setup/teardown
|
||||||
* support per-test and/or per test case.
|
* support per-test and/or per test case.
|
||||||
*
|
*
|
||||||
* @note likely pending refactoring as use cases are refined.
|
* @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) \
|
#define ZUC_TEST_F(tcase, test, param) \
|
||||||
static void zuctest_##tcase##_##test(void *data); \
|
static void zuctest_##tcase##_##test(void *param); \
|
||||||
\
|
\
|
||||||
const struct zuc_registration zzz_##tcase##_##test \
|
const struct zuc_registration zzz_##tcase##_##test \
|
||||||
__attribute__ ((section ("zuc_tsect"))) = \
|
__attribute__ ((section ("zuc_tsect"))) = \
|
||||||
@@ -290,7 +305,7 @@ zuc_set_output_junit(bool enable);
|
|||||||
zuctest_##tcase##_##test \
|
zuctest_##tcase##_##test \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
static void zuctest_##tcase##_##test(void *data)
|
static void zuctest_##tcase##_##test(void *param)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ static struct zuc_fixture fixture_minimal = {
|
|||||||
.data = "for all good men to",
|
.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;
|
const char *str = data;
|
||||||
ZUC_ASSERT_NOT_NULL(str);
|
ZUC_ASSERT_NOT_NULL(str);
|
||||||
@@ -86,7 +86,7 @@ static struct zuc_fixture fixture_data0 = {
|
|||||||
.tear_down = teardown_test_config
|
.tear_down = teardown_test_config
|
||||||
};
|
};
|
||||||
|
|
||||||
ZUC_TEST_F(fixture_data0, base)
|
ZUC_TEST_F(fixture_data0, base, data)
|
||||||
{
|
{
|
||||||
const char *str = data;
|
const char *str = data;
|
||||||
ZUC_ASSERT_NOT_NULL(str);
|
ZUC_ASSERT_NOT_NULL(str);
|
||||||
@@ -95,7 +95,7 @@ ZUC_TEST_F(fixture_data0, base)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Use the same fixture for a second test. */
|
/* 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;
|
int i;
|
||||||
const char *str = data;
|
const char *str = data;
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ struct zuc_fixture complex_test = {
|
|||||||
* but the fixture should reset that.
|
* 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;
|
struct fixture_data *fdata = data;
|
||||||
ZUC_ASSERT_NOT_NULL(fdata);
|
ZUC_ASSERT_NOT_NULL(fdata);
|
||||||
@@ -231,7 +231,7 @@ ZUC_TEST_F(complex_test, bases_cenario)
|
|||||||
ZUC_ASSERT_EQ(2, fdata->test_counter);
|
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;
|
struct fixture_data *fdata = data;
|
||||||
ZUC_ASSERT_NOT_NULL(fdata);
|
ZUC_ASSERT_NOT_NULL(fdata);
|
||||||
@@ -243,7 +243,7 @@ ZUC_TEST_F(complex_test, something)
|
|||||||
ZUC_ASSERT_EQ(2, fdata->test_counter);
|
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;
|
struct fixture_data *fdata = data;
|
||||||
ZUC_ASSERT_NOT_NULL(fdata);
|
ZUC_ASSERT_NOT_NULL(fdata);
|
||||||
|
|||||||
Reference in New Issue
Block a user