-
Notifications
You must be signed in to change notification settings - Fork 156
More extensive testing #45
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
Comments
Here's a script I used to smoke test svd2rust against posborne/cmsis-svd. set -ex
main() {
local url='https://github.com/posborne/cmsis-svd/archive/python-0.4.tar.gz'
local data_dir=$(mktemp -d)
curl -L $url | tar -C $data_dir --strip-components 1 -xz
local errors=()
set +ex
find $data_dir -type f -name '*.svd' -print0 | \
while IFS= read -r -d $'\0' line; do
svd2rust -i $line >/dev/null 2>&1 || \
echo $(basename $line)
done
set -ex
rm -rf $data_dir
}
main These svd2rust failed to generate code from these files:
I have yet to investigate the cause of the errors. The error rate is 71 out of 490 or about 14.49%. |
I have now classified all the 71 errors. Most of them are caused by the SVD not being valid. As per the specification all registers must have a reset value but the SVD listed above are missing reset values in some registers. |
Updated script to detect SVD files for which svd2rust does generate code without crashing but the generated code doesn't compile: set -ex
main() {
local url='https://github.com/posborne/cmsis-svd/archive/python-0.4.tar.gz'
local cargo_dir=$(mktemp -d)
local data_dir=$(mktemp -d)
curl -L $url | tar -C $data_dir --strip-components 1 -xz
cargo init --lib --name device $cargo_dir
( cd $cargo_dir && cargo add cortex-m vcell )
local errors=()
set +ex
find $data_dir -type f -name '*.svd' -print0 | \
while IFS= read -r -d $'\0' line; do
svd2rust -i $line >$cargo_dir/src/lib.rs 2>/dev/null || \
( echo "I: $(basename $line)" && continue )
cargo check --manifest-path $cargo_dir/Cargo.toml >/dev/null 2>&1 || \
echo "II: $(basename $line)"
done
set -ex
rm -rf $cargo_dir
rm -rf $data_dir
}
main The compile errors are referred to as class II errors, and the generation errors are referred to as class I errors. Here's the list of class II errors I have seen so far. (The script is still running on my machine; it's taking a while to test all the SVD files). The errors have already been classified:
(up to this point these errors are not due to svd2rust bugs)
|
Testing all the SVD files in cmsis-svd takes a few hours on my laptop so it seems very unlikely that will be able to run it as part of the CI testing of this repo. I think we should sample some files, specially those listed above that are causing trouble today, from the database and just use those in our test suite. At the very least we should pick on SVD file per microcontroller vendor. |
Also there are some new svd files in |
@pftbest thanks for the heads up. I'll re-run the test script on the diff between HEAD and v0.4.0. |
we now at least test one device per vendor in the SVD database cc #45
Done in #101 |
The ci/script.sh file is now keeping track of the SVD files that are not working due to missing feature is svd2rust. Each of those files has been classified and issues have been filed under the 'cmsis-svd' milestone. |
Once #43 lands, I think we should be ready to test generating all the peripherals that a SVD contains.
svd2rust -i $svd
would give us the full list of peripheral then we can usesvd2rust -i $svd $peripheral
for each peripheral in that list.We could even repeat this approach for several SVD files in the cmsis-svd repo. We should be careful to not overdo ourselves and end up with unreasonable test times though.
The text was updated successfully, but these errors were encountered: