* [Buildroot] [PATCH] utils/test-pkg: add check that show-info is proper json
@ 2021-02-07 21:21 Yann E. MORIN
2022-01-10 7:54 ` Arnout Vandecappelle
0 siblings, 1 reply; 2+ messages in thread
From: Yann E. MORIN @ 2021-02-07 21:21 UTC (permalink / raw)
To: buildroot
JSON parser are usually rather strict when parsing their input. Both
jq and the python json module choke on non-conformant inputs.
Commit e4c284e6b9 (package/pkg-utils: escape \ in generated legal-info)
fixed the \-escaping case, but we want to ensure that we do not have
other data that would be improperly encoded.
To more easily catch issues, also run show-info and send its output
through jq, to try and validate the output.
Reported-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
utils/test-pkg | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/utils/test-pkg b/utils/test-pkg
index a317d8c17a..5e00b589b8 100755
--- a/utils/test-pkg
+++ b/utils/test-pkg
@@ -13,7 +13,7 @@ do_clean() {
main() {
local o O opts
local cfg dir pkg random toolchains_csv toolchain all number mode
- local ret nb nb_skip nb_fail nb_legal nb_tc build_dir keep
+ local ret nb nb_skip nb_fail nb_legal nb_show nb_tc build_dir keep
local -a toolchains
local pkg_br_name
@@ -122,6 +122,7 @@ main() {
nb_skip=0
nb_fail=0
nb_legal=0
+ nb_show=0
for toolchainconfig in "${toolchains[@]}"; do
: $((nb++))
toolchain="$(basename "${toolchainconfig}" .config)"
@@ -133,11 +134,12 @@ main() {
(1) : $((nb_skip++)); printf "SKIPPED\n";;
(2) : $((nb_fail++)); printf "FAILED\n";;
(3) : $((nb_legal++)); printf "FAILED\n";;
+ (4) : $((nb_show++)); printf "FAILED\n";;
esac
done
- printf "%d builds, %d skipped, %d build failed, %d legal-info failed\n" \
- ${nb} ${nb_skip} ${nb_fail} ${nb_legal}
+ printf "%d builds, %d skipped, %d build failed, %d legal-info failed, %d show-info failed\n" \
+ ${nb} ${nb_skip} ${nb_fail} ${nb_legal} ${nb_show}
return $((nb_fail + nb_legal))
}
@@ -183,6 +185,20 @@ build_one() {
return 3
fi
+ # Validate that we generate proper json as show-info
+ { tput smso; printf '>>> Running show-info\n'; tput rmso; } >> "${dir}/logfile" 2> /dev/null;
+ JQ="$(which jq)"
+ if [ -z "${JQ}" ]; then
+ make O="${dir}" host-jq >> "${dir}/logfile" 2>&1
+ JQ="${dir}/host/bin/jq"
+ fi
+ if ! make O="${dir}" "${pkg:+${pkg}-}show-info" > "${dir}/info.json" 2>> "${dir}/logfile"; then
+ return 4
+ fi
+ if ! "${JQ}" . < "${dir}/info.json" >> "${dir}/logfile" 2>&1; then
+ return 4
+ fi
+
# If we get here, the build was successful. Clean up the build/host
# directories to save disk space, unless 'keep' was set.
if [ ${keep} -ne 1 ]; then
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Buildroot] [PATCH] utils/test-pkg: add check that show-info is proper json
2021-02-07 21:21 [Buildroot] [PATCH] utils/test-pkg: add check that show-info is proper json Yann E. MORIN
@ 2022-01-10 7:54 ` Arnout Vandecappelle
0 siblings, 0 replies; 2+ messages in thread
From: Arnout Vandecappelle @ 2022-01-10 7:54 UTC (permalink / raw)
To: Yann E. MORIN, buildroot
On 07/02/2021 22:21, Yann E. MORIN wrote:
> JSON parser are usually rather strict when parsing their input. Both
> jq and the python json module choke on non-conformant inputs.
>
> Commit e4c284e6b9 (package/pkg-utils: escape \ in generated legal-info)
> fixed the \-escaping case, but we want to ensure that we do not have
> other data that would be improperly encoded.
>
> To more easily catch issues, also run show-info and send its output
> through jq, to try and validate the output.
>
> Reported-by: Peter Korsgaard <peter@korsgaard.com>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Applied to master, thanks.
The same thing should be added to the autobuilder tests as well.
Regards,
Arnout
> ---
> utils/test-pkg | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/utils/test-pkg b/utils/test-pkg
> index a317d8c17a..5e00b589b8 100755
> --- a/utils/test-pkg
> +++ b/utils/test-pkg
> @@ -13,7 +13,7 @@ do_clean() {
> main() {
> local o O opts
> local cfg dir pkg random toolchains_csv toolchain all number mode
> - local ret nb nb_skip nb_fail nb_legal nb_tc build_dir keep
> + local ret nb nb_skip nb_fail nb_legal nb_show nb_tc build_dir keep
> local -a toolchains
> local pkg_br_name
>
> @@ -122,6 +122,7 @@ main() {
> nb_skip=0
> nb_fail=0
> nb_legal=0
> + nb_show=0
> for toolchainconfig in "${toolchains[@]}"; do
> : $((nb++))
> toolchain="$(basename "${toolchainconfig}" .config)"
> @@ -133,11 +134,12 @@ main() {
> (1) : $((nb_skip++)); printf "SKIPPED\n";;
> (2) : $((nb_fail++)); printf "FAILED\n";;
> (3) : $((nb_legal++)); printf "FAILED\n";;
> + (4) : $((nb_show++)); printf "FAILED\n";;
> esac
> done
>
> - printf "%d builds, %d skipped, %d build failed, %d legal-info failed\n" \
> - ${nb} ${nb_skip} ${nb_fail} ${nb_legal}
> + printf "%d builds, %d skipped, %d build failed, %d legal-info failed, %d show-info failed\n" \
> + ${nb} ${nb_skip} ${nb_fail} ${nb_legal} ${nb_show}
>
> return $((nb_fail + nb_legal))
> }
> @@ -183,6 +185,20 @@ build_one() {
> return 3
> fi
>
> + # Validate that we generate proper json as show-info
> + { tput smso; printf '>>> Running show-info\n'; tput rmso; } >> "${dir}/logfile" 2> /dev/null;
> + JQ="$(which jq)"
> + if [ -z "${JQ}" ]; then
> + make O="${dir}" host-jq >> "${dir}/logfile" 2>&1
> + JQ="${dir}/host/bin/jq"
> + fi
> + if ! make O="${dir}" "${pkg:+${pkg}-}show-info" > "${dir}/info.json" 2>> "${dir}/logfile"; then
> + return 4
> + fi
> + if ! "${JQ}" . < "${dir}/info.json" >> "${dir}/logfile" 2>&1; then
> + return 4
> + fi
> +
> # If we get here, the build was successful. Clean up the build/host
> # directories to save disk space, unless 'keep' was set.
> if [ ${keep} -ne 1 ]; then
>
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-10 7:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-07 21:21 [Buildroot] [PATCH] utils/test-pkg: add check that show-info is proper json Yann E. MORIN
2022-01-10 7:54 ` Arnout Vandecappelle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.