add proc file tests
This commit is contained in:
51
test/src/kunity_proc_test_file_handler_tests.c
Normal file
51
test/src/kunity_proc_test_file_handler_tests.c
Normal file
@@ -0,0 +1,51 @@
|
||||
#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_file(NULL));
|
||||
}
|
||||
|
||||
|
||||
KUNITY_TEST(create_proc_test_file_invalid_argument)
|
||||
{
|
||||
test_list_item_s test_item;
|
||||
test_item.test = NULL;
|
||||
TEST_ASSERT_EQUAL(ERROR_INVALID_ARGUMENT, create_proc_test_file(&test_item));
|
||||
}
|
||||
|
||||
|
||||
KUNITY_TEST(create_proc_test_file_invalid_operation_null_names)
|
||||
{
|
||||
test_s test;
|
||||
test_list_item_s test_item;
|
||||
test.modul_name = NULL;
|
||||
test.name = NULL;
|
||||
test.test_function = NULL;
|
||||
|
||||
test_item.test = &test;
|
||||
TEST_ASSERT_EQUAL(ERROR_INVALID_OPERATION, create_proc_test_file(&test_item));
|
||||
}
|
||||
|
||||
KUNITY_TEST(create_proc_test_file_ok)
|
||||
{
|
||||
test_s test;
|
||||
test_list_item_s test_item;
|
||||
struct proc_dir_entry* test_root = proc_mkdir("test_kunity_test_root", NULL);
|
||||
test.modul_name = "fake_test_module";
|
||||
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");
|
||||
}
|
||||
|
||||
set_proc_test_root_folder(test_root);
|
||||
TEST_ASSERT_EQUAL(OK, create_proc_test_file(&test_item));
|
||||
proc_remove(test_root);
|
||||
}
|
||||
Reference in New Issue
Block a user