1#!/bin/sh
2#-*-sh-*-
3
4#
5# Copyright © 2009 CNRS
6# Copyright © 2009-2020 Inria.  All rights reserved.
7# Copyright © 2009 Université Bordeaux
8# Copyright © 2014 Cisco Systems, Inc.  All rights reserved.
9# See COPYING in top-level directory.
10#
11
12HWLOC_top_srcdir="@HWLOC_top_srcdir@"
13HWLOC_top_builddir="@HWLOC_top_builddir@"
14srcdir="$HWLOC_top_srcdir/utils/hwloc"
15builddir="$HWLOC_top_builddir/utils/hwloc"
16distrib="$builddir/hwloc-distrib"
17
18HWLOC_PLUGINS_PATH=${HWLOC_top_builddir}/hwloc/.libs
19export HWLOC_PLUGINS_PATH
20
21HWLOC_DEBUG_CHECK=1
22export HWLOC_DEBUG_CHECK
23
24: ${TMPDIR=/tmp}
25{
26  tmp=`
27    (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
28  ` &&
29  test -n "$tmp" && test -d "$tmp"
30} || {
31  tmp=$TMPDIR/foo$$-$RANDOM
32  (umask 077 && mkdir "$tmp")
33} || exit $?
34file="$tmp/test-hwloc-distrib.output"
35
36set -e
37(
38  echo "# 2 sets out of 2 2 2"
39  $distrib --if synthetic --input "2 2 2" 2
40  echo
41  echo "# 4 sets out of 2 2 2"
42  $distrib --if synthetic --input "2 2 2" 4
43  echo
44  echo "# 8 sets out of 2 2 2"
45  $distrib --if synthetic --input "2 2 2" 8
46  echo
47  echo "# 13 sets out of 2 2 2"
48  $distrib --if synthetic --input "2 2 2" 13
49  echo
50  echo "# 16 sets out of 2 2 2"
51  $distrib --if synthetic --input "2 2 2" 16
52  echo
53
54  echo "# 4 sets out of 3 3 3"
55  $distrib --if synthetic --input "3 3 3" 4
56  echo
57  echo "# 4 singlified sets out of 3 3 3"
58  $distrib --if synthetic --input "3 3 3" 4 --single
59  echo
60  echo "# 4 sets out of 3 3 3, reversed"
61  $distrib --if synthetic --input "3 3 3" 4 --reverse
62  echo
63  echo "# 4 singlified sets out of 3 3 3, reversed"
64  $distrib --if synthetic --input "3 3 3" 4 --reverse --single
65  echo
66
67  echo "# 2 sets out of 4 4"
68  $distrib --if synthetic --input "4 4" 2
69  echo
70  echo "# 2 singlified sets out of 4 4"
71  $distrib --if synthetic --input "4 4" 2 --single
72  echo
73  echo "# 2 singlified sets out of 4 4, reversed"
74  $distrib --if synthetic --input "4 4" 2 --reverse --single
75  echo
76  echo "# 19 sets out of 4 4"
77  $distrib --if synthetic --input "4 4 4 4" 19
78  echo
79
80  echo "# 9 sets out of 2 2 2 2"
81  $distrib --if synthetic --input "2 2 2 2" 9
82  echo
83  echo "# 9 sets out of 2 2 2 2, starting at PU level"
84  $distrib --if synthetic --input "2 2 2 2" --from pu 9
85  echo
86  echo "# 9 sets out of 2 2 2 2, stopping at Core level"
87  $distrib --if synthetic --input "2 2 2 2" --to core 9
88  echo
89) > "$file"
90@DIFF@ @HWLOC_DIFF_U@ @HWLOC_DIFF_W@ $srcdir/test-hwloc-distrib.output "$file"
91rm -rf "$tmp"
92