1#!/bin/sh
2
3# Runs the installed *dupes* binary and the built binary and compares
4# the output for sameness. Also displays timing statistics.
5
6ERR=0
7
8# Detect installed program type (fdupes or jdupes)
9if [ -z "$ORIG_DUPE" ]
10	then ORIG_DUPE=false
11	jdupes -v 2>/dev/null >/dev/null && ORIG_DUPE=jdupes
12	fdupes -v 2>/dev/null >/dev/null && ORIG_DUPE=fdupes
13	test ! -z "$WINDIR" && "$WINDIR/jdupes.exe" -v 2>/dev/null >/dev/null && ORIG_DUPE="$WINDIR/jdupes.exe"
14fi
15
16if [ ! $ORIG_DUPE -v 2>/dev/null >/dev/null ]
17	then echo "Cannot run installed jdupes or fdupes"
18	exit 1
19fi
20
21test ! -e ./jdupes && echo "Build jdupes first, silly" && exit 1
22
23echo -n "Installed $ORIG_DUPE:"
24sync
25time $ORIG_DUPE -nq "$@" > installed_output.txt || ERR=1
26echo -en "\nBuilt jdupes:"
27sync
28time ./jdupes -nq "$@" > built_output.txt || ERR=1
29diff -Nau installed_output.txt built_output.txt
30if [ -e jdupes-standalone ]
31	then
32	echo -en "\nBuilt jdupes-standalone:"
33	sync
34	time ./jdupes-standalone -nrq "$@" > built_output.txt || ERR=1
35	diff -Nau installed_output.txt built_output.txt
36fi
37
38rm -f installed_output.txt built_output.txt
39test "$ERR" != "0" && echo "Errors were returned during execution"
40