From 1d2e280bef7884fe8b1cfcd75d2e5f415252bd2b Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 12 Feb 2019 17:19:19 +0800 Subject: [PATCH] cstest: code style --- suite/cstest/src/main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/suite/cstest/src/main.c b/suite/cstest/src/main.c index b838fd8e0..3337014d3 100644 --- a/suite/cstest/src/main.c +++ b/suite/cstest/src/main.c @@ -52,13 +52,13 @@ static int setup_MC(void **state) counter++; while (counter < size_lines && list_lines[counter][0] != '0') counter++; free_strs(list_params, size_params); + return 0; } static void test_MC(void **state) { test_single_MC((csh *)*state, list_lines[counter]); - return; } static int teardown_MC(void **state) @@ -98,7 +98,7 @@ static int setup_issue(void **state) handle = (csh *)calloc(1, sizeof(csh)); cs_open(arch, mode, handle); - for (i=2; i < size_params; ++i) + for (i=2; i < size_params; ++i) { if (strcmp(list_params[i], "None")) { index = get_index(options, NUMOPTION, list_params[i]); if (index == -1) { @@ -117,11 +117,14 @@ static int setup_issue(void **state) } cs_option(*handle, options[index].first_value, options[index].second_value); } + } + *state = (void *)handle; issue_mode = mode; while (counter < size_lines && list_lines[counter][0] != '0') counter ++; free_strs(list_params, size_params); + return 0; } @@ -171,14 +174,15 @@ static void test_file(const char *filename) number_of_tests ++; } } + _cmocka_run_group_tests("Testing issues", tests, number_of_tests, NULL, NULL); } else { list_lines = split(content, "\n", &size_lines); number_of_tests = 0; tests = NULL; -// tests = (struct CMUnitTest *)malloc(sizeof(struct CMUnitTest) * (size_lines - 1)); - for (i=0; i < size_lines - 1; ++i) { + // tests = (struct CMUnitTest *)malloc(sizeof(struct CMUnitTest) * (size_lines - 1)); + for (i=0; i < size_lines - 1; ++i) { if (list_lines[i][0] == '#' || list_lines[i][0] == '0') { char *tmp = (char *)malloc(sizeof(char) * 100); sprintf(tmp, "Line %d", i+2);