add first version
This commit is contained in:
Submodule test/lib/KUnity deleted from 09b89307c8
39
test/src/kunity_proc_test_file_handler_tests.c
Normal file
39
test/src/kunity_proc_test_file_handler_tests.c
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <kunity.h>
|
||||
#include <kunity_proc_test_file_handler.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
|
||||
//extern result_code_e kunity_module_runner_fake_test_function_ok(const ptr_output_functions_s output);
|
||||
|
||||
KUNITY_TEST(create_proc_test_file_null_argument)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(ERROR_NULL_ARGUMENT, create_proc_test_structure(NULL,NULL));
|
||||
}
|
||||
|
||||
|
||||
KUNITY_TEST(create_proc_test_file_ok)
|
||||
{
|
||||
test_s test;
|
||||
|
||||
test_list_s list;
|
||||
test_module_list_item_s module_item;
|
||||
test_list_item_s test_item;
|
||||
struct proc_dir_entry* test_root = proc_mkdir("test_kunity_test_root", NULL);
|
||||
module_item.test_module = THIS_MODULE;
|
||||
INIT_LIST_HEAD(&test_item.test_head);
|
||||
INIT_LIST_HEAD(&list.test_module_list);
|
||||
INIT_LIST_HEAD(&module_item.test_module_head);
|
||||
INIT_LIST_HEAD(&module_item.test_list);
|
||||
list_add(&test_item.test_head, &module_item.test_list);
|
||||
list_add(&module_item.test_module_head, &list.test_module_list);
|
||||
test.name = "fake_test_function";
|
||||
test.test_function = NULL;
|
||||
test_item.test = &test;
|
||||
if (test_root == NULL) {
|
||||
TEST_FAIL_MESSAGE("could not create \"test_kunity_test_root proc\" folder");
|
||||
}
|
||||
|
||||
TEST_ASSERT_EQUAL(OK, create_proc_test_structure(test_root, &list));
|
||||
proc_remove(test_root);
|
||||
}
|
||||
74
test/src/kunity_test_finder_tests.c
Normal file
74
test/src/kunity_test_finder_tests.c
Normal file
@@ -0,0 +1,74 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
#include <kunity.h>
|
||||
#include <kunity_test_finder.h>
|
||||
|
||||
|
||||
result_code_e kunity_module_runner_fake_test_function_ok(const ptr_test_session_control_block_s output)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
EXPORT_SYMBOL(kunity_module_runner_fake_test_function_ok);
|
||||
|
||||
static size_t tmp_list_counter;
|
||||
static result_code_e assert_test_item(/* in */ const ptr_test_list_item_s test_list_item)
|
||||
{
|
||||
TEST_ASSERT_NOT_EQUAL(NULL, test_list_item);
|
||||
TEST_ASSERT_NOT_EQUAL(NULL, test_list_item->test);
|
||||
TEST_ASSERT_NOT_EQUAL(NULL, test_list_item->test->name);
|
||||
TEST_ASSERT_NOT_EQUAL(NULL, test_list_item->test->test_function);
|
||||
tmp_list_counter++;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
KUNITY_TEST(test_find_test_null_argument)
|
||||
{
|
||||
TEST_ASSERT_EQUAL(ERROR_NULL_ARGUMENT, find_tests(NULL));
|
||||
}
|
||||
|
||||
KUNITY_TEST(test_find_test_invalid_argument)
|
||||
{
|
||||
test_list_s list;
|
||||
test_query_s query ={ KUNITY_DEFAULT_TEST_NAME_FITER_STR, "*", &list};
|
||||
|
||||
TEST_ASSERT_EQUAL(ERROR_INVALID_ARGUMENT, find_tests(&query));
|
||||
}
|
||||
|
||||
KUNITY_TEST(test_find_test_found)
|
||||
{
|
||||
ptr_test_module_list_item_s module = NULL;
|
||||
ptr_test_list_item_s test = NULL;
|
||||
test_query_s query ={ "kunity_module_runner_fake_test_function_ok", THIS_MODULE->name, NULL};
|
||||
TEST_ASSERT_EQUAL(OK, find_tests(&query));
|
||||
TEST_ASSERT_NOT_NULL(query.result_list);
|
||||
|
||||
module = list_first_entry(&query.result_list->test_module_list, test_module_list_item_s, test_module_head);
|
||||
TEST_ASSERT_NOT_NULL(module);
|
||||
test = list_first_entry(&module->test_list, test_list_item_s, test_head);
|
||||
TEST_ASSERT_NOT_NULL(test);
|
||||
TEST_ASSERT_EQUAL_STRING("kunity_module_runner_fake_test_function_ok", test->test->name);
|
||||
TEST_ASSERT_EQUAL_PTR(&kunity_module_runner_fake_test_function_ok, test->test->test_function);
|
||||
}
|
||||
|
||||
|
||||
KUNITY_TEST(test_find_tests_found)
|
||||
{
|
||||
ptr_test_module_list_item_s module = NULL;
|
||||
ptr_test_list_item_s test = NULL;
|
||||
test_query_s query ={ KUNITY_DEFAULT_TEST_NAME_FITER_STR, "*", NULL};
|
||||
TEST_ASSERT_EQUAL(OK, find_tests(&query));
|
||||
TEST_ASSERT_NOT_NULL (query.result_list);
|
||||
TEST_ASSERT_FALSE( list_empty(&query.result_list->test_module_list))
|
||||
module = list_first_entry(&query.result_list->test_module_list, test_module_list_item_s, test_module_head);
|
||||
TEST_ASSERT_FALSE( list_empty(&module->test_list))
|
||||
tmp_list_counter = 0;
|
||||
list_for_each_entry(test, &module->test_list, test_head)
|
||||
{
|
||||
assert_test_item(test);
|
||||
}
|
||||
|
||||
TEST_ASSERT_GREATER_OR_EQUAL(1, tmp_list_counter);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#include <kunity.h>
|
||||
#include <fff.h>
|
||||
DEFINE_FFF_GLOBALS
|
||||
|
||||
FAKE_VOID_FUNC(IO_MEM_WR8, int, int);
|
||||
|
||||
|
||||
KUNITY_TEST(bar_test)
|
||||
{
|
||||
IO_MEM_WR8(1,0);
|
||||
TEST_ASSERT_EQUAL_INT(1, IO_MEM_WR8_fake.call_count);
|
||||
TEST_ASSERT_TRUE(1)
|
||||
}
|
||||
|
||||
|
||||
void bar_test_2(void)
|
||||
{
|
||||
kunity_test_bar_test();
|
||||
pr_info ("huhu");
|
||||
}
|
||||
Reference in New Issue
Block a user