Skip to content

Commit 144cfa6

Browse files
Merge pull request #80 from thejpster/update-test-script
Updates test.sh
2 parents fec3e63 + 8b0b6c8 commit 144cfa6

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

tests.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ rustup target add armv7r-none-eabihf
88
rustup target add armv7a-none-eabi
99
rustup component add rust-src
1010

11+
# Set this to 1 to exit on the first error
12+
EXIT_FAST=0
13+
1114
FAILURE=0
1215

1316
fail() {
1417
echo "***************************************************"
1518
echo "test.sh MISMATCH: Binary $1 for target $2 mismatched"
1619
echo "***************************************************"
1720
FAILURE=1
21+
if [ $EXIT_FAST == "1" ]; then
22+
exit 1
23+
fi
1824
}
1925

2026
mkdir -p ./target
@@ -29,52 +35,65 @@ my_diff() {
2935
# output
3036
# - Fix the CRLF line endings in the files on disk, because git adds them to
3137
# text files.
32-
diff <(cat $file_a | tr -d '\r') <(cat $file_b | sed 's~\\\\~/~g')
38+
if [ ! -f $1 ]; then
39+
echo "File $1 is missing?!"
40+
return 1
41+
elif [ ! -f $1 ]; then
42+
echo "File $2 is missing?!"
43+
return 1
44+
else
45+
diff <(cat $file_a | tr -d '\r') <(cat $file_b | sed 's~\\\\~/~g')
46+
fi
3347
}
3448

3549
# armv7r-none-eabi tests
50+
cargo build ${versatile_ab_cargo} --target=armv7r-none-eabi || exit 1
3651
for bin_path in $(ls examples/versatileab/src/bin/*.rs); do
3752
filename=${bin_path##*/}
3853
binary=${filename%.rs}
39-
cargo run ${versatile_ab_cargo} --target=armv7r-none-eabi --bin $binary | tee ./target/$binary-armv7r-none-eabi.out
54+
cargo run ${versatile_ab_cargo} --target=armv7r-none-eabi --bin $binary > ./target/$binary-armv7r-none-eabi.out
4055
my_diff ./examples/versatileab/reference/$binary-armv7r-none-eabi.out ./target/$binary-armv7r-none-eabi.out || fail $binary "armv7r-none-eabi"
4156
done
4257

4358
# armv7r-none-eabihf tests
59+
cargo build ${versatile_ab_cargo} --target=armv7r-none-eabihf || exit 1
4460
for bin_path in $(ls examples/versatileab/src/bin/*.rs); do
4561
filename=${bin_path##*/}
4662
binary=${filename%.rs}
47-
cargo run ${versatile_ab_cargo} --target=armv7r-none-eabihf --bin $binary | tee ./target/$binary-armv7r-none-eabihf.out
63+
cargo run ${versatile_ab_cargo} --target=armv7r-none-eabihf --bin $binary > ./target/$binary-armv7r-none-eabihf.out
4864
my_diff ./examples/versatileab/reference/$binary-armv7r-none-eabihf.out ./target/$binary-armv7r-none-eabihf.out || fail $binary "armv7r-none-eabihf"
4965
done
5066

5167
# armv7a-none-eabi tests
68+
cargo build ${versatile_ab_cargo} --target=armv7a-none-eabi || exit 1
5269
for bin_path in $(ls examples/versatileab/src/bin/*.rs); do
5370
filename=${bin_path##*/}
5471
binary=${filename%.rs}
55-
cargo run ${versatile_ab_cargo} --target=armv7a-none-eabi --bin $binary | tee ./target/$binary-armv7a-none-eabi.out
72+
cargo run ${versatile_ab_cargo} --target=armv7a-none-eabi --bin $binary > ./target/$binary-armv7a-none-eabi.out
5673
my_diff ./examples/versatileab/reference/$binary-armv7a-none-eabi.out ./target/$binary-armv7a-none-eabi.out || fail $binary "armv7a-none-eabi"
5774
done
5875

5976
# armv7a-none-eabihf tests
77+
RUSTC_BOOTSTRAP=1 cargo build ${versatile_ab_cargo} --target=armv7a-none-eabihf || exit 1
6078
for bin_path in $(ls examples/versatileab/src/bin/*.rs); do
6179
filename=${bin_path##*/}
6280
binary=${filename%.rs}
63-
RUSTC_BOOTSTRAP=1 cargo run ${versatile_ab_cargo} --target=armv7a-none-eabihf --bin $binary | tee ./target/$binary-armv7a-none-eabihf.out
81+
RUSTC_BOOTSTRAP=1 cargo run ${versatile_ab_cargo} --target=armv7a-none-eabihf --bin $binary > ./target/$binary-armv7a-none-eabihf.out
6482
my_diff ./examples/versatileab/reference/$binary-armv7a-none-eabihf.out ./target/$binary-armv7a-none-eabihf.out || fail $binary "armv7a-none-eabihf"
6583
done
6684

6785
# These tests only run on QEMU 9 or higher.
6886
# Ubuntu 24.04 supplies QEMU 8, which doesn't support the machine we have configured for this target
87+
RUSTC_BOOTSTRAP=1 cargo build ${mps3_an536_cargo} --target=armv8r-none-eabihf --features=gic || exit 1
6988
if qemu-system-arm --version | grep "version \(9\|10\)"; then
7089
# armv8r-none-eabihf tests
7190
for bin_path in $(ls examples/mps3-an536/src/bin/*.rs); do
7291
filename=${bin_path##*/}
7392
binary=${filename%.rs}
74-
RUSTC_BOOTSTRAP=1 cargo run ${mps3_an536_cargo} --target=armv8r-none-eabihf --bin $binary --features=gic -Zbuild-std=core | tee ./target/$binary-armv8r-none-eabihf.out
93+
RUSTC_BOOTSTRAP=1 cargo run ${mps3_an536_cargo} --target=armv8r-none-eabihf --bin $binary --features=gic > ./target/$binary-armv8r-none-eabihf.out
7594
my_diff ./examples/mps3-an536/reference/$binary-armv8r-none-eabihf.out ./target/$binary-armv8r-none-eabihf.out || fail $binary "armv8r-none-eabihf"
7695
done
77-
RUSTC_BOOTSTRAP=1 cargo run ${mps3_an536_cargo} --target=armv8r-none-eabihf --bin smp_test --features=gic -Zbuild-std=core -- -smp 2 | tee ./target/smp_test-armv8r-none-eabihf_smp2.out
96+
RUSTC_BOOTSTRAP=1 cargo run ${mps3_an536_cargo} --target=armv8r-none-eabihf --bin smp_test --features=gic -- -smp 2 > ./target/smp_test-armv8r-none-eabihf_smp2.out
7897
my_diff ./examples/mps3-an536/reference/smp_test-armv8r-none-eabihf_smp2.out ./target/smp_test-armv8r-none-eabihf_smp2.out || fail smp_test "armv8r-none-eabihf"
7998
fi
8099

0 commit comments

Comments
 (0)