Skip to content

Commit

Permalink
windows: add a test to verify that MSVC version/soname match the offi…
Browse files Browse the repository at this point in the history
…cial numbers

MSVC hardwires the VERSION numbers/strings and soname in its manually generated
*_config.h files and in the vcxproj files. Make sure they match what we have
in normal headers and VERSION files.

Only check the soname when in a release branch (ignore on master, where the
lib version is 0:0:0).

This test doesn't run automatically in make check because it requires bash
and grep supporting -P. There's no need to run it for each build on each slave
anyway. So just run it manually in the main jenkins job.

Signed-off-by: Valentin Hoyet <[email protected]>
Signed-off-by: Brice Goglin <[email protected]>
  • Loading branch information
bgoglin committed Nov 29, 2018
1 parent 991b501 commit b9c1c37
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ endif
# distribution tarball if we're building in embedded mode.
DIST_SUBDIRS = $(SUBDIRS)
if HWLOC_BUILD_STANDALONE
DIST_SUBDIRS += contrib/windows
if !BUILD_NETLOC
DIST_SUBDIRS += netloc
endif
Expand Down
3 changes: 3 additions & 0 deletions config/hwloc_internal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ int foo(void) {
hwloc_config_prefix[utils/netloc/infiniband/netloc_ib_gather_raw]
hwloc_config_prefix[contrib/systemd/Makefile]
hwloc_config_prefix[contrib/misc/Makefile]
hwloc_config_prefix[contrib/windows/Makefile]
hwloc_config_prefix[contrib/windows/test-windows-version.sh]
hwloc_config_prefix[tests/netloc/Makefile]
hwloc_config_prefix[tests/netloc/tests.sh]
)
Expand All @@ -474,6 +476,7 @@ chmod +x ]hwloc_config_prefix[tests/hwloc/linux/test-topology.sh \
]hwloc_config_prefix[utils/hwloc/test-hwloc-dump-hwdata/test-hwloc-dump-hwdata.sh \
]hwloc_config_prefix[utils/lstopo/test-lstopo.sh \
]hwloc_config_prefix[utils/netloc/infiniband/netloc_ib_gather_raw \
]hwloc_config_prefix[contrib/windows/test-windows-version.sh \
]hwloc_config_prefix[tests/netloc/tests.sh])
# These links are only needed in standalone mode. It would
Expand Down
3 changes: 3 additions & 0 deletions contrib/ci.inria.fr/job-0-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,7 @@ sed -e 's/^snapshot_version=.*/snapshot_version='$snapshot/ \
make
make distcheck

# this test requires bash and grep -P, only run it in the main job
make check -C contrib/windows

exit 0
7 changes: 7 additions & 0 deletions contrib/windows/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright © 2009-2018 Inria. All rights reserved.
# See COPYING in top-level directory.

# This Makefile doesn't run by default because it requires
# bash, and grep built with support for -P

TESTS = test-windows-version.sh
93 changes: 93 additions & 0 deletions contrib/windows/test-windows-version.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!@BASH@
#-*-sh-*-

#
# Copyright © 2018 Inria. All rights reserved.
# See COPYING in top-level directory.
#
HWLOC_top_builddir="@HWLOC_top_builddir@"
HWLOC_top_srcdir="@HWLOC_top_srcdir@"
windows_config_h="$HWLOC_top_srcdir/contrib/windows/hwloc_config.h"
config_h="$HWLOC_top_builddir/include/hwloc/autogen/config.h"
vcxproj_file="$HWLOC_top_srcdir/contrib/windows/libhwloc.vcxproj"
version_file="$HWLOC_top_srcdir/VERSION"

# get all individual version components
echo "Looking for Windows-specific version in $windows_config_h ..."
windows_major=$(grep -w HWLOC_VERSION_MAJOR $windows_config_h | grep -oP '[0-9]+')
windows_minor=$(grep -w HWLOC_VERSION_MINOR $windows_config_h | grep -oP '[0-9]+')
windows_release=$(grep -w HWLOC_VERSION_RELEASE $windows_config_h | grep -oP '[0-9]+')
windows_greek=$(grep -w HWLOC_VERSION_GREEK $windows_config_h | grep -oP '".*"' | tr -d \")
if [ -z "$windows_major" -o -z "$windows_minor" -o -z "$windows_release" ]; then
# greek is likely empty on purpose, ignore it
echo "ERROR: Failed to get Windows-specific HWLOC_VERSION_MAJOR/MINOR/RELEASE"
exit 1
fi
echo " Found major=$windows_major minor=$windows_minor release=$windows_release greek=$windows_greek"

# check that the version string matches
windows_version=$(grep -w HWLOC_VERSION $windows_config_h | grep -oP '".+"' | tr -d \")
echo " Found windows-specific HWLOC_VERSION \"$windows_version\""
expected_windows_version="$windows_major.$windows_minor.$windows_release$windows_greek"
if [ "$windows_version" != "$expected_windows_version" ]; then
echo "ERROR: Windows-specific HWLOC_VERSION \"$windows_version\" doesn't match HWLOC_VERSION_MAJOR/MINOR/RELEASE/GREEK components \"$expected_windows_version\""
exit 1
fi
echo " Windows-specific HWLOC_VERSION \"$windows_version\" matches HWLOC_VERSION_MAJOR/MINOR/RELEASE/GREEK components"

# check that it matchs the official version, without a GREEK
echo "Looking in $config_h ..."
official_major=$(grep -w HWLOC_VERSION_MAJOR $config_h | grep -oP '[0-9]+')
official_minor=$(grep -w HWLOC_VERSION_MINOR $config_h | grep -oP '[0-9]+')
official_release=$(grep -w HWLOC_VERSION_RELEASE $config_h | grep -oP '[0-9]+')
if [ -z "$official_major" -o -z "$official_minor" -o -z "$official_release" ]; then
echo "ERROR: Failed to get official HWLOC_VERSION_MAJOR/MINOR/RELEASE"
exit 1
fi
echo " Found major=$official_major minor=$official_minor release=$official_release"
official_version_nogreek="$official_major.$official_minor.$official_release"
if [ "$official_version_nogreek" != "$windows_version" ]; then
echo "ERROR: Windows-specific HWLOC_VERSION \"$windows_version\" doesn't match \"$official_version_nogreek\" without GREEK"
exit 1
fi
echo "Windows-specific HWLOC_VERSION \"$windows_version\" matches official version without greek"

echo

# get the windows soname
echo "Looking in $vcxproj_file ..."
if [ `grep '<TargetName>' $vcxproj_file | uniq -c | wc -l` != 1 ]; then
echo "ERROR: Couldn't find a single value for <TargetName> lines"
exit 1
fi
windows_lib_soname=$(grep -m1 '<TargetName>' $vcxproj_file | grep -oP '\d+')
if [ -z "$windows_lib_soname" ]; then
echo "ERROR: Failed to get the Windows-specific soname"
exit 1
fi
echo " Found Windows-specific soname $windows_lib_soname"

# get the official soname
echo "Looking in $version_file ..."
official_lib_version=$(grep -w "libhwloc_so_version" $version_file | grep -oP '\d+:\d+:\d+')
if [ -z "$official_lib_version" ]; then
echo "ERROR: Failed to get the official lib version"
exit 1
fi
echo " Found official lib version \"$official_lib_version\""

# bashisms to extract the soname from the version
IFS=':' arr=(${official_lib_version})
declare -i official_lib_soname=${arr[0]}-${arr[2]}
echo " Extracted official lib soname $official_lib_soname"

# check that sonames match only if on a release branch
if [ "$official_lib_version" != "0:0:0" ] ; then
if [ "$windows_lib_soname" != "$official_lib_soname" ]; then
echo "ERROR: Windows-specific lib soname $windows_lib_soname differs from $official_lib_soname (from \"$official_lib_version\")"
exit 1
fi
echo "Windows-specific lib soname $windows_lib_soname matches official lib soname"
else
echo "Ignoring unset lib soname"
fi

0 comments on commit b9c1c37

Please sign in to comment.