Skip to content

Commit

Permalink
[#70544] [#71243] regression tests for uboot, refactor config mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
laudominik committed Jan 14, 2025
1 parent ad0a277 commit 1ba810d
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 27 deletions.
24 changes: 20 additions & 4 deletions .ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Test Static release:
- test.repl
- test2.repl

Compare repls:
.compare_repls: &compare_repls
stage: Test
image: debian:bullseye
variables:
Expand All @@ -60,8 +60,24 @@ Compare repls:
- apt -qqy install automake autoconf cmake libtool g++ coreutils policykit-1 libgtk2.0-dev uml-utilities gtk-sharp2 wget jq git curl python3 python3-pip parallel xz-utils rename &> /dev/null
- apt -qqy install mono-complete &> /dev/null
- mono --version
before_script:
- ./ci/prepare.sh
before_script:
- ./ci/prepare.sh # uses DASHBOARD_VARIANT
script:
- ./ci/test.sh
- ./ci/test.sh # uses DASHBOARD_VARIANT
- ./ci/process_test_results.sh

Compare repls uboot:
<<: *compare_repls
variables:
RENODE_VERSION: "latest"
DEBIAN_FRONTEND: "noninteractive"
GET_CUSTOM_RENODE_REVISION: ""
DASHBOARD_VARIANT: "uboot"

Compare repls zephyr:
<<: *compare_repls
variables:
RENODE_VERSION: "latest"
DEBIAN_FRONTEND: "noninteractive"
GET_CUSTOM_RENODE_REVISION: ""
DASHBOARD_VARIANT: "zephyr"
39 changes: 27 additions & 12 deletions ci/get_dashboard_replkit.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
#!/bin/bash
set -euo pipefail

GCP_SIM_BASE="https://zephyr-dashboard.renode.io/zephyr_sim"
LATEST_ZEPHYR=$(curl --fail -sS -G "$GCP_SIM_BASE"/latest)
LATEST_RENODE=$(curl --fail -sS -G "$GCP_SIM_BASE"/"$LATEST_ZEPHYR"/latest)
if [[ "$DASHBOARD_VARIANT" == "zephyr" ]]; then
GCP_SIM_BASE="https://zephyr-dashboard.renode.io/zephyr_sim"
export DEMO_NAME=hello_world
elif [[ "$DASHBOARD_VARIANT" == "uboot" ]]; then
GCP_SIM_BASE="https://u-boot-dashboard.renode.io/uboot_sim"
export DEMO_NAME=uboot
else
exit 1
fi

LATEST_SIM=$(curl --fail -sS -G "$GCP_SIM_BASE"/latest)
LATEST_RENODE=$(curl --fail -sS -G "$GCP_SIM_BASE"/"$LATEST_SIM"/latest)
wget "$GCP_SIM_BASE"/"$LATEST_SIM"/"$LATEST_RENODE"/replkit.tar.xz

wget "$GCP_SIM_BASE"/"$LATEST_ZEPHYR"/"$LATEST_RENODE"/replkit.tar.xz
mkdir replkit
tar xf replkit.tar.xz -C replkit >/dev/null
# Grab only the hello_world repls, configs and dtses

# Grab only the DEMO_NAME repls, configs and dtses
# We assume they will be the same as for other samples
rename -E 's:replkit/:dts/:' -E 's:-hello_world.dts:.dts:' replkit/*-hello_world.dts
rename -E 's:replkit/:repls/dashboard/:' -E 's:-hello_world.repl:.repl:' replkit/*-hello_world.repl
rename -E 's:replkit/:repls/dashboard/:' -E 's:-hello_world-config.json:-config.json:' replkit/*-hello_world-config.json
# Remove the leftovers (dts/repl/json from other samples)
rm replkit/*.repl
rm replkit/*.json
rm replkit/*.dts
rename -E 's:replkit/:dts/:' -E "s:-${DEMO_NAME}.dts:.dts:" replkit/*-${DEMO_NAME}.dts
rename -E 's:replkit/:repls/dashboard/:' -E "s:-${DEMO_NAME}.repl:.repl:" replkit/*-${DEMO_NAME}.repl

if ls replkit/*-"$DEMO_NAME"-config.json 1> /dev/null 2>&1; then
rename -E 's:replkit/:repls/dashboard/:' -E "s:-${DEMO_NAME}-config.json:-config.json:" replkit/*-${DEMO_NAME}-config.json
rm replkit/*.json
fi

# Grab the versions
mv replkit/*.version .

# Remove the leftovers
rm replkit/*.repl
rm replkit/*.dts

rmdir replkit 2>/dev/null || {
echo replkit had unexpected files:
ls -l replkit
Expand Down
44 changes: 33 additions & 11 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,51 @@
#!/bin/bash
set -euxo pipefail
set -exuo pipefail


# Print which dts2repl commits are being compared
OLD_COMMIT="$(<ci-output/dts2repl.version)"
echo "Dashboard repls were generated by dts2repl $OLD_COMMIT, commits since then are:"
git log --oneline --graph --color=always "$OLD_COMMIT..HEAD"

cd ci-output
# Generate repls for the boards that have downloaded dtses for comparison

(
echo "Generating repls for comparison"
cd repls/generated
# process platforms that have a system clock override in a config.json file
mkdir ../../dts-clock-override
grep -Hr override-system-clock-frequency ../../repls/dashboard/*.json | cut -d/ -f5 | cut -d- -f1 | parallel 'mv ../../dts/{}.dts ../../dts-clock-override/'
ls -1 ../../dts-clock-override | cut -d. -f1 | parallel 'dts2repl ../../dts-clock-override/{}.dts --override-system-clock-frequency=$(jq -r ".[\"override-system-clock-frequency\"]" ../dashboard/{}-config.json) --output {}.repl'
# process other platforms
ls -1 ../../dts | cut -d. -f1 | parallel 'dts2repl ../../dts/{}.dts --output {}.repl'
# merge results
mv ../../dts-clock-override/* ../../dts
rmdir ../../dts-clock-override

# shellcheck disable=SC2317
generate() {
file=$1

NAME=$(basename "$file" .dts)
CMDLINE=()
CONFIG=../dashboard/"$NAME"-config.json

# Assemble cmdline based on config
if [ -f "$CONFIG" ]; then
for key in $(jq 'keys[]' "$CONFIG" | tr -d '"'); do
value=$(jq --arg v "$key" '.[$v]' "$CONFIG" | tr -d '"')
CMDLINE+=("--$key=$value")
done
fi
echo "Generating for $NAME"
if [ ${#CMDLINE[@]} -eq 0 ]; then
dts2repl ../../dts/"$NAME".dts --output "$NAME".repl
else
echo "with custom command-line $CMDLINE"
dts2repl ../../dts/"$NAME".dts --output "$NAME".repl "${CMDLINE[@]}"
fi
}
export -f generate
parallel generate ::: $(ls ../../dts/*)
echo "All files generated"
)

# Save diffs for repls that are different
# diff returns 0 on no difference which we use to delete diff files if the
# generated repl is identical (+/- blank lines) to the dashboard one
echo "Generating diffs"

pushd repls/diffs
ls -1 ../generated | parallel 'diff -u --new-file --ignore-blank-lines "../dashboard/{}" "../generated/{}" > "{}.diff" && rm "{}.diff" || true'
popd
Expand Down

0 comments on commit 1ba810d

Please sign in to comment.