#!/bin/bash

DIR="@abs_top_srcdir@"
BDIR="@abs_top_builddir@"
LOG="/tmp/zbar_dbus_test_$$.log"

EXPECTED="7bfb83f7d54763ddb5841f0892e79071d4bb2c70"


$BDIR/test/test_dbus -c1 -t5 >$LOG &
PID=$!

trap "rm -r $LOG" EXIT

$BDIR/zbarimg/zbarimg $DIR/examples/code-128.png 2>/dev/null >/dev/null

wait $PID

if [ ! -s $LOG ]; then
	echo "FAILED: nothing received via D-Bus"
    exit -2
fi

CK="`cat $LOG  |sha1sum |cut -d" " -f 1`"
if [ "x$CK" != "x$EXPECTED" ]; then
	echo "FAILED: $CK instead of $EXPECTED"
    exit -2
fi

echo "D-Bus PASSED."
