From e80722fd89200fdde90ed51ac383dfa8a308a64c Mon Sep 17 00:00:00 2001 From: Alexandru Costache Date: Tue, 22 Oct 2024 16:38:12 +0300 Subject: [PATCH] tests/os: Add Jetson Orin device-specific fan and power mode smoke tests These tests are the same for all public Orin device types and validate that the power mode and the fan profile can be changed by writing directly to the config.json file in the boot partition of an un-managed OS. Signed-off-by: Alexandru Costache Change-type: patch --- tests/suites/os/suite.js | 6 ++ .../jetson-agx-orin-devkit-64gb/index.js | 74 +++++++++++++++++++ .../jetson-agx-orin-devkit/index.js | 74 +++++++++++++++++++ .../jetson-orin-nano-devkit-nvme/index.js | 74 +++++++++++++++++++ .../jetson-orin-nano-seeed-j3010/index.js | 74 +++++++++++++++++++ .../jetson-orin-nx-seeed-j4012/index.js | 74 +++++++++++++++++++ .../jetson-orin-nx-xavier-nx-devkit/index.js | 74 +++++++++++++++++++ .../orin-assets/power-fan-helpers.sh | 68 +++++++++++++++++ 8 files changed, 518 insertions(+) create mode 100644 tests/suites/os/tests/device-specific-tests/jetson-agx-orin-devkit-64gb/index.js create mode 100644 tests/suites/os/tests/device-specific-tests/jetson-agx-orin-devkit/index.js create mode 100644 tests/suites/os/tests/device-specific-tests/jetson-orin-nano-devkit-nvme/index.js create mode 100644 tests/suites/os/tests/device-specific-tests/jetson-orin-nano-seeed-j3010/index.js create mode 100644 tests/suites/os/tests/device-specific-tests/jetson-orin-nx-seeed-j4012/index.js create mode 100644 tests/suites/os/tests/device-specific-tests/jetson-orin-nx-xavier-nx-devkit/index.js create mode 100755 tests/suites/os/tests/device-specific-tests/orin-assets/power-fan-helpers.sh diff --git a/tests/suites/os/suite.js b/tests/suites/os/suite.js index b3d95aa241..9091a29a76 100644 --- a/tests/suites/os/suite.js +++ b/tests/suites/os/suite.js @@ -445,6 +445,12 @@ module.exports = { './tests/secureboot', './tests/device-specific-tests/beaglebone-black', './tests/device-specific-tests/243390-rpi3', + './tests/device-specific-tests/jetson-agx-orin-devkit', + './tests/device-specific-tests/jetson-agx-orin-devkit-64gb', + './tests/device-specific-tests/jetson-orin-nano-devkit-nvme', + './tests/device-specific-tests/jetson-orin-nano-seeed-j3010', + './tests/device-specific-tests/jetson-orin-nx-seeed-j4012', + './tests/device-specific-tests/jetson-orin-nx-xavier-nx-devkit', './tests/overlap_test/', './tests/fingerprint', './tests/fsck', diff --git a/tests/suites/os/tests/device-specific-tests/jetson-agx-orin-devkit-64gb/index.js b/tests/suites/os/tests/device-specific-tests/jetson-agx-orin-devkit-64gb/index.js new file mode 100644 index 0000000000..b248fa9bd5 --- /dev/null +++ b/tests/suites/os/tests/device-specific-tests/jetson-agx-orin-devkit-64gb/index.js @@ -0,0 +1,74 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const fs = require('fs'); + +module.exports = { + deviceType: { + type: 'object', + required: ['slug'], + properties: { + slug: { + type: 'string', + const: 'jetson-agx-orin-devkit-64gb', + }, + }, + }, + title: 'jetson-agx-orin-devkit-64gb - power mode and fan profile tests', + run: async function(test) { + const testHelpers = fs + .readFileSync(`${__dirname}/../orin-assets/power-fan-helpers.sh`) + .toString(); + + let output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} test_fan_profile`, + this.link, + ); + + test.is( + output.includes('passed'), + true, + 'Fan profile test passed', + ); + + output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} set_power_mode`, + this.link, + ); + + test.is( + output.includes('set'), + true, + 'Power mode was set', + ); + + await this.worker.rebootDut(this.link); + + await this.utils.waitUntil( + async () => { + output = await this.context.get().worker.executeCommandInHostOS(`${testHelpers} test_power_mode`, this.link); + return output.includes('passed'); + }, + true, + 10, + 5 * 1000 + ); + + test.is(output.includes('passed'), true, 'Power mode test passed'); + }, +}; diff --git a/tests/suites/os/tests/device-specific-tests/jetson-agx-orin-devkit/index.js b/tests/suites/os/tests/device-specific-tests/jetson-agx-orin-devkit/index.js new file mode 100644 index 0000000000..8c73fd3273 --- /dev/null +++ b/tests/suites/os/tests/device-specific-tests/jetson-agx-orin-devkit/index.js @@ -0,0 +1,74 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const fs = require('fs'); + +module.exports = { + deviceType: { + type: 'object', + required: ['slug'], + properties: { + slug: { + type: 'string', + const: 'jetson-agx-orin-devkit', + }, + }, + }, + title: 'jetson-agx-orin-devkit - power mode and fan profile tests', + run: async function(test) { + const testHelpers = fs + .readFileSync(`${__dirname}/../orin-assets/power-fan-helpers.sh`) + .toString(); + + let output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} test_fan_profile`, + this.link, + ); + + test.is( + output.includes('passed'), + true, + 'Fan profile test passed', + ); + + output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} set_power_mode`, + this.link, + ); + + test.is( + output.includes('set'), + true, + 'Power mode was set', + ); + + await this.worker.rebootDut(this.link); + + await this.utils.waitUntil( + async () => { + output = await this.context.get().worker.executeCommandInHostOS(`${testHelpers} test_power_mode`, this.link); + return output.includes('passed'); + }, + true, + 10, + 5 * 1000 + ); + + test.is(output.includes('passed'), true, 'Power mode test passed'); + }, +}; diff --git a/tests/suites/os/tests/device-specific-tests/jetson-orin-nano-devkit-nvme/index.js b/tests/suites/os/tests/device-specific-tests/jetson-orin-nano-devkit-nvme/index.js new file mode 100644 index 0000000000..47f098a323 --- /dev/null +++ b/tests/suites/os/tests/device-specific-tests/jetson-orin-nano-devkit-nvme/index.js @@ -0,0 +1,74 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const fs = require('fs'); + +module.exports = { + deviceType: { + type: 'object', + required: ['slug'], + properties: { + slug: { + type: 'string', + const: 'jetson-orin-nano-devkit-nvme', + }, + }, + }, + title: 'jetson-orin-nano-devkit-nvme - power mode and fan profile tests', + run: async function(test) { + const testHelpers = fs + .readFileSync(`${__dirname}/../orin-assets/power-fan-helpers.sh`) + .toString(); + + let output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} test_fan_profile`, + this.link, + ); + + test.is( + output.includes('passed'), + true, + 'Fan profile test passed', + ); + + output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} set_power_mode`, + this.link, + ); + + test.is( + output.includes('set'), + true, + 'Power mode was set', + ); + + await this.worker.rebootDut(this.link); + + await this.utils.waitUntil( + async () => { + output = await this.context.get().worker.executeCommandInHostOS(`${testHelpers} test_power_mode`, this.link); + return output.includes('passed'); + }, + true, + 10, + 5 * 1000 + ); + + test.is(output.includes('passed'), true, 'Power mode test passed'); + }, +}; diff --git a/tests/suites/os/tests/device-specific-tests/jetson-orin-nano-seeed-j3010/index.js b/tests/suites/os/tests/device-specific-tests/jetson-orin-nano-seeed-j3010/index.js new file mode 100644 index 0000000000..348e7877d0 --- /dev/null +++ b/tests/suites/os/tests/device-specific-tests/jetson-orin-nano-seeed-j3010/index.js @@ -0,0 +1,74 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const fs = require('fs'); + +module.exports = { + deviceType: { + type: 'object', + required: ['slug'], + properties: { + slug: { + type: 'string', + const: 'jetson-orin-nano-seeed-j3010', + }, + }, + }, + title: 'jetson-orin-nano-seeed-j3010 - power mode and fan profile tests', + run: async function(test) { + const testHelpers = fs + .readFileSync(`${__dirname}/../orin-assets/power-fan-helpers.sh`) + .toString(); + + let output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} test_fan_profile`, + this.link, + ); + + test.is( + output.includes('passed'), + true, + 'Fan profile test passed', + ); + + output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} set_power_mode`, + this.link, + ); + + test.is( + output.includes('set'), + true, + 'Power mode was set', + ); + + await this.worker.rebootDut(this.link); + + await this.utils.waitUntil( + async () => { + output = await this.context.get().worker.executeCommandInHostOS(`${testHelpers} test_power_mode`, this.link); + return output.includes('passed'); + }, + true, + 10, + 5 * 1000 + ); + + test.is(output.includes('passed'), true, 'Power mode test passed'); + }, +}; diff --git a/tests/suites/os/tests/device-specific-tests/jetson-orin-nx-seeed-j4012/index.js b/tests/suites/os/tests/device-specific-tests/jetson-orin-nx-seeed-j4012/index.js new file mode 100644 index 0000000000..6b0b4fd680 --- /dev/null +++ b/tests/suites/os/tests/device-specific-tests/jetson-orin-nx-seeed-j4012/index.js @@ -0,0 +1,74 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const fs = require('fs'); + +module.exports = { + deviceType: { + type: 'object', + required: ['slug'], + properties: { + slug: { + type: 'string', + const: 'jetson-orin-nx-seeed-j4012', + }, + }, + }, + title: 'jetson-orin-nx-seeed-j4012 - power mode and fan profile tests', + run: async function(test) { + const testHelpers = fs + .readFileSync(`${__dirname}/../orin-assets/power-fan-helpers.sh`) + .toString(); + + let output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} test_fan_profile`, + this.link, + ); + + test.is( + output.includes('passed'), + true, + 'Fan profile test passed', + ); + + output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} set_power_mode`, + this.link, + ); + + test.is( + output.includes('set'), + true, + 'Power mode was set', + ); + + await this.worker.rebootDut(this.link); + + await this.utils.waitUntil( + async () => { + output = await this.context.get().worker.executeCommandInHostOS(`${testHelpers} test_power_mode`, this.link); + return output.includes('passed'); + }, + true, + 10, + 5 * 1000 + ); + + test.is(output.includes('passed'), true, 'Power mode test passed'); + }, +}; diff --git a/tests/suites/os/tests/device-specific-tests/jetson-orin-nx-xavier-nx-devkit/index.js b/tests/suites/os/tests/device-specific-tests/jetson-orin-nx-xavier-nx-devkit/index.js new file mode 100644 index 0000000000..4670c20645 --- /dev/null +++ b/tests/suites/os/tests/device-specific-tests/jetson-orin-nx-xavier-nx-devkit/index.js @@ -0,0 +1,74 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const fs = require('fs'); + +module.exports = { + deviceType: { + type: 'object', + required: ['slug'], + properties: { + slug: { + type: 'string', + const: 'jetson-orin-nx-xavier-nx-devkit', + }, + }, + }, + title: 'jetson-orin-nx-xavier-nx-devkit - power mode and fan profile tests', + run: async function(test) { + const testHelpers = fs + .readFileSync(`${__dirname}/../orin-assets/power-fan-helpers.sh`) + .toString(); + + let output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} test_fan_profile`, + this.link, + ); + + test.is( + output.includes('passed'), + true, + 'Fan profile test passed', + ); + + output = await this.context + .get() + .worker.executeCommandInHostOS( + `${testHelpers} set_power_mode`, + this.link, + ); + + test.is( + output.includes('set'), + true, + 'Power mode was set', + ); + + await this.worker.rebootDut(this.link); + + await this.utils.waitUntil( + async () => { + output = await this.context.get().worker.executeCommandInHostOS(`${testHelpers} test_power_mode`, this.link); + return output.includes('passed'); + }, + true, + 10, + 5 * 1000 + ); + + test.is(output.includes('passed'), true, 'Power mode test passed'); + }, +}; diff --git a/tests/suites/os/tests/device-specific-tests/orin-assets/power-fan-helpers.sh b/tests/suites/os/tests/device-specific-tests/orin-assets/power-fan-helpers.sh new file mode 100755 index 0000000000..5d3739a142 --- /dev/null +++ b/tests/suites/os/tests/device-specific-tests/orin-assets/power-fan-helpers.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +TARGET_POWER_MODE="0" +CONFIG_JSON="/mnt/boot/config.json" + +target_fan_profile="quiet" + +get_power_mode_index() { + applied_power_mode=$(/usr/sbin/nvpmodel -q) + if [[ "$applied_power_mode" == null ]] || [[ -z "$applied_power_mode" ]]; then + echo "failed" + else + power_mode_index=$(echo "${applied_power_mode}" | sed -n 2p) + echo "$power_mode_index" + fi + +} + +get_fan_profile() { + running_profile=$(/usr/sbin/nvfancontrol -q | grep FAN_PROFILE | cut -d ":" -f3) + if [[ "$running_profile" == null ]] || [[ -z "$running_profile" ]]; then + echo "failed" + else + echo "$running_profile" + fi +} + +set_power_mode() { + tmp=$(mktemp) + jq --arg TARGET_POWER_MODE $TARGET_POWER_MODE '.os.power.mode |= $TARGET_POWER_MODE' $CONFIG_JSON > ${tmp} + mv ${tmp} ${CONFIG_JSON} + + added_mode=$(jq -c -M -e '.os.power.mode' $CONFIG_JSON) + if [[ "$added_mode" == "\"0\"" ]]; then + echo "set" + fi +} + +set_fan_profile() { + tmp=$(mktemp) + jq --arg target_fan_profile $target_fan_profile '.os.fan.profile |= $target_fan_profile' $CONFIG_JSON > ${tmp} + mv ${tmp} ${CONFIG_JSON} +} + +test_fan_profile() { + current_fan_profile=$(get_fan_profile) + if [[ "$current_fan_profile" == "$target_fan_profile" ]]; then + target_fan_profile="cool" + fi + + set_fan_profile + sleep 5 + applied_fan_profile=$(get_fan_profile) + if [[ "$applied_fan_profile" == "$target_fan_profile" ]]; then + echo "passed" + else + echo "failed" + fi +} + +test_power_mode() { + current_power_mode=$(get_power_mode_index) + if [[ "$current_power_mode" == "$TARGET_POWER_MODE" ]]; then + echo "passed" + else + echo "failed" + fi +}