-
Notifications
You must be signed in to change notification settings - Fork 168
/
test-topology.sh.in
138 lines (112 loc) · 3.11 KB
/
test-topology.sh.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh
#-*-sh-*-
#
# Copyright © 2009 CNRS
# Copyright © 2009-2023 Inria. All rights reserved.
# Copyright © 2009-2012 Université Bordeaux
# Copyright © 2010-2014 Cisco Systems, Inc. All rights reserved.
# See COPYING in top-level directory.
#
# Check the conformance of `lstopo' for all the XML
# hierarchies available here. Return true on success.
HWLOC_top_builddir="@HWLOC_top_builddir@"
HWLOC_top_srcdir="@HWLOC_top_srcdir@"
lstopo="$HWLOC_top_builddir/utils/lstopo/lstopo-no-graphics"
HWLOC_PLUGINS_PATH=${HWLOC_top_builddir}/hwloc/.libs
export HWLOC_PLUGINS_PATH
HWLOC_DEBUG_CHECK=1
export HWLOC_DEBUG_CHECK
HWLOC_LIBXML_CLEANUP=1
export HWLOC_LIBXML_CLEANUP
if test x@HWLOC_XML_LOCALIZED@ = x1; then
# make sure we use default numeric formats in XML outputs (non-XML outputs have to set those variables too)
LANG=C
LC_ALL=C
export LANG LC_ALL
fi
error()
{
echo $@ 2>&1
}
if [ ! -x "$lstopo" ]
then
error "Could not find executable file \`$lstopo'."
exit 1
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 $?
output="$tmp/lstopo_xml.output"
set -e
testname="$1"
dirname=`dirname $1`
basename=`basename $1 .test`
if test \! -f "$testname"; then
echo "Cannot find test file $testname"
exit 1
fi
####################################
# foo.test should contain:
# - source filename on 1st line (must be in same directory as foo.test)
# - target filename on 2nd line (must be in same directory as foo.test)
# - options on 3rd line, if any
# - environment variables to be sourced on next lines, if any
source=`sed -n 1p "$testname"`
target=`sed -n 2p "$testname"`
opts=`sed -n 3p "$testname"`
sed -n '4,$p' "$testname" > "$tmp/env"
if test \! -f "$dirname/$source"; then
echo "Cannot find source file $source from test $testname"
exit 1
fi
if test \! -f "$dirname/$target"; then
echo "Cannot find target file $target from test $testname"
exit 1
fi
if test "$target" = `basename $target .xml`".xml"; then
is_xml_target=1
opts="--of xml $opts"
else
is_xml_target=0
opts="--of console $opts"
fi
. "$tmp/env"
do_run()
{
echo $lstopo --if xml --input "$dirname/$source" "$output" $opts
$lstopo --if xml --input "$dirname/$source" "$output" $opts
if [ "$HWLOC_UPDATE_TEST_TOPOLOGY_OUTPUT" != 1 ]
then
@DIFF@ @HWLOC_DIFF_U@ @HWLOC_DIFF_W@ "$dirname/$target" "$output"
else
if ! @DIFF@ "$dirname/$target" "$output" >/dev/null
then
cp -f "$output" "$dirname/$target"
echo "Updated $target"
fi
fi
if [ -n "@XMLLINT@" -a $is_xml_target -eq 1 ]
then
cp -f "$HWLOC_top_srcdir"/hwloc/hwloc*.dtd "$tmp/"
( cd $tmp ; @XMLLINT@ --valid $output ) > /dev/null
fi
rm "$output"
}
export HWLOC_LIBXML_IMPORT
export HWLOC_LIBXML_EXPORT
echo "Importing with default parser and reexporting with minimalistic implementation..."
HWLOC_LIBXML_IMPORT=1
HWLOC_LIBXML_EXPORT=0
do_run
echo "Importing with minimalistic parser and reexporting with default implementation..."
HWLOC_LIBXML_IMPORT=0
HWLOC_LIBXML_EXPORT=1
do_run
rm -rf "$tmp"