From 414943689f164586eb86a74f2148da31287ca4a0 Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Thu, 8 Apr 2021 12:52:51 -0400 Subject: [PATCH 1/7] Use a variable for CMAKE_SOURCE_DIR --- tests/full-version-label.sh | 3 ++- tests/print-build-info.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index 7039fc98415..389c3ed4f0a 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -5,12 +5,13 @@ echo '##### Nodeos Full Version Label Test #####' # orient ourselves [[ "$BUILD_ROOT" == '' ]] && BUILD_ROOT=$(pwd) echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." +[[ -z "$CMAKE_SOURCE_DIR" ]] && export CMAKE_SOURCE_DIR="$2" EXPECTED=$1 if [[ -z "$EXPECTED" ]]; then echo "Missing version input." exit 1 fi -VERSION_HASH="$(pushd $2 &>/dev/null && git rev-parse HEAD 2>/dev/null ; popd &>/dev/null)" +VERSION_HASH="$(pushd "$CMAKE_SOURCE_DIR" &>/dev/null && git rev-parse HEAD 2>/dev/null ; popd &>/dev/null)" EXPECTED=v$EXPECTED-$VERSION_HASH echo "Expecting \"$EXPECTED\"..." # get nodeos version diff --git a/tests/print-build-info.sh b/tests/print-build-info.sh index a9883d573fe..cf07db4350e 100755 --- a/tests/print-build-info.sh +++ b/tests/print-build-info.sh @@ -6,6 +6,7 @@ echo '##### Nodeos Print Build Info Test #####' # orient ourselves [[ "$BUILD_ROOT" == '' ]] && BUILD_ROOT="$(pwd)" echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." +[[ -z "$CMAKE_SOURCE_DIR" ]] && export CMAKE_SOURCE_DIR="$1" exec 9>&1 # enable tee to write to STDOUT as a file PRINT_BUILD_INFO="$BUILD_ROOT/bin/nodeos --print-build-info 2>&1 | tee >(cat - >&9) || :" @@ -44,7 +45,7 @@ if [[ "$PLATFORM_TYPE" == "pinned" ]]; then echo "Missing IMAGE_TAG variable." exit 1 fi - FILE=$(ls $1/.cicd/platforms/pinned/$IMAGE_TAG* | head) + FILE=$(ls $CMAKE_SOURCE_DIR/.cicd/platforms/pinned/$IMAGE_TAG* | head) BOOST=$(cat $FILE | grep boost | tr -d '\r\n' | sed -E 's/^.+boost_([0-9]+_[0-9]+_[0-9]+).+$/\1/' | head) BOOST_MAJOR=$(echo $BOOST | sed -E 's/^([0-9])+_[0-9]+_[0-9]+$/\1/') BOOST_MINOR=$(echo $BOOST | sed -E 's/^[0-9]+_([0-9]+)_[0-9]+$/\1/') From 1a9f9a097f224b74350374d298bcea85573f2039 Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Thu, 8 Apr 2021 13:12:40 -0400 Subject: [PATCH 2/7] Consistency is key --- tests/full-version-label.sh | 2 +- tests/print-build-info.sh | 2 +- tests/version-label.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index 389c3ed4f0a..0fb46161329 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -3,7 +3,7 @@ set -eo pipefail # The purpose of this test is to ensure that the output of the "nodeos --full-version" command matches the version string defined by our CMake files echo '##### Nodeos Full Version Label Test #####' # orient ourselves -[[ "$BUILD_ROOT" == '' ]] && BUILD_ROOT=$(pwd) +[[ -z "$BUILD_ROOT" ]] && export BUILD_ROOT="$(pwd)" echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." [[ -z "$CMAKE_SOURCE_DIR" ]] && export CMAKE_SOURCE_DIR="$2" EXPECTED=$1 diff --git a/tests/print-build-info.sh b/tests/print-build-info.sh index cf07db4350e..897fa26a7d9 100755 --- a/tests/print-build-info.sh +++ b/tests/print-build-info.sh @@ -4,7 +4,7 @@ set -eo pipefail # This includes verifying valid output in JSON shape and checking parameters (only boost for now). echo '##### Nodeos Print Build Info Test #####' # orient ourselves -[[ "$BUILD_ROOT" == '' ]] && BUILD_ROOT="$(pwd)" +[[ -z "$BUILD_ROOT" ]] && export BUILD_ROOT="$(pwd)" echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." [[ -z "$CMAKE_SOURCE_DIR" ]] && export CMAKE_SOURCE_DIR="$1" diff --git a/tests/version-label.sh b/tests/version-label.sh index 18957916399..2945ed8a454 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -3,7 +3,7 @@ set -eo pipefail # The purpose of this test is to ensure that the output of the "nodeos --version" command matches the version string defined by our CMake files echo '##### Nodeos Version Label Test #####' # orient ourselves -[[ "$BUILD_ROOT" == '' ]] && BUILD_ROOT="$(pwd)" +[[ -z "$BUILD_ROOT" ]] && export BUILD_ROOT="$(pwd)" echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." EXPECTED=v$1 if [[ -z "$EXPECTED" ]]; then From a3e5978a97b47a04e5058562d06a1be61cdeea5c Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Thu, 8 Apr 2021 13:15:26 -0400 Subject: [PATCH 3/7] Support getting the commit hash without invoking git, for testing --full-version on a clean Linux install --- tests/full-version-label.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index 0fb46161329..3ade7cfb9a2 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -11,8 +11,8 @@ if [[ -z "$EXPECTED" ]]; then echo "Missing version input." exit 1 fi -VERSION_HASH="$(pushd "$CMAKE_SOURCE_DIR" &>/dev/null && git rev-parse HEAD 2>/dev/null ; popd &>/dev/null)" -EXPECTED=v$EXPECTED-$VERSION_HASH +[[ -z "$BUILDKITE_COMMIT" ]] && export BUILDKITE_COMMIT="$(pushd "$CMAKE_SOURCE_DIR" &>/dev/null && git rev-parse HEAD 2>/dev/null ; popd &>/dev/null)" +EXPECTED=v$EXPECTED-$BUILDKITE_COMMIT echo "Expecting \"$EXPECTED\"..." # get nodeos version ACTUAL=$($BUILD_ROOT/bin/nodeos --full-version) From 83adc3fc1e9963310b4ddd12ae766f3d97f3b794 Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Thu, 8 Apr 2021 13:22:46 -0400 Subject: [PATCH 4/7] Support providing an expected value from outside the test (and without git or CMake) --- tests/full-version-label.sh | 8 +++++--- tests/version-label.sh | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index 3ade7cfb9a2..c62ec22d33a 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -6,13 +6,15 @@ echo '##### Nodeos Full Version Label Test #####' [[ -z "$BUILD_ROOT" ]] && export BUILD_ROOT="$(pwd)" echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." [[ -z "$CMAKE_SOURCE_DIR" ]] && export CMAKE_SOURCE_DIR="$2" -EXPECTED=$1 +# test expectations +if [[ -z "$EXPECTED" ]]; then + [[ -z "$BUILDKITE_COMMIT" ]] && export BUILDKITE_COMMIT="$(pushd "$CMAKE_SOURCE_DIR" &>/dev/null && git rev-parse HEAD 2>/dev/null ; popd &>/dev/null)" + export EXPECTED="v$1-$BUILDKITE_COMMIT" +fi if [[ -z "$EXPECTED" ]]; then echo "Missing version input." exit 1 fi -[[ -z "$BUILDKITE_COMMIT" ]] && export BUILDKITE_COMMIT="$(pushd "$CMAKE_SOURCE_DIR" &>/dev/null && git rev-parse HEAD 2>/dev/null ; popd &>/dev/null)" -EXPECTED=v$EXPECTED-$BUILDKITE_COMMIT echo "Expecting \"$EXPECTED\"..." # get nodeos version ACTUAL=$($BUILD_ROOT/bin/nodeos --full-version) diff --git a/tests/version-label.sh b/tests/version-label.sh index 2945ed8a454..d65415e4da2 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -5,7 +5,10 @@ echo '##### Nodeos Version Label Test #####' # orient ourselves [[ -z "$BUILD_ROOT" ]] && export BUILD_ROOT="$(pwd)" echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." -EXPECTED=v$1 +# test expectations +if [[ -z "$EXPECTED" ]]; then + export EXPECTED="v$1" +fi if [[ -z "$EXPECTED" ]]; then echo "Missing version input." exit 1 From 709d4e3d24e099d9eb8059a814e151dfe8dd60e9 Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Thu, 8 Apr 2021 13:58:09 -0400 Subject: [PATCH 5/7] Test now works with full git tags, not partial ones --- tests/CMakeLists.txt | 4 ++-- tests/full-version-label.sh | 2 +- tests/version-label.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0265efee9c4..e62d5718d31 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -95,8 +95,8 @@ set_property(TEST keosd_auto_launch_test PROPERTY LABELS nonparallelizable_tests add_test(NAME db_modes_test COMMAND tests/db_modes_test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(db_modes_test PROPERTIES COST 6000) add_test(NAME release-build-test COMMAND tests/release-build.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -add_test(NAME version-label-test COMMAND tests/version-label.sh ${VERSION_FULL} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) -add_test(NAME full-version-label-test COMMAND tests/full-version-label.sh ${VERSION_FULL} ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +add_test(NAME version-label-test COMMAND tests/version-label.sh "v${VERSION_FULL}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +add_test(NAME full-version-label-test COMMAND tests/full-version-label.sh "v${VERSION_FULL}" ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) add_test(NAME print-build-info-test COMMAND tests/print-build-info.sh ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) # Long running tests diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index c62ec22d33a..beb5cc66648 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -9,7 +9,7 @@ echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." # test expectations if [[ -z "$EXPECTED" ]]; then [[ -z "$BUILDKITE_COMMIT" ]] && export BUILDKITE_COMMIT="$(pushd "$CMAKE_SOURCE_DIR" &>/dev/null && git rev-parse HEAD 2>/dev/null ; popd &>/dev/null)" - export EXPECTED="v$1-$BUILDKITE_COMMIT" + export EXPECTED="$1-$BUILDKITE_COMMIT" fi if [[ -z "$EXPECTED" ]]; then echo "Missing version input." diff --git a/tests/version-label.sh b/tests/version-label.sh index d65415e4da2..a07eb417568 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -7,7 +7,7 @@ echo '##### Nodeos Version Label Test #####' echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." # test expectations if [[ -z "$EXPECTED" ]]; then - export EXPECTED="v$1" + export EXPECTED="$1" fi if [[ -z "$EXPECTED" ]]; then echo "Missing version input." From dd7d9336f065f1ef5bf82bc0850c6d7990362161 Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Thu, 8 Apr 2021 13:36:36 -0400 Subject: [PATCH 6/7] Support providing git tag via environment variables in addition to argument 1 --- tests/full-version-label.sh | 3 ++- tests/version-label.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index beb5cc66648..b6d64a5b78f 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -9,7 +9,8 @@ echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." # test expectations if [[ -z "$EXPECTED" ]]; then [[ -z "$BUILDKITE_COMMIT" ]] && export BUILDKITE_COMMIT="$(pushd "$CMAKE_SOURCE_DIR" &>/dev/null && git rev-parse HEAD 2>/dev/null ; popd &>/dev/null)" - export EXPECTED="$1-$BUILDKITE_COMMIT" + [[ -z "$BUILDKITE_TAG" ]] export BUILDKITE_TAG="${GIT_TAG:-$1}" + export EXPECTED="$BUILDKITE_TAG-$BUILDKITE_COMMIT" fi if [[ -z "$EXPECTED" ]]; then echo "Missing version input." diff --git a/tests/version-label.sh b/tests/version-label.sh index a07eb417568..df756d3b1e1 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -7,7 +7,8 @@ echo '##### Nodeos Version Label Test #####' echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." # test expectations if [[ -z "$EXPECTED" ]]; then - export EXPECTED="$1" + [[ -z "$BUILDKITE_TAG" ]] export BUILDKITE_TAG="${GIT_TAG:-$1}" + export EXPECTED="$BUILDKITE_TAG" fi if [[ -z "$EXPECTED" ]]; then echo "Missing version input." From 84f6838eee7eda9baef385622a372134fa2def43 Mon Sep 17 00:00:00 2001 From: Zach Butler Date: Thu, 8 Apr 2021 14:48:11 -0400 Subject: [PATCH 7/7] Fix missing symbol --- tests/full-version-label.sh | 2 +- tests/version-label.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/full-version-label.sh b/tests/full-version-label.sh index b6d64a5b78f..732727c85b3 100755 --- a/tests/full-version-label.sh +++ b/tests/full-version-label.sh @@ -9,7 +9,7 @@ echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." # test expectations if [[ -z "$EXPECTED" ]]; then [[ -z "$BUILDKITE_COMMIT" ]] && export BUILDKITE_COMMIT="$(pushd "$CMAKE_SOURCE_DIR" &>/dev/null && git rev-parse HEAD 2>/dev/null ; popd &>/dev/null)" - [[ -z "$BUILDKITE_TAG" ]] export BUILDKITE_TAG="${GIT_TAG:-$1}" + [[ -z "$BUILDKITE_TAG" ]] && export BUILDKITE_TAG="${GIT_TAG:-$1}" export EXPECTED="$BUILDKITE_TAG-$BUILDKITE_COMMIT" fi if [[ -z "$EXPECTED" ]]; then diff --git a/tests/version-label.sh b/tests/version-label.sh index df756d3b1e1..3b431be9220 100755 --- a/tests/version-label.sh +++ b/tests/version-label.sh @@ -7,7 +7,7 @@ echo '##### Nodeos Version Label Test #####' echo "Using BUILD_ROOT=\"$BUILD_ROOT\"." # test expectations if [[ -z "$EXPECTED" ]]; then - [[ -z "$BUILDKITE_TAG" ]] export BUILDKITE_TAG="${GIT_TAG:-$1}" + [[ -z "$BUILDKITE_TAG" ]] && export BUILDKITE_TAG="${GIT_TAG:-$1}" export EXPECTED="$BUILDKITE_TAG" fi if [[ -z "$EXPECTED" ]]; then