#!/bin/sh

# Copyright (C) 2004 Simon Josefsson.
#
# This file is part of Autobuild.
#
# Autobuild is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# Autobuild is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Autobuild; see the file COPYING.  If not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.

TMPDIR="tmp.$$"
srcdir=${srcdir:-.}

LOG=$srcdir/examples/libidn.txt

if mkdir $TMPDIR; then
    :
else
    echo mkdir $TMPDIR failed
    exit 1
fi

expect="autobuild,project=libidn,revision=0.5.0,mode=default,hosttype=i686-pc-linux-gnu,buildtype=i686-pc-linux-gnu,hostname=unknown,timestamp=unknown,status=ok,log.txt"
filename=`$srcdir/autobuild -o $TMPDIR $LOG`
err=$?

if test "$err" != "0"; then
    echo Running autobuild failed: $err
    rmdir $TMPDIR
    exit 1
fi

if test "$filename" != "$TMPDIR/$expect"; then
    echo File name mismatch
    echo Expected: $expect
    echo Got: $filename
    rm -f $filename
    rmdir $TMPDIR
    exit 1
fi

if cmp $filename $LOG; then
    :
else
    echo File comparison failed
    rm -f $filename
    rmdir $TMPDIR
    exit 1
fi

rm -f $filename
rmdir $TMPDIR
exit 0
