add proc file tests

This commit is contained in:
stubbfel
2018-03-28 16:19:23 +02:00
parent 7d3f2a8beb
commit eb96de3b5f
5 changed files with 73 additions and 10 deletions

View 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);
}