Skip to content

Commit 4724b29

Browse files
committed
tests/linux: add testing for THISSYSTEM_ALLOWED_RESOURCES flag
Signed-off-by: Brice Goglin <[email protected]>
1 parent cd92833 commit 4724b29

File tree

8 files changed

+242
-3
lines changed

8 files changed

+242
-3
lines changed

config/hwloc_internal.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dnl -*- Autoconf -*-
22
dnl
3-
dnl Copyright © 2010-2016 Inria. All rights reserved.
3+
dnl Copyright © 2010-2017 Inria. All rights reserved.
44
dnl Copyright © 2009, 2011 Université Bordeaux
55
dnl Copyright © 2004-2005 The Trustees of Indiana University and Indiana
66
dnl University Research and Technology
@@ -395,11 +395,13 @@ int foo(void) {
395395
hwloc_config_prefix[tests/Makefile]
396396
hwloc_config_prefix[tests/hwloc/Makefile]
397397
hwloc_config_prefix[tests/hwloc/linux/Makefile]
398+
hwloc_config_prefix[tests/hwloc/linux/allowed/Makefile]
398399
hwloc_config_prefix[tests/hwloc/linux/gather/Makefile]
399400
hwloc_config_prefix[tests/hwloc/x86/Makefile]
400401
hwloc_config_prefix[tests/hwloc/xml/Makefile]
401402
hwloc_config_prefix[tests/hwloc/ports/Makefile]
402403
hwloc_config_prefix[tests/hwloc/rename/Makefile]
404+
hwloc_config_prefix[tests/hwloc/linux/allowed/test-topology.sh]
403405
hwloc_config_prefix[tests/hwloc/linux/gather/test-gather-topology.sh]
404406
hwloc_config_prefix[tests/hwloc/linux/test-topology.sh]
405407
hwloc_config_prefix[tests/hwloc/x86/test-topology.sh]
@@ -427,6 +429,7 @@ int foo(void) {
427429
chmod +x ]hwloc_config_prefix[tests/hwloc/linux/test-topology.sh \
428430
]hwloc_config_prefix[tests/hwloc/x86/test-topology.sh \
429431
]hwloc_config_prefix[tests/hwloc/xml/test-topology.sh \
432+
]hwloc_config_prefix[tests/hwloc/linux/allowed/test-topology.sh \
430433
]hwloc_config_prefix[tests/hwloc/linux/gather/test-gather-topology.sh \
431434
]hwloc_config_prefix[tests/hwloc/wrapper.sh \
432435
]hwloc_config_prefix[utils/hwloc/hwloc-compress-dir \

tests/hwloc/linux/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright © 2009-2016 Inria. All rights reserved.
1+
# Copyright © 2009-2017 Inria. All rights reserved.
22
# Copyright © 2009-2011 Université Bordeaux
33
# Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
44
# See COPYING in top-level directory.
@@ -160,4 +160,4 @@ EXTRA_DIST = $(sysfs_outputs) $(sysfs_tarballs) $(sysfs_excludes) $(sysfs_option
160160

161161
LOG_COMPILER = $(builddir)/test-topology.sh
162162

163-
SUBDIRS = . gather
163+
SUBDIRS = . allowed gather

tests/hwloc/linux/allowed/Makefile.am

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright © 2009-2017 Inria. All rights reserved.
2+
# See COPYING in top-level directory.
3+
4+
AM_CFLAGS = $(HWLOC_CFLAGS)
5+
AM_CPPFLAGS = $(HWLOC_CPPFLAGS)
6+
AM_LDFLAGS = $(HWLOC_LDFLAGS)
7+
8+
tests_outputs = \
9+
test1.output
10+
11+
tests_synthetics = \
12+
test1.synthetic
13+
14+
tests_fsroots = \
15+
test1.fsroot.tar.bz2
16+
17+
tests_options = \
18+
test1.options
19+
20+
tests_envs =
21+
22+
if HWLOC_HAVE_OPENAT
23+
if HWLOC_HAVE_BUNZIPP
24+
TESTS = $(tests_outputs)
25+
endif HWLOC_HAVE_BUNZIPP
26+
endif HWLOC_HAVE_OPENAT
27+
28+
EXTRA_DIST = $(tests_outputs) $(tests_synthetics) $(tests_fsroots) $(tests_options) $(tests_envs)
29+
30+
LOG_COMPILER = $(builddir)/test-topology.sh
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#!@BASH@
2+
#-*-sh-*-
3+
4+
#
5+
# Copyright © 2009 CNRS
6+
# Copyright © 2009-2017 Inria. All rights reserved.
7+
# Copyright © 2009-2011 Université Bordeaux
8+
# Copyright © 2009-2014 Cisco Systems, Inc. All rights reserved.
9+
# See COPYING in top-level directory.
10+
#
11+
12+
# Check the conformance of `lstopo' for all the Linux sysfs
13+
# hierarchies available here. Return true on success.
14+
15+
HWLOC_VERSION="@HWLOC_VERSION@"
16+
HWLOC_top_srcdir="@HWLOC_top_srcdir@"
17+
HWLOC_top_builddir="@HWLOC_top_builddir@"
18+
lstopo="$HWLOC_top_builddir/utils/lstopo/lstopo-no-graphics"
19+
20+
HWLOC_PLUGINS_PATH=${HWLOC_top_builddir}/hwloc
21+
export HWLOC_PLUGINS_PATH
22+
23+
HWLOC_THISSYSTEM=1
24+
export HWLOC_THISSYSTEM
25+
26+
HWLOC_THISSYSTEM_ALLOWED_RESOURCES=1
27+
export HWLOC_THISSYSTEM_ALLOWED_RESOURCES
28+
29+
actual_output="$1"
30+
31+
# make sure we use default numeric formats (only XML outputs are dis-localized when supported)
32+
LANG=C
33+
LC_ALL=C
34+
export LANG LC_ALL
35+
36+
error()
37+
{
38+
echo $@ 2>&1
39+
}
40+
41+
# test_topology NAME TOPOLOGY-DIR
42+
#
43+
# Test the topology under TOPOLOGY-DIR. Return true on success.
44+
test_topology ()
45+
{
46+
local input="$1"
47+
local dir="$2"
48+
local expected_output="$3"
49+
local options="$4"
50+
51+
local output="`mktemp`"
52+
53+
export HWLOC_DEBUG_CHECK=1
54+
55+
opts="-v -"
56+
[ -r "$options" ] && opts=`cat $options`
57+
58+
input=$(cat $input)
59+
inputformat=synthetic
60+
61+
if ! HWLOC_FSROOT="$dir" "$lstopo" --if $inputformat -i "$input" $opts \
62+
| sed -e 's/ hwlocVersion='$HWLOC_VERSION'//' \
63+
-e 's/ ProcessName=lstopo-no-graphics//' \
64+
-e 's/ ProcessName=lt-lstopo-no-graphics//' \
65+
| grep -v "<info name=\"hwlocVersion\" value=\"$HWLOC_VERSION\"\/>" \
66+
| grep -v "<info name=\"ProcessName\" value=\"lstopo-no-graphics\"\/>" \
67+
| grep -v "<info name=\"ProcessName\" value=\"lt-lstopo-no-graphics\"\/>" \
68+
> "$output"
69+
# filtered hwlocVersion since it often changes
70+
# filtered gp_index because it depends on the insertiong order, which may depend on pciaccess version, etc
71+
then
72+
result=1
73+
else
74+
if [ "$HWLOC_UPDATE_TEST_TOPOLOGY_OUTPUT" != 1 ]
75+
then
76+
diff @HWLOC_DIFF_U@ -b "$expected_output" "$output"
77+
result=$?
78+
else
79+
if ! diff "$expected_output" "$output" >/dev/null
80+
then
81+
cp -f "$output" "$expected_output"
82+
echo "Updated $expected_output"
83+
fi
84+
result=0
85+
fi
86+
fi
87+
88+
rm "$output"
89+
90+
return $result
91+
}
92+
93+
# test_eligible TOPOLOGY-DIR
94+
#
95+
# Return true if the topology under TOPOLOGY-DIR is eligible for
96+
# testing with the current flavor.
97+
test_eligible()
98+
{
99+
local dir="$1"
100+
local output="$2"
101+
102+
[ -d "$dir" -a -f "$output" ]
103+
}
104+
105+
106+
if [ ! -x "$lstopo" ]
107+
then
108+
error "Could not find executable file \`$lstopo'."
109+
exit 1
110+
fi
111+
112+
topology="${actual_output%.output}"
113+
if [ "$topology" = "$actual_output" ] ;
114+
then
115+
error "Input file \`$1' should end with .output"
116+
exit 1
117+
fi
118+
119+
actual_options="$topology".options
120+
121+
actual_input="$topology".synthetic
122+
123+
# if there's a .source file, use the tarball name it contains instead of $topology
124+
if [ -f "$topology".source ] ; then
125+
actual_fsroot="$HWLOC_top_srcdir"/tests/hwloc/linux/allowed/`cat "$topology".fsroot.source`
126+
else
127+
actual_fsroot="$topology".fsroot.tar.bz2
128+
fi
129+
130+
# if there's a .env file, source it
131+
if [ -f "$topology".env ] ; then
132+
source "$topology".env
133+
fi
134+
135+
result=1
136+
137+
dir="`mktemp -d`"
138+
139+
if ! ( bunzip2 -c "$actual_fsroot" | ( cd "$dir" && tar xf - $tar_options ) )
140+
then
141+
error "failed to extract topology \`$topology'"
142+
else
143+
actual_dir="`echo "$dir"/*`"
144+
145+
if test_eligible "$actual_dir" "$actual_output"
146+
then
147+
test_count="`expr $test_count + 1`"
148+
149+
test_topology "$actual_input" "$actual_dir" "$actual_output" "$actual_options"
150+
result=$?
151+
else
152+
# Skip this test.
153+
result=77
154+
fi
155+
fi
156+
157+
rm -rf "$dir"
158+
159+
exit $result
359 Bytes
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-v -.xml
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE topology SYSTEM "hwloc.dtd">
3+
<topology>
4+
<object type="Machine" os_index="0" cpuset="0x0000747e" complete_cpuset="0x0000ffff" allowed_cpuset="0x0000747e" nodeset="0x00000006" complete_nodeset="0x0000000f" allowed_nodeset="0x00000006" gp_index="1">
5+
<info name="Backend" value="Synthetic"/>
6+
<info name="SyntheticDescription" value="numa:4 core:2 pu:2"/>
7+
<info name="LinuxCgroup" value="/dummy"/>
8+
<object type="NUMANode" os_index="0" cpuset="0x0000000e" complete_cpuset="0x0000000f" allowed_cpuset="0x0000000e" nodeset="0x0" complete_nodeset="0x00000001" allowed_nodeset="0x0" gp_index="8">
9+
<page_type size="4096" count="0"/>
10+
<object type="Core" os_index="0" cpuset="0x00000002" complete_cpuset="0x00000003" allowed_cpuset="0x00000002" nodeset="0x0" complete_nodeset="0x00000001" allowed_nodeset="0x0" gp_index="4">
11+
<object type="PU" os_index="1" cpuset="0x00000002" complete_cpuset="0x00000002" allowed_cpuset="0x00000002" nodeset="0x0" complete_nodeset="0x00000001" allowed_nodeset="0x0" gp_index="3"/>
12+
</object>
13+
<object type="Core" os_index="1" cpuset="0x0000000c" complete_cpuset="0x0000000c" allowed_cpuset="0x0000000c" nodeset="0x0" complete_nodeset="0x00000001" allowed_nodeset="0x0" gp_index="7">
14+
<object type="PU" os_index="2" cpuset="0x00000004" complete_cpuset="0x00000004" allowed_cpuset="0x00000004" nodeset="0x0" complete_nodeset="0x00000001" allowed_nodeset="0x0" gp_index="5"/>
15+
<object type="PU" os_index="3" cpuset="0x00000008" complete_cpuset="0x00000008" allowed_cpuset="0x00000008" nodeset="0x0" complete_nodeset="0x00000001" allowed_nodeset="0x0" gp_index="6"/>
16+
</object>
17+
</object>
18+
<object type="NUMANode" os_index="1" cpuset="0x00000070" complete_cpuset="0x000000f0" allowed_cpuset="0x00000070" nodeset="0x00000002" complete_nodeset="0x00000002" allowed_nodeset="0x00000002" gp_index="15" local_memory="1073741824">
19+
<page_type size="4096" count="262144"/>
20+
<object type="Core" os_index="2" cpuset="0x00000030" complete_cpuset="0x00000030" allowed_cpuset="0x00000030" nodeset="0x00000002" complete_nodeset="0x00000002" allowed_nodeset="0x00000002" gp_index="11">
21+
<object type="PU" os_index="4" cpuset="0x00000010" complete_cpuset="0x00000010" allowed_cpuset="0x00000010" nodeset="0x00000002" complete_nodeset="0x00000002" allowed_nodeset="0x00000002" gp_index="9"/>
22+
<object type="PU" os_index="5" cpuset="0x00000020" complete_cpuset="0x00000020" allowed_cpuset="0x00000020" nodeset="0x00000002" complete_nodeset="0x00000002" allowed_nodeset="0x00000002" gp_index="10"/>
23+
</object>
24+
<object type="Core" os_index="3" cpuset="0x00000040" complete_cpuset="0x000000c0" allowed_cpuset="0x00000040" nodeset="0x00000002" complete_nodeset="0x00000002" allowed_nodeset="0x00000002" gp_index="14">
25+
<object type="PU" os_index="6" cpuset="0x00000040" complete_cpuset="0x00000040" allowed_cpuset="0x00000040" nodeset="0x00000002" complete_nodeset="0x00000002" allowed_nodeset="0x00000002" gp_index="12"/>
26+
</object>
27+
</object>
28+
<object type="NUMANode" os_index="2" cpuset="0x00000400" complete_cpuset="0x00000f00" allowed_cpuset="0x00000400" nodeset="0x00000004" complete_nodeset="0x00000004" allowed_nodeset="0x00000004" gp_index="22" local_memory="1073741824">
29+
<page_type size="4096" count="262144"/>
30+
<object type="Core" os_index="5" cpuset="0x00000400" complete_cpuset="0x00000c00" allowed_cpuset="0x00000400" nodeset="0x00000004" complete_nodeset="0x00000004" allowed_nodeset="0x00000004" gp_index="21">
31+
<object type="PU" os_index="10" cpuset="0x00000400" complete_cpuset="0x00000400" allowed_cpuset="0x00000400" nodeset="0x00000004" complete_nodeset="0x00000004" allowed_nodeset="0x00000004" gp_index="19"/>
32+
</object>
33+
</object>
34+
<object type="NUMANode" os_index="3" cpuset="0x00007000" complete_cpuset="0x0000f000" allowed_cpuset="0x00007000" nodeset="0x0" complete_nodeset="0x00000008" allowed_nodeset="0x0" gp_index="29">
35+
<page_type size="4096" count="0"/>
36+
<object type="Core" os_index="6" cpuset="0x00003000" complete_cpuset="0x00003000" allowed_cpuset="0x00003000" nodeset="0x0" complete_nodeset="0x00000008" allowed_nodeset="0x0" gp_index="25">
37+
<object type="PU" os_index="12" cpuset="0x00001000" complete_cpuset="0x00001000" allowed_cpuset="0x00001000" nodeset="0x0" complete_nodeset="0x00000008" allowed_nodeset="0x0" gp_index="23"/>
38+
<object type="PU" os_index="13" cpuset="0x00002000" complete_cpuset="0x00002000" allowed_cpuset="0x00002000" nodeset="0x0" complete_nodeset="0x00000008" allowed_nodeset="0x0" gp_index="24"/>
39+
</object>
40+
<object type="Core" os_index="7" cpuset="0x00004000" complete_cpuset="0x0000c000" allowed_cpuset="0x00004000" nodeset="0x0" complete_nodeset="0x00000008" allowed_nodeset="0x0" gp_index="28">
41+
<object type="PU" os_index="14" cpuset="0x00004000" complete_cpuset="0x00004000" allowed_cpuset="0x00004000" nodeset="0x0" complete_nodeset="0x00000008" allowed_nodeset="0x0" gp_index="26"/>
42+
</object>
43+
</object>
44+
</object>
45+
</topology>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
numa:4 core:2 pu:2

0 commit comments

Comments
 (0)