/tests/xml/test-topology.sh.in

https://bitbucket.org/carter/hwloc-mirror · Autoconf · 104 lines · 71 code · 21 blank · 12 comment · 14 complexity · 3c9a982e2e48f6a92e291b367380fe87 MD5 · raw file

  1. #!/bin/sh
  2. #-*-sh-*-
  3. #
  4. # Copyright © 2009 CNRS
  5. # Copyright © 2009-2013 Inria. All rights reserved.
  6. # Copyright © 2009-2012 Université Bordeaux 1
  7. # Copyright © 2010 Cisco Systems, Inc. All rights reserved.
  8. # See COPYING in top-level directory.
  9. #
  10. # Check the conformance of `lstopo' for all the XML
  11. # hierarchies available here. Return true on success.
  12. HWLOC_top_builddir="@HWLOC_top_builddir@"
  13. HWLOC_top_srcdir="@HWLOC_top_srcdir@"
  14. lstopo="@HWLOC_top_builddir@/utils/lstopo-no-graphics"
  15. HWLOC_PLUGINS_PATH=${HWLOC_top_builddir}/src
  16. export HWLOC_PLUGINS_PATH
  17. if test x@HWLOC_XML_LOCALIZED@ = x1; then
  18. # make sure we use default numeric formats
  19. LANG=C
  20. LC_ALL=C
  21. export LANG LC_ALL
  22. fi
  23. error()
  24. {
  25. echo $@ 2>&1
  26. }
  27. if [ ! -x "$lstopo" ]
  28. then
  29. error "Could not find executable file \`$lstopo'."
  30. exit 1
  31. fi
  32. : ${TMPDIR=/tmp}
  33. {
  34. tmp=`
  35. (umask 077 && mktemp -d "$TMPDIR/fooXXXXXX") 2>/dev/null
  36. ` &&
  37. test -n "$tmp" && test -d "$tmp"
  38. } || {
  39. tmp=$TMPDIR/foo$$-$RANDOM
  40. (umask 077 && mkdir "$tmp")
  41. } || exit $?
  42. file="$tmp/lstopo_xml.output.xml"
  43. set -e
  44. dirname=`dirname $1`
  45. basename=`basename $1 .xml`
  46. source="${dirname}/${basename}.xml"
  47. source_file="${dirname}/${basename}.source"
  48. test -f "$source_file" && source="${dirname}/"`cat $source_file`
  49. options_file="${dirname}/${basename}.options"
  50. test -f "$options_file" && opts=`cat $options_file`
  51. test -f "${dirname}/${basename}.env" && . "${dirname}/${basename}.env"
  52. do_run()
  53. {
  54. echo $lstopo --if xml --input "$source" --of xml "$file" $opts
  55. $lstopo --if xml --input "$source" --of xml "$file" $opts
  56. if [ "$HWLOC_UPDATE_TEST_TOPOLOGY_OUTPUT" != 1 ]
  57. then
  58. diff @HWLOC_DIFF_U@ @HWLOC_DIFF_W@ "${dirname}/${basename}.xml" "$file"
  59. else
  60. if ! diff "${dirname}/${basename}.xml" "$file" >/dev/null
  61. then
  62. cp -f "$file" "${dirname}/${basename}.xml"
  63. echo "Updated ${basename}.xml"
  64. fi
  65. fi
  66. if [ -n "@XMLLINT@" ]
  67. then
  68. cp -f "$HWLOC_top_srcdir"/src/hwloc.dtd "$tmp/"
  69. ( cd $tmp ; @XMLLINT@ --valid lstopo_xml.output.xml ) > /dev/null
  70. fi
  71. rm "$file"
  72. }
  73. export HWLOC_NO_LIBXML_IMPORT
  74. export HWLOC_NO_LIBXML_EXPORT
  75. echo "Importing with default parser and reexporting with minimalistic implementation..."
  76. HWLOC_NO_LIBXML_IMPORT=0
  77. HWLOC_NO_LIBXML_EXPORT=1
  78. do_run "$dirname" "$basename"
  79. echo "Importing with minimalistic parser and reexporting with default implementation..."
  80. HWLOC_NO_LIBXML_IMPORT=1
  81. HWLOC_NO_LIBXML_EXPORT=0
  82. do_run "$dirname" "$basename"
  83. rm -rf "$tmp"