1#!/bin/sh 2#-*-sh-*- 3 4# 5# Copyright © 2012-2019 Inria. All rights reserved. 6# Copyright © 2010-2014 Cisco Systems, Inc. All rights reserved. 7# Copyright © 2011 Université Bordeaux 8# See COPYING in top-level directory. 9# 10 11HWLOC_top_builddir="@HWLOC_top_builddir@" 12lstopo="$HWLOC_top_builddir/utils/lstopo/lstopo-no-graphics" 13gather="$HWLOC_top_builddir/utils/hwloc/hwloc-gather-topology" 14 15# make sure we use default numeric formats 16LANG=C 17LC_ALL=C 18export LANG LC_ALL 19 20# This test can quite long on large server, allow to skip it 21if test "x$HWLOC_TEST_GATHER_TOPOLOGY" = x0; then 22 exit 77 23fi 24 25# Ensure we're running on linux. If not, then just exit with status 26# code 77 (the GNU standard for a skipped test) 27 28case `uname -a` in 29*[Ll]inux*) good=1 ;; 30*) 31 echo "Not running on linux; skipped" 32 exit 77 ;; 33esac 34 35error() 36{ 37 echo $@ 2>&1 38} 39 40if [ ! -x "$lstopo" ] 41then 42 error "Could not find executable file \`$lstopo'." 43 exit 1 44fi 45if [ ! -x "$gather" ] 46then 47 error "Could not find executable script \`$gather'." 48 exit 1 49fi 50 51tmpdir=`mktemp -d` 52 53# make sure other components don't report things that won't be exported in the tarball 54export HWLOC_COMPONENTS=linux,stop 55# use "//" so that we gather from root but thissystem gets disabled since it's not "/". 56# therefore we only gather things that can be gathered from the tarball. 57# (if we disabled thissystem explicitly without changing fsroot, Linux would automatically disable itself). 58export HWLOC_FSROOT=// 59 60echo "Saving current system topology to XML..." 61if ! "$lstopo" --no-io "$tmpdir/save1.xml" ; then 62 error "Failed" 63 exit 1 64fi 65 66echo "Saving current system topology to a tarball..." 67if ! "$gather" "$tmpdir/save" ; then 68 error "Failed" 69 exit 1 70fi 71# we'll ignore save.xml generated by hwloc-gather-topology 72# and just our own xmls generated with the right lstopo options 73 74echo "Extracting tarball..." 75if ! ( cd "$tmpdir" && tar xfj save.tar.bz2 ) ; then 76 error "Failed" 77 exit 1 78fi 79export HWLOC_FSROOT="$tmpdir/save" 80 81rm -f "$tmpdir/save/proc/hwloc-nofile-info" 82 83echo "Saving tarball topology to XML..." 84if ! "$lstopo" --no-io "$tmpdir/save2.xml" ; then 85 error "Failed" 86 exit 1 87fi 88 89echo "Comparing XML outputs..." 90( cd $tmpdir && @DIFF@ @HWLOC_DIFF_U@ @HWLOC_DIFF_W@ save1.xml save2.xml ) 91result=$? 92 93rm -rf "$tmpdir" 94 95exit $result 96