#!/bin/sh # Every reader and both libraries, over every document, into $OUT/read/. # # What each produces: # # read/ssp-{d,g}/.txt the .ssp readers' summary # read/db-{d,g}/.txt the .ocda.db readers' summary # read/dump-{d,g}/.ssp the library's dump, loaded from the .ssp # read/dump-{d,g}/.db the same, loaded from the .ocda.db # # The dumps are the interesting ones. All four of them should be identical: # the two serialisations say the same thing, and the two languages read it the # same way. `diff` says so, and the summary at the end counts it. set -e . "$(dirname "$0")/config.sh" : "${ARTEFACTS:?set ARTEFACTS to a directory of .ssp and .ocda.db files}" mkdir -p "$OUT/read" for d in ssp-d ssp-g db-d db-g dump-d dump-g; do mkdir -p "$OUT/read/$d"; done list=$(find "$ARTEFACTS" -name '*.ssp' | sort) [ -n "$LIMIT" ] && list=$(echo "$list" | head -n "$LIMIT") n=0; same=0 for ssp in $list; do stem=$(basename "$ssp" .ssp); lang=${stem##*.}; uid=${stem%.*} db=$(find "$ARTEFACTS" -name "$uid.ocda.db" | head -1) n=$((n+1)) sh "$(dirname "$0")/one.sh" ssp-d "$ssp" > "$OUT/read/ssp-d/$stem.txt" sh "$(dirname "$0")/one.sh" ssp-g "$ssp" > "$OUT/read/ssp-g/$stem.txt" sh "$(dirname "$0")/one.sh" dump-d "$ssp" > "$OUT/read/dump-d/$stem.ssp" sh "$(dirname "$0")/one.sh" dump-g "$ssp" > "$OUT/read/dump-g/$stem.ssp" [ -n "$db" ] || continue sh "$(dirname "$0")/one.sh" db-d "$db" > "$OUT/read/db-d/$stem.txt" sh "$(dirname "$0")/one.sh" db-g "$db" > "$OUT/read/db-g/$stem.txt" sh "$(dirname "$0")/one.sh" dump-d "$db" "$lang" > "$OUT/read/dump-d/$stem.db" sh "$(dirname "$0")/one.sh" dump-g "$db" "$lang" > "$OUT/read/dump-g/$stem.db" # the four-way agreement, which is the library's whole claim if cmp -s "$OUT/read/dump-d/$stem.ssp" "$OUT/read/dump-d/$stem.db" \ && cmp -s "$OUT/read/dump-g/$stem.ssp" "$OUT/read/dump-g/$stem.db" \ && cmp -s "$OUT/read/dump-d/$stem.ssp" "$OUT/read/dump-g/$stem.ssp" then same=$((same+1)) else echo "DUMPS DIFFER $stem" fi done echo echo "documents read: $n" echo "all four dumps identical $same"