#endif
+static void test_get_cpu_boosting(resource_pid_t pid, cpu_boosting_level_info_t *level, bool forked);
+
static void *thread_worker(void *arg)
{
pid_t *tid = (pid_t *)arg;
pthread_exit(NULL);
}
+static void *thread_attr_check(void *arg)
+{
+ cpu_boosting_level_info_t cur_level;
+ resource_pid_t pid;
+
+ pid.pid = 0;
+ pid.tid = NULL;
+ pid.tid_count = 0;
+
+ test_get_cpu_boosting(pid, &cur_level, true); /* Expect CPU_BOOSTING_LEVEL_NONE */
+ pthread_exit(NULL);
+}
+
static void test_set_cpu_boosting(resource_pid_t pid, cpu_boosting_level_e level, cpu_boosting_flag_e flag, int timeout_msec)
{
int ret;
}
}
-static void test_get_cpu_boosting(resource_pid_t pid, cpu_boosting_level_info_t *level)
+static void test_get_cpu_boosting(resource_pid_t pid, cpu_boosting_level_info_t *level, bool forked)
{
int ret;
}
else {
for(int i = 0; i < level->tid_count; i++)
- _I("[CPU-BOOSTING-TEST] boosting level is %s",
+ _I("[CPU-BOOSTING-TEST] %sboosting level is %s", forked ? "Child thread " : "",
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");
for (int level = CPU_BOOSTING_LEVEL_WEAK; level > CPU_BOOSTING_LEVEL_NONE; level--)
test_set_cpu_boosting(pid, level, flag, 3000);
- test_get_cpu_boosting(pid, &cur_level); /* Expect CPU_BOOSTING_LEVEL_STRONG */
+ if (flag & CPU_BOOSTING_RESET_ON_FORK) {
+ pthread_t thread;
+ int ret = pthread_create(&thread, NULL, thread_attr_check, NULL);
+ if (ret == 0) {
+ ret = pthread_detach(thread);
+ if (ret)
+ _E("[CPU-BOOSTING-TEST] Failed to join a new thread");
+ }
+ else
+ _E("[CPU-BOOSTING-TEST] Failed to create a new thread");
+ }
+ test_get_cpu_boosting(pid, &cur_level, false); /* Expect CPU_BOOSTING_LEVEL_STRONG */
test_clear_cpu_boosting(pid);
- test_get_cpu_boosting(pid, &cur_level); /* Expect CPU_BOOSTING_LEVEL_NONE */
+ test_get_cpu_boosting(pid, &cur_level, false); /* Expect CPU_BOOSTING_LEVEL_NONE */
}
static void one_process_one_thread_test(cpu_boosting_flag_e flag)
}
pid.pid = 0;
pid.tid_count = real_tid_count;
+
+ usleep(300000);
test_cpu_boosting(pid, 0);
free(pid.tid);
}
_D("[CPU-BOOSTING-TEST] <<<<<<<<<< One Process One Thread >>>>>>>>>>");
one_process_one_thread_test(0);
- return 0;
-
/* Case 2: Boosting single-threaded processes */
_D("[CPU-BOOSTING-TEST] <<<<<<<<<< Multi Processes One Thread >>>>>>>>>>");
multi_process_one_thread_test(7);