// SPDX-License-Identifier: GPL-2.0 /* * KUnit test for the KUnit executor. * * Copyright (C) 2021, Google LLC. * Author: Daniel Latypov <dlatypov@google.com>
*/
/* Validate we just have suite2 */
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, got.start[0]);
KUNIT_EXPECT_STREQ(test, (constchar *)got.start[0]->name, "suite2");
/* Contains one element (end is 1 past end) */
KUNIT_ASSERT_EQ(test, got.end - got.start, 1);
}
/* Validate we just have suite2 */
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, got.start[0]);
KUNIT_EXPECT_STREQ(test, (constchar *)got.start[0]->name, "suite2");
KUNIT_ASSERT_EQ(test, got.end - got.start, 1);
/* Now validate we just have test2 */
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, got.start[0]->test_cases);
KUNIT_EXPECT_STREQ(test, (constchar *)got.start[0]->test_cases[0].name, "test2");
KUNIT_EXPECT_FALSE(test, got.start[0]->test_cases[1].name);
}
subsuite[0] = alloc_fake_suite(test, "normal_suite", dummy_attr_test_cases);
subsuite[1] = alloc_fake_suite(test, "slow_suite", dummy_attr_test_cases);
subsuite[1]->attr.speed = KUNIT_SPEED_SLOW; // Set suite attribute
/* * Want: normal_suite(slow, normal), slow_suite(slow, normal), * NULL -> normal_suite(normal), NULL * * The normal test in slow_suite is filtered out because the speed * attribute is unset and thus, the filtering is based on the parent attribute * of slow.
*/
got = kunit_filter_suites(&suite_set, NULL, filter, NULL, &err);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, got.start);
KUNIT_ASSERT_EQ(test, err, 0);
free_suite_set_at_end(test, &got);
/* Validate we just have normal_suite */
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, got.start[0]);
KUNIT_EXPECT_STREQ(test, got.start[0]->name, "normal_suite");
KUNIT_ASSERT_EQ(test, got.end - got.start, 1);
/* Now validate we just have normal test case */
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, got.start[0]->test_cases);
KUNIT_EXPECT_STREQ(test, got.start[0]->test_cases[0].name, "normal");
KUNIT_EXPECT_FALSE(test, got.start[0]->test_cases[1].name);
}
/* Validate we have both the slow and normal test */
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, got.start[0]->test_cases);
KUNIT_ASSERT_EQ(test, kunit_suite_num_test_cases(got.start[0]), 2);
KUNIT_EXPECT_STREQ(test, got.start[0]->test_cases[0].name, "slow");
KUNIT_EXPECT_STREQ(test, got.start[0]->test_cases[1].name, "normal");
/* Now ensure slow is skipped and normal is not */
KUNIT_EXPECT_EQ(test, got.start[0]->test_cases[0].status, KUNIT_SKIPPED);
KUNIT_EXPECT_FALSE(test, got.start[0]->test_cases[1].status);
}
/* Use the resource API to register a call to free_suite_set. * Since we never actually use the resource, it's safe to use on const data.
*/ staticvoid free_suite_set_at_end(struct kunit *test, constvoid *to_free)
{ struct kunit_suite_set *free;
if (!((struct kunit_suite_set *)to_free)->start) return;
/* We normally never expect to allocate suites, hence the non-const cast. */
suite = kunit_kzalloc(test, sizeof(*suite), GFP_KERNEL);
strscpy((char *)suite->name, suite_name, sizeof(suite->name));
suite->test_cases = test_cases;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.