This repository has been archived on 2026-09-16. You can view files and clone it, but cannot push or open issues or pull requests.
win-diagnostics-analysis/tools/validate-all.sh

45 lines
829 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)
usage() {
echo "Usage: $0 INPUT_DIR [--evidence-root DIR]" >&2
exit 2
}
fail() {
echo "error: $*" >&2
exit 1
}
input_dir=${1:-}
[[ -n "$input_dir" ]] || usage
shift
evidence_root=
while (($#)); do
case $1 in
--evidence-root)
(($# >= 2)) || usage
evidence_root=$2
shift 2
;;
*)
usage
;;
esac
done
count=0
while IFS= read -r -d '' input; do
arguments=()
[[ -z "$evidence_root" ]] || arguments+=(--evidence-root "$evidence_root")
"$root/tools/validate.sh" "$input" "${arguments[@]}"
((count += 1))
done < <(find "$input_dir" -type f -name '*.json' -print0 | sort -z)
((count > 0)) || fail "$input_dir: no JSON diagnostics found"
echo "Validated $count diagnostics"