Supplement cpu-boosting test code 22/277722/2
authorUnsung Lee <unsung.lee@samsung.com>
Tue, 12 Jul 2022 10:21:48 +0000 (19:21 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 12 Jul 2022 10:28:36 +0000 (10:28 +0000)
Change-Id: Id905be00f3a9fa2f9dd6d49d2fd9f82d1e0c09c9
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/plugin/plugin.c
tests/main.c

index 038886edc6fa0da11586c4f676f1ea753cff005d..40e9e7350209babe37a18d8562a00bd6b3e12b18 100644 (file)
@@ -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);
index 1009a8b6e28e832632a0fe4082b477362f55ca17..f719060f582f1d5b8614d8352785fe2577baf30b 100644 (file)
@@ -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)