Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: add u-boot related functions to sh-test-lib #471

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions automated/lib/sh-test-lib
Original file line number Diff line number Diff line change
Expand Up @@ -766,3 +766,39 @@ check_config() {
check_return "config_value_${c}"
done
}

# this function allows to use u-boot variables in
# linux shell. It gets the value of variable using
# UBOOT_VAR_TOOL. This should be set to fw_printenv
# or a tool with a similar function
uboot_variable_value() {
# shellcheck disable=SC2039
local var="$1"
result=$("${UBOOT_VAR_TOOL}" "${var}")
if [ -n "${result}" ]; then
echo "${result#*=}"
else
echo ""
fi
}

# this function compares values of 2 arguments
# it reports pass if the arguments are identical
compare_test_value() {
# shellcheck disable=SC2039
local test_name="$1"
# shellcheck disable=SC2039
local expected_value="$2"
# shellcheck disable=SC2039
local tested_value="$3"

echo "Testing: #${test_name}#"
echo "Expected: #${expected_value}#"
echo "Actual: #${tested_value}#"

if [ "${expected_value}" = "${tested_value}" ]; then
report_pass "${test_name}"
else
report_fail "${test_name}"
fi
}
Loading