eth-statediff-compliance/scripts/compare-diffs.sh

39 lines
752 B
Bash
Raw Normal View History

#!/bin/bash
# usage: compare-diffs.sh [-d <output-dir>] <differ-A> <differ-B>
set -e
while getopts d: opt; do
case $opt in
d) output_dir="$OPTARG"
esac
done
shift $((OPTIND - 1))
A=${1:-geth}
B=${2:-plugeth}
if [[ -n "$output_dir" ]]; then
mkdir -p $output_dir
A_OUTPUT="$output_dir/A"
B_OUTPUT="$output_dir/B"
else
A_OUTPUT=$(mktemp -d -t A_XXXX)
B_OUTPUT=$(mktemp -d -t B_XXXX)
fi
./dumpdiff.$A $A_OUTPUT
./dumpdiff.$B $B_OUTPUT
tmpfile=$(mktemp)
for file in $(ls $A_OUTPUT); do
for dir in "$A_OUTPUT" "$B_OUTPUT"; do
sort -u "$dir/$file" > $tmpfile
mv $tmpfile "$dir/$file"
done
(set -x; diff "${A_OUTPUT}/$file" "${B_OUTPUT}/$file")
echo Files match: "$PLUGIN_OUTPUT/$file" "$GETH_OUTPUT/$file"
done