Skip to content

Commit 6d21ad5

Browse files
committed
logging/app: make test more robust
also note that the output of `cargo run` may not match what you get locally if using a different toolchain
1 parent 27ebdad commit 6d21ad5

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

ci/script.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,35 @@ main() {
134134
# # Logging with symbols
135135
pushd logging
136136

137-
# check that the output and disassembly matches
137+
# check that the ~output~ and disassembly matches
138+
# the output won't exactly match because addresses of static variables won't
139+
# remain the same when the toolchain is updated. Instead we'll that the
140+
# printed address is contained in the output of `cargo objdump -- -t`
138141
pushd app
139-
diff dev.out \
140-
<(cargo run)
141-
diff dev.objdump \
142-
<(cargo objdump --bin app -- -t | grep '\.rodata\s*0*1\b')
143-
diff release.out \
144-
<(cargo run --release)
145-
diff release.objdump \
146-
<(cargo objdump --bin app --release -- -t | grep '\.rodata\s*0*1\b')
142+
cargo run > dev.out
143+
cargo objdump --bin app -- -t | grep '\.rodata\s*0*1\b' > dev.objdump
144+
for address in $(cat dev.out); do
145+
grep ${address#0x} dev.objdump
146+
done
147+
148+
cargo run --release > release.out
149+
cargo objdump --bin app --release -- -t | grep '\.rodata\s*0*1\b' > dev.objdump
150+
for address in $(cat release.out); do
151+
grep ${address#0x} release.objdump
152+
done
153+
154+
# sanity check the committed files
155+
git checkout dev.out
156+
git checkout dev.objdump
157+
for address in $(cat dev.out); do
158+
grep ${address#0x} dev.objdump
159+
done
160+
161+
git checkout release.out
162+
git checkout release.objdump
163+
for address in $(cat release.out); do
164+
grep ${address#0x} release.objdump
165+
done
147166
edition_check
148167
popd
149168

src/logging.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ $ qemu-system-arm \
104104
{{#include ../ci/logging/app/dev.out}}
105105
```
106106

107+
> **NOTE**: These addresses may not be the ones you get locally because
108+
> addresses of `static` variable are not guaranteed to remain the same when the
109+
> toolchain is changed (e.g. optimizations may have improved).
110+
107111
Now we have two addresses printed to the console.
108112

109113
## Decoding

0 commit comments

Comments
 (0)