tests: unittest: Add pass-parser test for each resource 24/276924/4
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 22 Jun 2022 10:05:44 +0000 (19:05 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 5 Jul 2022 01:25:18 +0000 (10:25 +0900)
Add the unittest of pass-parser features which parse the each resource
configurations.

Change-Id: I1eaacd4340d4d19d236285a98ef0c10772ca9a46
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
tests/unittest/pass-unittests.cc
tests/unittest/scripts/valid/pass-battery.json [new file with mode: 0644]
tests/unittest/scripts/valid/pass-bus0.json [new file with mode: 0644]
tests/unittest/scripts/valid/pass-bus1.json [new file with mode: 0644]
tests/unittest/scripts/valid/pass-cpu0.json [new file with mode: 0644]
tests/unittest/scripts/valid/pass-cpu4.json [new file with mode: 0644]
tests/unittest/scripts/valid/pass-gpu.json [new file with mode: 0644]
tests/unittest/scripts/valid/pass-memory.json [new file with mode: 0644]

index 207e64b..2942b63 100644 (file)
@@ -516,6 +516,35 @@ TEST(PassParserTest, pass_parser_get_resource_config_invalid) {
        EXPECT_NE(ret, 0);
 }
 
+TEST(PassParserTest, pass_parser_get_each_resource_config_valid) {
+       struct pass pass;
+       const char path_json[] = "./scripts/valid/pass.json";
+       unsigned int i;
+
+       int ret = pass_parser_get_resource_config(&pass, path_json);
+       ASSERT_EQ(ret, 0);
+
+       for (i = 0; i < pass.num_resources; i++) {
+               struct pass_resource *res = &pass.res[i];
+
+               ret = pass_parser_get_each_resource_config(res,
+                                       res->config_data.path_conf_file);
+               EXPECT_EQ(ret, 0);
+               if (ret < 0)
+                       goto err;
+       }
+
+       for (i = 0; i < pass.num_resources; i++)
+               pass_parser_put_each_resource_config(&pass.res[i]);
+       pass_parser_put_resource_config(&pass);
+
+       return;
+err:
+       for (i--; i >= 0; i--)
+               pass_parser_put_each_resource_config(&pass.res[i]);
+       pass_parser_put_resource_config(&pass);
+}
+
 int main(int argc, char *argv[])
 {
        try {
diff --git a/tests/unittest/scripts/valid/pass-battery.json b/tests/unittest/scripts/valid/pass-battery.json
new file mode 100644 (file)
index 0000000..b698d6c
--- /dev/null
@@ -0,0 +1,51 @@
+{
+       "support"                       : true,
+       "init_level"                    : 0,
+       "level_list"                    :
+       [
+               {
+                       "level"                         : 0,
+                       "battery,charging_status"       : 0,    // POWER_SUPPLY_STATUS_UNKNOWN
+                       "battery_charging_currnt_uA"    : 2048000
+               }, {
+                       "level"                         : 1,
+                       "battery,charging_status"       : 0,    // POWER_SUPPLY_STATUS_UNKNOWN
+                       "battery,charging_currnt_uA"    : 1024000
+               }, {
+                       "level"                         : 2,
+                       "battery,charging_status"       : 3,    // POWER_SUPPLY_STATUS_NOT_CHARGING
+                       "battery,charging_currnt_uA"    : 1024000
+               }
+       ],
+
+       "pmqos_support"                 :false,
+
+       "thermal_support"               : true,
+       "thermal_timer_interval_ms"     : 5000,
+       "thermal_scenario_list":
+       [
+               {
+                       "name"                  : "Release",
+                       "temperature"           : { "start": 0, "end": 45, "threshold": 42},
+                       "timer_interval_ms"     : 5000,
+                       "target_level"          : 0
+               }, {
+                       "name"                  : "Warning",
+                       "temperature"           : { "start": 45, "end": 50, "threshold": 47},
+                       "timer_interval_ms"     : 3000,
+                       "target_level"          : 1
+               }, {
+                       "name"                  : "LimitAction",
+                       "temperature"           : { "start": 50, "end": 55, "threshold": 52},
+                       "timer_interval_ms"     : 1000,
+                       "target_level"          : 2
+               }, {
+                       "name"                  : "Shutdown",
+                       "temperature"           : { "start": 55, "end": 100 },
+                       "timer_interval_ms"     : 1000,
+                       "target_level"          : 2
+               }
+       ],
+
+       "cpuhp_support"                 : false
+}
diff --git a/tests/unittest/scripts/valid/pass-bus0.json b/tests/unittest/scripts/valid/pass-bus0.json
new file mode 100644 (file)
index 0000000..1c13eff
--- /dev/null
@@ -0,0 +1,46 @@
+{
+       "support"                       : true,
+       "init_level"                    : 0,
+       "level_list"                    :
+       [
+               {
+                       "level"                         : 0,
+                       "dvfs,minimum_frequency_khz"    : 138000000,
+                       "dvfs,maximum_frequency_khz"    : 413000000
+               }, {
+                       "level"                         : 1,
+                       "dvfs,minimum_frequency_khz"    : 138000000,
+                       "dvfs,maximum_frequency_khz"    : 138000000
+               }, {
+                       "level"                         : 2,
+                       "dvfs,minimum_frequency_khz"    : 138000000,
+                       "dvfs,maximum_frequency_khz"    : 275000000
+               }, {
+                       "level"                         : 3,
+                       "dvfs,minimum_frequency_khz"    : 413000000,
+                       "dvfs,maximum_frequency_khz"    : 413000000
+               }
+       ],
+
+       "pmqos_support"                 : true,
+       "pmqos_scenario_list":
+       [
+               {
+                       "name"          : "AppLaunch",
+                       "target_level"  : 3
+               }, {
+                       "name"          : "UltraPowerSaving",
+                       "target_level"  : 1
+               }, {
+                       "name"          : "Doze",
+                       "target_level"  : 2
+               }, {
+                       "name"          : "Performance",
+                       "target_level"  : 3
+               }
+       ],
+
+       "thermal_support"               : false,
+
+       "cpuhp_support"                 : false
+}
diff --git a/tests/unittest/scripts/valid/pass-bus1.json b/tests/unittest/scripts/valid/pass-bus1.json
new file mode 100644 (file)
index 0000000..8be2420
--- /dev/null
@@ -0,0 +1,50 @@
+{
+       "support"                       : true,
+       "init_level"                    : 0,
+       "level_list"                    :
+       [
+               {
+                       "level"                         : 0,
+                       "dvfs,minimum_frequency_khz"    : 200000000,
+                       "dvfs,maximum_frequency_khz"    : 600000000
+               }, {
+                       "level"                         : 1,
+                       "dvfs,minimum_frequency_khz"    : 200000000,
+                       "dvfs,maximum_frequency_khz"    : 200000000
+               }, {
+                       "level"                         : 2,
+                       "dvfs,minimum_frequency_khz"    : 200000000,
+                       "dvfs,maximum_frequency_khz"    : 400000000
+               }, {
+                       "level"                         : 3,
+                       "dvfs,minimum_frequency_khz"    : 400000000,
+                       "dvfs,maximum_frequency_khz"    : 400000000
+               }, {
+                       "level"                         : 4,
+                       "dvfs,minimum_frequency_khz"    : 600000000,
+                       "dvfs,maximum_frequency_khz"    : 600000000
+               }
+       ],
+
+       "pmqos_support"                 : true,
+       "pmqos_scenario_list":
+       [
+               {
+                       "name"          : "AppLaunch",
+                       "target_level"  : 3
+               }, {
+                       "name"          : "UltraPowerSaving",
+                       "target_level"  : 1
+               }, {
+                       "name"          : "Doze",
+                       "target_level"  : 2
+               }, {
+                       "name"          : "Performance",
+                       "target_level"  : 4
+               }
+       ],
+
+       "thermal_support"               : false,
+
+       "cpuhp_support"                 : false
+}
diff --git a/tests/unittest/scripts/valid/pass-cpu0.json b/tests/unittest/scripts/valid/pass-cpu0.json
new file mode 100644 (file)
index 0000000..c921eb0
--- /dev/null
@@ -0,0 +1,64 @@
+{
+       "support"                       : true,
+       "init_level"                    : 0,
+       "level_list"                    :
+       [
+               {
+                       "level"                         : 0,
+                       "dvfs,minimum_frequency_khz"    : 600000,
+                       "dvfs,maximum_frequency_khz"    : 1500000
+               }, {
+                       "level"                         : 1,
+                       "dvfs,minimum_frequency_khz"    : 1500000,
+                       "dvfs,maximum_frequency_khz"    : 1500000
+               }, {
+                       "level"                         : 2,
+                       "dvfs,minimum_frequency_khz"    : 600000,
+                       "dvfs,maximum_frequency_khz"    : 600000
+               }
+       ],
+
+       "pmqos_support"                 : true,
+       "pmqos_scenario_list":
+       [
+               {
+                       "name"          : "AppLaunch",
+                       "target_level"  : 1
+               }, {
+                       "name"          : "UltraPowerSaving",
+                       "target_level"  : 2
+               }, {
+                       "name"          : "Performance",
+                       "target_level"  : 1
+               }
+       ],
+
+       "thermal_support"               : true,
+       "thermal_timer_interval_ms"     : 5000,
+       "thermal_scenario_list":
+       [
+               {
+                       "name"                  : "Release",
+                       "temperature"           : { "start": 0, "end": 75, "threshold": 72},
+                       "timer_interval_ms"     : 5000,
+                       "target_level"          : 0
+               }, {
+                       "name"                  : "Warning",
+                       "temperature"           : { "start": 75, "end": 80, "threshold": 77 },
+                       "timer_interval_ms"     : 3000,
+                       "target_level"          : 0
+               }, {
+                       "name"                  : "LimitAction",
+                       "temperature"           : { "start": 80, "end": 85, "threshold": 82 },
+                       "timer_interval_ms"     : 1000,
+                       "target_level"          : 2
+               }, {
+                       "name"                  : "Shutdown",
+                       "temperature"           : { "start": 85, "end": 100 },
+                       "timer_interval_ms"     : 1000,
+                       "target_level"          : 2
+               }
+       ],
+
+       "cpuhp_support"                 : false
+}
diff --git a/tests/unittest/scripts/valid/pass-cpu4.json b/tests/unittest/scripts/valid/pass-cpu4.json
new file mode 100644 (file)
index 0000000..c921eb0
--- /dev/null
@@ -0,0 +1,64 @@
+{
+       "support"                       : true,
+       "init_level"                    : 0,
+       "level_list"                    :
+       [
+               {
+                       "level"                         : 0,
+                       "dvfs,minimum_frequency_khz"    : 600000,
+                       "dvfs,maximum_frequency_khz"    : 1500000
+               }, {
+                       "level"                         : 1,
+                       "dvfs,minimum_frequency_khz"    : 1500000,
+                       "dvfs,maximum_frequency_khz"    : 1500000
+               }, {
+                       "level"                         : 2,
+                       "dvfs,minimum_frequency_khz"    : 600000,
+                       "dvfs,maximum_frequency_khz"    : 600000
+               }
+       ],
+
+       "pmqos_support"                 : true,
+       "pmqos_scenario_list":
+       [
+               {
+                       "name"          : "AppLaunch",
+                       "target_level"  : 1
+               }, {
+                       "name"          : "UltraPowerSaving",
+                       "target_level"  : 2
+               }, {
+                       "name"          : "Performance",
+                       "target_level"  : 1
+               }
+       ],
+
+       "thermal_support"               : true,
+       "thermal_timer_interval_ms"     : 5000,
+       "thermal_scenario_list":
+       [
+               {
+                       "name"                  : "Release",
+                       "temperature"           : { "start": 0, "end": 75, "threshold": 72},
+                       "timer_interval_ms"     : 5000,
+                       "target_level"          : 0
+               }, {
+                       "name"                  : "Warning",
+                       "temperature"           : { "start": 75, "end": 80, "threshold": 77 },
+                       "timer_interval_ms"     : 3000,
+                       "target_level"          : 0
+               }, {
+                       "name"                  : "LimitAction",
+                       "temperature"           : { "start": 80, "end": 85, "threshold": 82 },
+                       "timer_interval_ms"     : 1000,
+                       "target_level"          : 2
+               }, {
+                       "name"                  : "Shutdown",
+                       "temperature"           : { "start": 85, "end": 100 },
+                       "timer_interval_ms"     : 1000,
+                       "target_level"          : 2
+               }
+       ],
+
+       "cpuhp_support"                 : false
+}
diff --git a/tests/unittest/scripts/valid/pass-gpu.json b/tests/unittest/scripts/valid/pass-gpu.json
new file mode 100644 (file)
index 0000000..044d8cc
--- /dev/null
@@ -0,0 +1,79 @@
+{
+       "support"                       : true,
+       "init_level"                    : 0,
+       "level_list"                    :
+       [
+               {
+                       "level"                         : 0,
+                       "dvfs,minimum_frequency_khz"    : 100000000,
+                       "dvfs,maximum_frequency_khz"    : 800000000
+               }, {
+                       "level"                         : 1,
+                       "dvfs,minimum_frequency_khz"    : 100000000,
+                       "dvfs,maximum_frequency_khz"    : 200000000
+               }, {
+                       "level"                         : 2,
+                       "dvfs,minimum_frequency_khz"    : 600000000,
+                       "dvfs,maximum_frequency_khz"    : 80000000
+               }, {
+                       "level"                         : 3,
+                       "dvfs,minimum_frequency_khz"    : 100000000,
+                       "dvfs,maximum_frequency_khz"    : 400000000
+               }, {
+                       "level"                         : 4,
+                       "dvfs,minimum_frequency_khz"    : 100000000,
+                       "dvfs,maximum_frequency_khz"    : 600000000
+               }, {
+                       "level"                         : 5,
+                       "dvfs,minimum_frequency_khz"    : 800000000,
+                       "dvfs,maximum_frequency_khz"    : 800000000
+               }
+       ],
+
+       "pmqos_support"                 : true,
+       "pmqos_scenario_list":
+       [
+               {
+                       "name"          : "AppLaunch",
+                       "target_level"  : 2
+               }, {
+                       "name"          : "UltraPowerSaving",
+                       "target_level"  : 1
+               }, {
+                       "name"          : "Doze",
+                       "target_level"  : 3
+               }, {
+                       "name"          : "Performance",
+                       "target_level"  : 2
+               }
+       ],
+
+       "thermal_support"               : true,
+       "thermal_timer_interval_ms"     : 5000,
+       "thermal_scenario_list":
+       [
+               {
+                       "name"                  : "Release",
+                       "temperature"           : { "start": 0, "end": 75, "threshold": 72},
+                       "timer_interval_ms"     : 5000,
+                       "target_level"          : 0
+               }, {
+                       "name"                  : "Warning",
+                       "temperature"           : { "start": 75, "end": 85, "threshold": 77 },
+                       "timer_interval_ms"     : 3000,
+                       "target_level"          : 0
+               }, {
+                       "name"                  : "LimitAction",
+                       "temperature"           : { "start": 85, "end": 95, "threshold": 87 },
+                       "timer_interval_ms"     : 1000,
+                       "target_level"          : 4
+               }, {
+                       "name"                  : "Shutdown",
+                       "temperature"           : { "start": 95, "end": 100 },
+                       "timer_interval_ms"     : 1000,
+                       "target_level"          : 3
+               }
+       ],
+
+       "cpuhp_support"                 : false
+}
diff --git a/tests/unittest/scripts/valid/pass-memory.json b/tests/unittest/scripts/valid/pass-memory.json
new file mode 100644 (file)
index 0000000..4099313
--- /dev/null
@@ -0,0 +1,33 @@
+{
+       "support"               : true,
+       "init_level"            : 0,
+       "level_list"            :
+       [
+               {
+                       "level"                         : 0,
+                       "memory,fault_around_bytes"     : 4096
+               }, {
+                       "level"                         : 1,
+                       "memory,fault_around_bytes"     : 65536
+               }
+       ],
+
+       "pmqos_support"         : true,
+       "pmqos_scenario_list"   :
+       [
+               {
+                       "name"          : "AppLaunch",
+                       "target_level"  : 0
+               }, {
+                       "name"          : "UltraPowerSaving",
+                       "target_level"  : 0
+               }, {
+                       "name"          : "Performance",
+                       "target_level"  : 1
+               }
+       ],
+
+       "thermal_support"       : false,
+
+       "cpuhp_support"         : false
+}