From 862c42e63737d2f8b5553da64d12969dbd15246d Mon Sep 17 00:00:00 2001 From: Matej Kafka Date: Fri, 23 Jul 2021 04:13:36 +0200 Subject: [PATCH] per_process_pp: Add tests for imx8_per_process freq validation, update test config --- test/0210-config_validation.t | 133 ++++++++++++++++++++++ test/meson.build | 1 + test_config/per_process_power_policy.yaml | 28 +++-- 3 files changed, 150 insertions(+), 12 deletions(-) create mode 100644 test/0210-config_validation.t diff --git a/test/0210-config_validation.t b/test/0210-config_validation.t new file mode 100644 index 00000000..d50af2db --- /dev/null +++ b/test/0210-config_validation.t @@ -0,0 +1,133 @@ +#!/usr/bin/env bash +. testlib +plan_tests 14 + +# set fixed log level for config tests; otherwise if user would run something +# like `SPDLOG_LEVEL=trace make test`, the output would include the logs and the tests would fail +export SPDLOG_LEVEL=warning + +test_validation_pass() { + local test_name=$1 + local cfg_in=$2 + + echo "======== NEXT TEST =======================" >&2 + demos-sched -d -C "$cfg_in" >&2 + is $? 0 "$1" +} + +test_validation_fail() { + local test_name=$1 + local cfg_in=$2 + local error_like_expected=$3 + + local exit_code + local demos_output # `local` must be separate, otherwise it overwrites the exit code from DEmOS + echo "======== NEXT TEST =======================" >&2 + demos_output=$(demos-sched -d -C "$cfg_in" 2>&1) + exit_code=$? + echo "$demos_output" >&2 + is $exit_code 1 "$1 - DEmOS should exit with code 1" + like "$demos_output" "$error_like_expected" "$test_name - error output matches" +} + +test_validation_fail "unknown partition" "{ + windows: [{length: 1, cpu: 0, sc_partition: NON_EXISTENT}], + partitions: [], +}" "unknown partition 'NON_EXISTENT'" + +test_validation_fail "overlapping CPU sets inside window" "{ + windows: [{length: 1, slices: [ + {cpu: 0, sc_partition: SC1}, + {cpu: 0, sc_partition: SC2}, + ]}], + partitions: [ + {name: SC1, processes: {cmd: echo, budget: 1}}, + {name: SC2, processes: {cmd: echo, budget: 1}}, + ], +}" "overlapping CPU sets" + +test_validation_fail "unfeasible per-process freq combination - A53" "{ + windows: [ + {length: 1, slices: [ + {cpu: 0, sc_partition: SC1}, + {cpu: 1, sc_partition: SC2},]} + ], + partitions: [ + {name: SC1, processes: [{cmd: echo, budget: 1, _a53_freq: 1}]}, + {name: SC2, processes: [{cmd: echo, budget: 1, _a53_freq: 0}]}, + ], +}" "window #0, between SC partitions on CPU cluster '0-3'." + +test_validation_fail "unfeasible per-process freq combination - A72" "{ + windows: [ + {length: 1, slices: [ + {cpu: 4, sc_partition: SC1}, + {cpu: 5, sc_partition: SC2},]} + ], + partitions: [ + {name: SC1, processes: [{cmd: echo, budget: 1, _a72_freq: 1}]}, + {name: SC2, processes: [{cmd: echo, budget: 1, _a72_freq: 0}]}, + ], +}" "window #0, between SC partitions on CPU cluster '4,5'." + +test_validation_fail "unfeasible per-process freq combination - BE" "{ + windows: [ + {length: 1, slices: [ + {cpu: 0, be_partition: BE1}, + {cpu: 1, be_partition: BE2},]} + ], + partitions: [ + {name: BE1, processes: [{cmd: echo, budget: 1, _a53_freq: 1}]}, + {name: BE2, processes: [{cmd: echo, budget: 1, _a53_freq: 0}]}, + ], +}" "window #0, between BE partitions on CPU cluster '0-3'." + +test_validation_pass "collision between SC and BE is ignored" "{ + windows: [ + {length: 1, slices: [ + {cpu: 0, sc_partition: SC1}, + {cpu: 1, be_partition: BE1},]} + ], + partitions: [ + {name: SC1, processes: [{cmd: echo, budget: 1, _a53_freq: 0}]}, + {name: BE1, processes: [{cmd: echo, budget: 1, _a53_freq: 1}]}, + ], +}" + +test_validation_pass "single partition requesting multiple freqs is feasible" "{ + windows: [ + {length: 1, slices: [{cpu: 0, sc_partition: SC1}]} + ], + partitions: [ + {name: SC1, processes: [ + {cmd: echo, budget: 1, _a53_freq: 0}, + {cmd: echo, budget: 1, _a53_freq: 1}, + ]} + ], +}" + +test_validation_pass "same frequency from multiple partitions is feasible" "{ + windows: [ + {length: 1, slices: [ + {cpu: 0, be_partition: SC1}, + {cpu: 1, be_partition: SC2}, + ]} + ], + partitions: [ + {name: SC1, processes: [{cmd: echo, budget: 1, _a53_freq: 0}]}, + {name: SC2, processes: [{cmd: echo, budget: 1, _a53_freq: 0}]}, + ], +}" + +test_validation_pass "freqs on different clusters are feasible" "{ + windows: [ + {length: 1, slices: [ + {cpu: 0, be_partition: SC1}, + {cpu: 4, be_partition: SC2}, + ]} + ], + partitions: [ + {name: SC1, processes: [{cmd: echo, budget: 1, _a53_freq: 0}]}, + {name: SC2, processes: [{cmd: echo, budget: 1, _a72_freq: 1}]}, + ], +}" \ No newline at end of file diff --git a/test/meson.build b/test/meson.build index dfd58947..a959433a 100644 --- a/test/meson.build +++ b/test/meson.build @@ -3,6 +3,7 @@ tests = ''' 0020-basic.t 0100-api.t 0200-config.t +0210-config_validation.t '''.split() foreach t: tests diff --git a/test_config/per_process_power_policy.yaml b/test_config/per_process_power_policy.yaml index 5a8d471f..2abaa594 100644 --- a/test_config/per_process_power_policy.yaml +++ b/test_config/per_process_power_policy.yaml @@ -1,23 +1,27 @@ # tests the imx8_per_process power policy +# we currently don't have a good way to test this in the automated test suite + +# in the 1st window, the policy should only switch frequencies for the A53 cluster; +# in the 2nd window, only for the A72 cluster partitions: - name: SC1 processes: - - cmd: echo proc00; sleep 3600 - budget: 1000 - _a53_freq: 0 - _a72_freq: 0 - - cmd: echo proc33; sleep 3600 - budget: 1000 + - cmd: echo proc0; sleep 3600 + budget: 500 _a53_freq: 3 - _a72_freq: 3 - - cmd: echo proc12; sleep 3600 - budget: 1000 - _a53_freq: 1 _a72_freq: 2 + - cmd: echo proc1; sleep 3600 + budget: 500 + _a53_freq: 0 + _a72_freq: 0 windows: - - length: 3000 + - length: 1500 + slices: + - cpu: 0 + sc_partition: SC1 + - length: 1500 slices: - - cpu: 0-1 + - cpu: 4 sc_partition: SC1 \ No newline at end of file