diff options
author | Chanwoo Choi <cw00.choi@samsung.com> | 2022-06-27 18:30:13 +0900 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2022-09-07 03:13:03 +0000 |
commit | 873f5cb6eb8c6c0e3c154918fe936f940b245980 (patch) | |
tree | e4f72281e271f1d51075c3f4533d4c9d1aa0aba8 | |
parent | 47bcf74f5789b3db5afc2842d1b2c08244aed7a5 (diff) | |
download | pass-873f5cb6eb8c6c0e3c154918fe936f940b245980.tar.gz pass-873f5cb6eb8c6c0e3c154918fe936f940b245980.tar.bz2 pass-873f5cb6eb8c6c0e3c154918fe936f940b245980.zip |
tests: unittest: Add pass-parser invalid test
Add pass-parser invalid unittests for each section
- Test for invalid level section
- Test for invalid pmqos section
- Test for invalid thermal section
- Test for invalid header section
- Test for invalid battery h/w resource type
- Test for invalid memory h/w resource type
Change-Id: Ibdf109751560fc130ce3d8680867c9ac81be1c56
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
-rw-r--r-- | tests/unittest/pass-unittests.cc | 43 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-battery/pass-battery.json | 51 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-battery/pass.json | 12 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-header/pass-bus0.json | 46 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-header/pass.json | 11 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-level/pass-cpu0.json | 64 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-level/pass.json | 13 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-memory/pass-memory.json | 33 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-memory/pass.json | 10 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-pmqos/pass-cpu0.json | 64 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-pmqos/pass.json | 13 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-thermal/pass-cpu.json | 64 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-thermal/pass-cpu1.json | 67 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-thermal/pass.json | 13 | ||||
-rw-r--r-- | tests/unittest/scripts/invalid-thermal/pass1.json | 13 |
15 files changed, 516 insertions, 1 deletions
diff --git a/tests/unittest/pass-unittests.cc b/tests/unittest/pass-unittests.cc index 6408468..cda27aa 100644 --- a/tests/unittest/pass-unittests.cc +++ b/tests/unittest/pass-unittests.cc @@ -526,7 +526,6 @@ TEST(PassParserTest, pass_parser_get_each_resource_config_valid) { for (i = 0; i < (int)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); @@ -539,6 +538,48 @@ TEST(PassParserTest, pass_parser_get_each_resource_config_valid) { pass_parser_put_resource_config(&pass); } +class ResourceConfigInvalid { +public: + const char *path_json; + + ResourceConfigInvalid( + const char *path_json_) : + path_json(path_json_) {} +}; + +class PassParserInvalidTest : public ::testing::TestWithParam<ResourceConfigInvalid> {}; + +INSTANTIATE_TEST_CASE_P (PassParserTest, PassParserInvalidTest, + ::testing::Values ( + ResourceConfigInvalid ("./scripts/invalid-level/pass.json"), + ResourceConfigInvalid ("./scripts/invalid-pmqos/pass.json"), + ResourceConfigInvalid ("./scripts/invalid-thermal/pass.json"), + ResourceConfigInvalid ("./scripts/invalid-thermal/pass1.json"), + ResourceConfigInvalid ("./scripts/invalid-header/pass.json"), + ResourceConfigInvalid ("./scripts/invalid-battery/pass.json"), + ResourceConfigInvalid ("./scripts/invalid-memory/pass.json") +)); + +TEST_P(PassParserInvalidTest, pass_parser_get_each_resource_config_invalid) { + auto param = GetParam(); + struct pass pass; + unsigned int i; + + int ret = pass_parser_get_resource_config(&pass, param.path_json); + EXPECT_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_NE(ret, 0); + } + + for (i = 0; i < pass.num_resources; 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/invalid-battery/pass-battery.json b/tests/unittest/scripts/invalid-battery/pass-battery.json new file mode 100644 index 0000000..01b822a --- /dev/null +++ b/tests/unittest/scripts/invalid-battery/pass-battery.json @@ -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/invalid-battery/pass.json b/tests/unittest/scripts/invalid-battery/pass.json new file mode 100644 index 0000000..4857561 --- /dev/null +++ b/tests/unittest/scripts/invalid-battery/pass.json @@ -0,0 +1,12 @@ +{ + "device_list" : + [ + { + "device_type" : "battery", + "device_name" : "battery", + "device_config_path" : "./scripts/invalid-battery/pass-battery.json", + "thermal_device_name" : "thermal_zone5", + "cooling_device_name" : null + } + ] +} diff --git a/tests/unittest/scripts/invalid-header/pass-bus0.json b/tests/unittest/scripts/invalid-header/pass-bus0.json new file mode 100644 index 0000000..bcc94fd --- /dev/null +++ b/tests/unittest/scripts/invalid-header/pass-bus0.json @@ -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/invalid-header/pass.json b/tests/unittest/scripts/invalid-header/pass.json new file mode 100644 index 0000000..1591e61 --- /dev/null +++ b/tests/unittest/scripts/invalid-header/pass.json @@ -0,0 +1,11 @@ +{ + "device_list" : + [ + { + "device_type" : "bus", + "device_name" : "devfreq0", + "device_config_path" : "./scripts/invalid-bus/pass-bus0.json", + "thermal_device_name" : null + } + ] +} diff --git a/tests/unittest/scripts/invalid-level/pass-cpu0.json b/tests/unittest/scripts/invalid-level/pass-cpu0.json new file mode 100644 index 0000000..ae42205 --- /dev/null +++ b/tests/unittest/scripts/invalid-level/pass-cpu0.json @@ -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/invalid-level/pass.json b/tests/unittest/scripts/invalid-level/pass.json new file mode 100644 index 0000000..e26f60d --- /dev/null +++ b/tests/unittest/scripts/invalid-level/pass.json @@ -0,0 +1,13 @@ +{ + "device_list" : + [ + { + "device_type" : "cpu", + "device_name" : "cpu0", + "device_config_path" : "./scripts/invalid-level/pass-cpu0.json", + "thermal_device_name" : "thermal_zone0", + "cpu,number_of_cpus" : 4, + "cpu,first_cpu" : 0 + } + ] +} diff --git a/tests/unittest/scripts/invalid-memory/pass-memory.json b/tests/unittest/scripts/invalid-memory/pass-memory.json new file mode 100644 index 0000000..1038fad --- /dev/null +++ b/tests/unittest/scripts/invalid-memory/pass-memory.json @@ -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 +} diff --git a/tests/unittest/scripts/invalid-memory/pass.json b/tests/unittest/scripts/invalid-memory/pass.json new file mode 100644 index 0000000..df8ed06 --- /dev/null +++ b/tests/unittest/scripts/invalid-memory/pass.json @@ -0,0 +1,10 @@ +{ + "device_list" : + [ + { + "device_type" : "memory", + "device_name" : "memory", + "device_config_path" : "./scripts/invalid-memory/pass-memory.json" + } + ] +} diff --git a/tests/unittest/scripts/invalid-pmqos/pass-cpu0.json b/tests/unittest/scripts/invalid-pmqos/pass-cpu0.json new file mode 100644 index 0000000..13fe285 --- /dev/null +++ b/tests/unittest/scripts/invalid-pmqos/pass-cpu0.json @@ -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/invalid-pmqos/pass.json b/tests/unittest/scripts/invalid-pmqos/pass.json new file mode 100644 index 0000000..e35f722 --- /dev/null +++ b/tests/unittest/scripts/invalid-pmqos/pass.json @@ -0,0 +1,13 @@ +{ + "device_list" : + [ + { + "device_type" : "cpu", + "device_name" : "cpu0", + "device_config_path" : "./scripts/invalid-pmqos/pass-cpu0.json", + "thermal_device_name" : "thermal_zone0", + "cpu,number_of_cpus" : 4, + "cpu,first_cpu" : 0 + } + ] +} diff --git a/tests/unittest/scripts/invalid-thermal/pass-cpu.json b/tests/unittest/scripts/invalid-thermal/pass-cpu.json new file mode 100644 index 0000000..51d546b --- /dev/null +++ b/tests/unittest/scripts/invalid-thermal/pass-cpu.json @@ -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/invalid-thermal/pass-cpu1.json b/tests/unittest/scripts/invalid-thermal/pass-cpu1.json new file mode 100644 index 0000000..1e5521f --- /dev/null +++ b/tests/unittest/scripts/invalid-thermal/pass-cpu1.json @@ -0,0 +1,67 @@ +{ + "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/invalid-thermal/pass.json b/tests/unittest/scripts/invalid-thermal/pass.json new file mode 100644 index 0000000..044b17b --- /dev/null +++ b/tests/unittest/scripts/invalid-thermal/pass.json @@ -0,0 +1,13 @@ +{ + "device_list" : + [ + { + "device_type" : "cpu", + "device_name" : "cpu0", + "device_config_path" : "./scripts/invalid-thermal/pass-cpu.json", + "thermal_device_name" : "thermal_zone0", + "cpu,number_of_cpus" : 4, + "cpu,first_cpu" : 0 + } + ] +} diff --git a/tests/unittest/scripts/invalid-thermal/pass1.json b/tests/unittest/scripts/invalid-thermal/pass1.json new file mode 100644 index 0000000..212862f --- /dev/null +++ b/tests/unittest/scripts/invalid-thermal/pass1.json @@ -0,0 +1,13 @@ +{ + "device_list" : + [ + { + "device_type" : "cpu", + "device_name" : "cpu0", + "device_config_path" : "./scripts/invalid-thermal/pass-cpu1.json", + "thermal_device_name" : "thermal_zone0", + "cpu,number_of_cpus" : 4, + "cpu,first_cpu" : 0 + } + ] +} |