#!/bin/bash # Runs the two verifiers of IIS-Q-0002 and compares their tables. usage: bash run_q0002.sh [OUT_DIR] set -u HERE=$(cd "$(dirname "$0")" && pwd) OUT=${1:-$HERE/out} CC=${CC:-cc} mkdir -p "$OUT" || exit 1 echo "== versions" python3 --version "$CC" --version | head -1 echo "== 1. Python verifier" python3 -I "$HERE/verify_q0002.py" > "$OUT/verify_q0002_python.log" 2>&1 echo "exit code $?" echo "== 2. C verifier" "$CC" -O2 -std=c99 -Wall -Wextra -o "$OUT/verify_q0002" "$HERE/verify_q0002.c" || exit 1 "$OUT/verify_q0002" "$OUT/cap236_rows.txt" > "$OUT/verify_q0002_c.log" 2>&1 echo "exit code $?" echo "== 3. SHA-256 of the 236 rows written by the C verifier" if command -v sha256sum > /dev/null 2>&1; then sha256sum "$OUT/cap236_rows.txt" | cut -d' ' -f1 else shasum -a 256 "$OUT/cap236_rows.txt" | cut -d' ' -f1; fi echo "expected: 1d6a5c73bd44d4cd99e40cf97644dd4a0c37f1bd39e3f6edfc47fd9756240efe" echo "== 4. comparison of the two logs" python3 -I "$HERE/compare_q0002.py" "$OUT/verify_q0002_python.log" "$OUT/verify_q0002_c.log" echo "exit code $?"