aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-01-08 04:33:12 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-01-08 04:38:01 +0300
commitd13ed4ccddc2ccb94a877fbba7ad87fb0f8f6bc0 (patch)
tree3a1e8fda807d0be382165cc1d1aba9c508470461
parentTravis: prettify .travis.yml (diff)
downloadcmake-common-d13ed4ccddc2ccb94a877fbba7ad87fb0f8f6bc0.tar.gz
cmake-common-d13ed4ccddc2ccb94a877fbba7ad87fb0f8f6bc0.zip
Travis: verify executable file bitness
Diffstat (limited to '')
-rw-r--r--.ci/.gitattributes1
-rwxr-xr-x.ci/verify_arch.sh56
-rw-r--r--.travis.yml5
3 files changed, 62 insertions, 0 deletions
diff --git a/.ci/.gitattributes b/.ci/.gitattributes
new file mode 100644
index 0000000..dfdb8b7
--- /dev/null
+++ b/.ci/.gitattributes
@@ -0,0 +1 @@
+*.sh text eol=lf
diff --git a/.ci/verify_arch.sh b/.ci/verify_arch.sh
new file mode 100755
index 0000000..aafc5e8
--- /dev/null
+++ b/.ci/verify_arch.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+set -o errexit -o nounset -o pipefail
+
+script_name="$( basename -- "${BASH_SOURCE[0]}" )"
+readonly script_name
+
+elf_file_class() {
+ local path
+ for path; do
+ od --address-radix=n --skip-bytes=4 --read-bytes=1 --format=x1 -- "$path"
+ done
+}
+
+arch_to_file_class() {
+ local arch
+ for arch; do
+ case "$arch" in
+ x86)
+ echo '01'
+ ;;
+ x64)
+ echo '02'
+ ;;
+ *)
+ echo "$script_name: unsupported architecture: $arch" >&2
+ return 1
+ ;;
+ esac
+ done
+}
+
+main() {
+ if [ "$#" -ne 2 ]; then
+ echo "usage: $script_name BIN_PATH ARCH" >&2
+ return 1
+ fi
+
+ local path="$1"
+ local arch="$2"
+
+ local expected
+ expected=" $( arch_to_file_class "$arch" )"
+ local actual
+ actual="$( elf_file_class "$path" )"
+
+ if [ "$expected" = "$actual" ]; then
+ echo "$script_name: file '$path' matches architecture '$arch'"
+ else
+ echo "$script_name: file '$path' DOES NOT match architecture '$arch'"
+ echo "$script_name: expected ELF file class '$expected', actual file class is '$actual'" >&2
+ return 1
+ fi
+}
+
+main "$@"
diff --git a/.travis.yml b/.travis.yml
index 250ce85..b7ce789 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,6 +22,7 @@ jobs:
--configuration Release
-- cmake/examples/simple
- "$HOME/install/simple/bin/foo"
+ - ./.ci/verify_arch.sh "$HOME/install/simple/bin/foo" x64
- >-
./cmake/build/build.py
@@ -30,6 +31,7 @@ jobs:
-- cmake/examples/static
-D "CMAKE_TOOLCHAIN_FILE=$TRAVIS_BUILD_DIR/cmake/toolchains/gcc-x86.cmake"
- "$HOME/install/static/bin/foo"
+ - ./.ci/verify_arch.sh "$HOME/install/static/bin/foo" x86
- >-
./cmake/build/build.py
@@ -37,6 +39,7 @@ jobs:
--configuration Release
-- cmake/examples/dynamic
- LD_LIBRARY_PATH="$HOME/install/dynamic/lib" "$HOME/install/dynamic/bin/foo"
+ - ./.ci/verify_arch.sh "$HOME/install/dynamic/bin/foo" x64
- name: Boost 1.58
script:
@@ -57,6 +60,7 @@ jobs:
-D "BOOST_LIBRARYDIR=$TRAVIS_BUILD_DIR/boost_1_58_0/stage/x86/Debug/lib"
-D "CMAKE_TOOLCHAIN_FILE=$TRAVIS_BUILD_DIR/cmake/toolchains/gcc-x86.cmake"
- "$HOME/install/boost_1_58_0/bin/foo"
+ - ./.ci/verify_arch.sh "$HOME/install/boost_1_58_0/bin/foo" x86
- name: Boost 1.72
script:
@@ -80,6 +84,7 @@ jobs:
- >-
LD_LIBRARY_PATH="$TRAVIS_BUILD_DIR/boost_1_72_0/stage/x64/Release/lib"
"$HOME/install/boost_1_72_0/bin/foo"
+ - ./.ci/verify_arch.sh "$HOME/install/boost_1_72_0/bin/foo" x64
- name: Boost 1.65
script: