#!/bin/sh
#-*-sh-*-

#
# Copyright © 2009-2012 Inria.  All rights reserved.
# Copyright © 2009, 2011 Université Bordeaux 1
# See COPYING in top-level directory.
#

abs_top_builddir="@abs_top_builddir@"
assembler="$abs_top_builddir/utils/hwloc-assembler"
abs_top_srcdir="@abs_top_srcdir@"

HWLOC_PLUGINS_PATH=${abs_top_builddir}/src
export HWLOC_PLUGINS_PATH

if test x@HWLOC_XML_LOCALIZED@ = x1; then
  # make sure we use default numeric formats
  LANG=C
  LC_ALL=C
  export LANG LC_ALL
fi

: ${TMPDIR=/tmp}
{
  tmp=`
    (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
  ` &&
  test -n "$tmp" && test -d "$tmp"
} || {
  tmp=$TMPDIR/foo$$-$RANDOM
  (umask 077 && mkdir "$tmp")
} || exit $?
file="$tmp/test-hwloc-assembler.output"

set -e

$assembler $file \
	--name input1 $abs_top_srcdir/utils/test-hwloc-assembler.input1 \
	--name input2 $abs_top_srcdir/utils/test-hwloc-assembler.input2 \
	--name input1again $abs_top_srcdir/utils/test-hwloc-assembler.input1
diff @HWLOC_DIFF_U@ $abs_top_srcdir/utils/test-hwloc-assembler.output "$file"
rm -rf "$tmp"
