From: Unsung Lee Date: Tue, 12 Jul 2022 10:21:48 +0000 (+0900) Subject: Supplement cpu-boosting test code X-Git-Tag: submit/tizen/20220722.040833~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ceeb725b9c47b8b1a7f546f140be2b885ce63452;p=platform%2Fcore%2Fapi%2Fresource.git Supplement cpu-boosting test code Change-Id: Id905be00f3a9fa2f9dd6d49d2fd9f82d1e0c09c9 Signed-off-by: Unsung Lee --- diff --git a/src/plugin/plugin.c b/src/plugin/plugin.c index 038886e..40e9e73 100644 --- a/src/plugin/plugin.c +++ b/src/plugin/plugin.c @@ -247,10 +247,9 @@ API int resource_get_cpu_boosting_level (resource_pid_t pid, if (!output.success) { _E("[CPU-BOOSTING-PLUGIN] Failed to get boosting"); + free(level->tid_level); ret = -1; } - else - _D("[CPU-BOOSTING-PLUGIN] Success to get boosting"); close_sock: close(sock); diff --git a/tests/main.c b/tests/main.c index 1009a8b..f719060 100644 --- a/tests/main.c +++ b/tests/main.c @@ -50,7 +50,7 @@ static void *thread_worker(void *arg) if (tid) *tid = gettid(); - sleep(5); + sleep(3); pthread_exit(NULL); } @@ -78,10 +78,21 @@ static void test_get_cpu_boosting(resource_pid_t pid, cpu_boosting_level_info_t { int ret; + level->tid_level = NULL; ret = resource_get_cpu_boosting_level(pid, level); - if (ret) { + if (ret < 0) { _E("[CPU-BOOSTING-TEST] error = %d", ret); } + else { + for(int i = 0; i < level->tid_count; i++) + _I("[CPU-BOOSTING-TEST] boosting level is %s", + level->tid_level[i] == CPU_BOOSTING_LEVEL_STRONG ? "strong" : + level->tid_level[i] == CPU_BOOSTING_LEVEL_MEDIUM ? "medium" : + level->tid_level[i] == CPU_BOOSTING_LEVEL_WEAK ? "weak" : "none"); + + if (level->tid_level) + free(level->tid_level); + } } static void test_cpu_boosting(resource_pid_t pid) @@ -91,9 +102,11 @@ static void test_cpu_boosting(resource_pid_t pid) for (int level = CPU_BOOSTING_LEVEL_WEAK; level > CPU_BOOSTING_LEVEL_NONE; level--) test_set_cpu_boosting(pid, level, 3000); - test_get_cpu_boosting(pid, &cur_level); /* Expect CPU_BOOSTING_LEVEL_STRRONG */ + test_get_cpu_boosting(pid, &cur_level); /* Expect CPU_BOOSTING_LEVEL_STRONG */ + test_clear_cpu_boosting(pid); test_get_cpu_boosting(pid, &cur_level); /* Expect CPU_BOOSTING_LEVEL_NONE */ + sleep(3); } static void one_process_one_thread_test(void)