#!/bin/bash

. ../init.sh

[[ $PORTDIR == "" ]] && PORTDIR=$(portageq envvar PORTDIR)
pushd ${PORTDIR}/metadata/cache >/dev/null || { echo SKIPPED; exit 0 ; }

if [[ $1 == -v ]] ; then
	find . -mindepth 2 -type f -printf '%P\n%f\n' | while read line ; do
		echo "TESTING $line: "
		"$b"/e "${line}"
	done
	exit 0
fi

# split the disk i/o out so both tests are CPU bound only
files=$(find . -mindepth 2 -type f -printf '%P\n%f\n')
popd >/dev/null

printf "atom_explode():"
time echo "${files}" | "$b"/e > "$b"/me || exit $?
echo

printf "portage:"
time echo "${files}" | "$s"/atom-explode.py > "$b"/py || exit $?
echo

diff -U 0 "$b"/me "$b"/py
tend $? "portage-utils vs portage atom parsing"

end
