Appl new code style on whole code base

Use a similar code style to bemanitools though reduce indentation
to 2 spaces. Also some other tweaks to be more similar to google
style.
This commit is contained in:
icex2
2021-03-19 15:52:34 +01:00
parent b493b4983a
commit eafb2909d1
322 changed files with 30291 additions and 25084 deletions
+36 -37
View File
@@ -8,66 +8,65 @@ typedef int (*test_mock_function_t)(int a);
static int test_mock_function(int a)
{
return a * 2;
return a * 2;
}
static void test_cnh_lib_mock_init_unit_test(void** state)
static void test_cnh_lib_mock_init_unit_test(void **state)
{
struct cnh_lib_unit_test_func_mocks* mocks;
size_t mocks_cnt;
void* ptr;
struct cnh_lib_unit_test_func_mocks *mocks;
size_t mocks_cnt;
void *ptr;
mocks_cnt = 1;
mocks = cnh_lib_allocate_func_mocks(mocks_cnt);
mocks_cnt = 1;
mocks = cnh_lib_allocate_func_mocks(mocks_cnt);
mocks[0].name = "test_mock_function";
mocks[0].func = test_mock_function;
mocks[0].name = "test_mock_function";
mocks[0].func = test_mock_function;
cnh_lib_init_unit_test(mocks, mocks_cnt);
cnh_lib_init_unit_test(mocks, mocks_cnt);
ptr = cnh_lib_load("asdf");
assert_ptr_not_equal(ptr, NULL);
ptr = cnh_lib_load("asdf");
assert_ptr_not_equal(ptr, NULL);
ptr = cnh_lib_get_func_addr_handle(ptr, "test_mock_function");
assert_ptr_equal(ptr, test_mock_function);
ptr = cnh_lib_get_func_addr_handle(ptr, "test_mock_function");
assert_ptr_equal(ptr, test_mock_function);
assert_int_equal(((test_mock_function_t) ptr)(2), 4);
assert_int_equal(((test_mock_function_t) ptr)(2), 4);
ptr = cnh_lib_get_func_addr_handle(ptr, "asdf");
assert_ptr_equal(ptr, NULL);
ptr = cnh_lib_get_func_addr_handle(ptr, "asdf");
assert_ptr_equal(ptr, NULL);
cnh_lib_unload(ptr);
// Nothing happens here
cnh_lib_unload(ptr);
// Nothing happens here
ptr = cnh_lib_get_func_addr( "test_mock_function");
assert_ptr_equal(ptr, test_mock_function);
ptr = cnh_lib_get_func_addr("test_mock_function");
assert_ptr_equal(ptr, test_mock_function);
cnh_lib_shutdown_unit_test();
cnh_lib_shutdown_unit_test();
}
static void test_cnh_lib_real(void** state)
static void test_cnh_lib_real(void **state)
{
void* ptr;
void *ptr;
cnh_lib_init();
cnh_lib_init();
ptr = cnh_lib_load("libc.so.6");
ptr = cnh_lib_load("libc.so.6");
assert_ptr_not_equal(ptr, NULL);
assert_ptr_equal(cnh_lib_load("asdfasdas"), NULL);
assert_ptr_not_equal(ptr, NULL);
assert_ptr_equal(cnh_lib_load("asdfasdas"), NULL);
assert_ptr_not_equal(cnh_lib_get_func_addr_handle(ptr, "printf"), NULL);
assert_ptr_not_equal(cnh_lib_get_func_addr("printf"), NULL);
assert_ptr_not_equal(cnh_lib_get_func_addr_handle(ptr, "printf"), NULL);
assert_ptr_not_equal(cnh_lib_get_func_addr("printf"), NULL);
assert_ptr_equal(cnh_lib_get_func_addr("asdasdas"), NULL);
assert_ptr_equal(cnh_lib_get_func_addr("asdasdas"), NULL);
}
int main(int argc, char* argv[])
int main(int argc, char *argv[])
{
const struct CMUnitTest tests[] ={
cmocka_unit_test(test_cnh_lib_mock_init_unit_test),
cmocka_unit_test(test_cnh_lib_real)
};
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_cnh_lib_mock_init_unit_test),
cmocka_unit_test(test_cnh_lib_real)};
return cmocka_run_group_tests(tests, NULL, NULL);
return cmocka_run_group_tests(tests, NULL, NULL);
}