1#!/bin/sh 2#-*-sh-*- 3 4# 5# Copyright © 2012 Inria. All rights reserved. 6# Copyright © 2010 Cisco Systems, Inc. All rights reserved. 7# Copyright © 2011 Université Bordeaux 1 8# See COPYING in top-level directory. 9# 10 11abs_top_builddir="@abs_top_builddir@" 12lstopo="$abs_top_builddir/utils/lstopo-no-graphics" 13gather="$abs_top_builddir/tests/linux/hwloc-gather-topology" 14 15# make sure we use default numeric formats 16LANG=C 17LC_ALL=C 18export LANG LC_ALL 19 20# Ensure we're running on linux. If not, then just exit with status 21# code 77 (the GNU standard for a skipped test) 22 23case `uname -a` in 24*[Ll]inux*) good=1 ;; 25*) 26 echo "Not running on linux; skipped" 27 exit 77 ;; 28esac 29 30error() 31{ 32 echo $@ 2>&1 33} 34 35if [ ! -x "$lstopo" ] 36then 37 error "Could not find executable file \`$lstopo'." 38 exit 1 39fi 40if [ ! -x "$gather" ] 41then 42 error "Could not find executable script \`$gather'." 43 exit 1 44fi 45 46tmpdir=`mktemp -d` 47 48# make sure we compare things that are comparable 49# (the tarball cannot be "this system") 50export HWLOC_THISSYSTEM=0 51 52echo "Saving current system topology to XML..." 53if ! "$lstopo" "$tmpdir/save.xml" ; then 54 error "Failed" 55 exit 1 56fi 57 58echo "Saving current system topology to a tarball..." 59if ! "$gather" "$tmpdir/save" ; then 60 error "Failed" 61 exit 1 62fi 63 64echo "Extracting tarball..." 65if ! ( cd "$tmpdir" && tar xfj save.tar.bz2 ) ; then 66 error "Failed" 67 exit 1 68fi 69export HWLOC_FSROOT="$tmpdir/save" 70 71echo "Saving tarball topology to XML..." 72if ! "$lstopo" "$tmpdir/save2.xml" ; then 73 error "Failed" 74 exit 1 75fi 76 77echo "Comparing XML outputs..." 78( cd $tmpdir && diff -u save.xml save2.xml ) 79result=$? 80 81rm -rf "$tmpdir" 82 83exit $result 84