#!/usr/bin/env sh # The library and its reader, over every document, into $OUT/read/. # # What each produces: # # 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 # read/read-{d,g}/.ssp ocda-read --tree, reading the .ssp # read/read-{d,g}/.db the same, reading 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 dump-d dump-g read-d read-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; read_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" 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" 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 # ocda-read: the same from either form, and the same in either language, # the first line, which names the file read, set aside sh "$(dirname "$0")/one.sh" read-d "$ssp" "$lang" --tree | tail -n +2 > "$OUT/read/read-d/$stem.ssp" sh "$(dirname "$0")/one.sh" read-g "$ssp" "$lang" --tree | tail -n +2 > "$OUT/read/read-g/$stem.ssp" sh "$(dirname "$0")/one.sh" read-d "$db" "$lang" --tree | tail -n +2 > "$OUT/read/read-d/$stem.db" sh "$(dirname "$0")/one.sh" read-g "$db" "$lang" --tree | tail -n +2 > "$OUT/read/read-g/$stem.db" if cmp -s "$OUT/read/read-d/$stem.ssp" "$OUT/read/read-d/$stem.db" \ && cmp -s "$OUT/read/read-g/$stem.ssp" "$OUT/read/read-g/$stem.db" \ && cmp -s "$OUT/read/read-d/$stem.ssp" "$OUT/read/read-g/$stem.ssp" then read_same=$((read_same+1)) else echo "OCDA-READ DIFFERS $stem" fi done echo echo "documents read: $n" echo "all four dumps identical $same" echo "ocda-read, all four identical $read_same"