This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating print-build-info to get data from pinned build scripts.
- Loading branch information
1 parent
103c7d9
commit cb9ef32
Showing
1 changed file
with
49 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,65 @@ | ||
#!/bin/bash | ||
# The purpose of this test is to ensure that the output of the "nodeos --print-build-info" command matches the version string defined by our CMake files | ||
echo '##### Nodeos Version Label Test #####' | ||
# The purpose of this test is to ensure that the output of the "nodeos --print-build-info" command. | ||
echo '##### Nodeos Print Build Info Test #####' | ||
# orient ourselves | ||
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/eos/') | ||
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/EOSIO/eosio/') | ||
[[ "$EOSIO_ROOT" == '' ]] && EOSIO_ROOT=$(echo $(pwd)/ | grep -ioe '.*/build/' | sed 's,/build/,,') | ||
echo "Using EOSIO_ROOT=\"$EOSIO_ROOT\"." | ||
# determine expected value | ||
BUILD_VARS="$EOSIO_ROOT/scripts/.build_vars" | ||
if [[ -f "$BUILD_VARS" ]]; then | ||
echo "Parsing \"$BUILD_VARS\"..." | ||
$(cat $BUILD_VARS | grep -ie 'export BOOST_VERSION_MAJOR' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1" "$2}') | ||
$(cat $BUILD_VARS | grep -ie 'export BOOST_VERSION_MINOR' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1" "$2}') | ||
$(cat $BUILD_VARS | grep -ie 'export BOOST_VERSION_PATCH' | cut -d '(' -f 2 | cut -d ')' -f 1 | awk '{print $1" "$2}') | ||
EXPECTED_BOOST_VERSION=$(printf "%d%03d%02d" $BOOST_VERSION_MAJOR $BOOST_VERSION_MINOR $BOOST_VERSION_PATCH) | ||
else | ||
echo 'No build vars available.' | ||
|
||
OUTPUT=$($EOSIO_ROOT/build/bin/nodeos --print-build-info 2>&1) | ||
EXIT_CODE=$? | ||
echo "$OUTPUT" | ||
if [[ $EXIT_CODE -eq 0 ]]; then | ||
echo 'Expected non-zero nodeos exit code.' | ||
exit 1 | ||
fi | ||
# fail if no expected value was found | ||
if [[ -z "$BOOST_VERSION_MAJOR" || -z "$BOOST_VERSION_MINOR" || -z "$BOOST_VERSION_PATCH" ]]; then | ||
echo 'ERROR: Could not determine expected value for version label!' | ||
set +e | ||
echo "EOSIO_ROOT=\"$EOSIO_ROOT\"" | ||
echo "BUILD_VARS=\"$BUILD_VARS\"" | ||
echo '' | ||
echo "BOOST_VERSION_MAJOR=\"$BOOST_VERSION_MAJOR\"" | ||
echo "BOOST_VERSION_MINOR=\"$BOOST_VERSION_MINOR\"" | ||
echo "BOOST_VERSION_PATCH=\"$BOOST_VERSION_PATCH\"" | ||
echo "EXPECTED_BOOST_VERSION=\"$EXPECTED_BOOST_VERSION\"" | ||
echo '' | ||
echo '$ pwd' | ||
pwd | ||
echo '$ ls -la "$EOSIO_ROOT"' | ||
ls -la "$EOSIO_ROOT" | ||
echo '$ ls -la "$EOSIO_ROOT/build"' | ||
ls -la "$EOSIO_ROOT/build" | ||
exit 1 | ||
|
||
OUTPUT=$(echo "$OUTPUT" | tr -d '\r\n') | ||
OUTPUT=$(echo "$OUTPUT" | sed 's/^.\+JSON://') | ||
OUTPUT=$(echo "$OUTPUT" | sed 's/}.\+$/}/') | ||
|
||
JQ_OUTPUT=$(echo "$OUTPUT" | jq type) | ||
EXIT_CODE=$? | ||
if [[ "$EXIT_CODE" -ne 0 ]]; then | ||
echo "Not valid JSON type." | ||
exit $EXIT_CODE | ||
fi | ||
|
||
OUTPUT=$($EOSIO_ROOT/build/bin/nodeos --print-build-info 2>&1) | ||
if [[ $? -eq 0 ]]; then | ||
echo 'Expected non-zero nodeos exit code.' | ||
V_ARCH=$(echo "$OUTPUT" | jq '.arch') | ||
echo "ARCH: $V_ARCH" | ||
V_BOOST=$(echo "$OUTPUT" | jq '.boost_version') | ||
echo "BOOST_VERSION: $V_BOOST" | ||
V_COMPILER=$(echo "$OUTPUT" | jq '.compiler') | ||
echo "COMPILER: $V_COMPILER" | ||
V_DEBUG=$(echo "$OUTPUT" | jq '.debug') | ||
echo "DEBUG: $V_DEBUG" | ||
V_OS=$(echo "$OUTPUT" | jq '.os') | ||
echo "OS: $V_OS" | ||
|
||
if [[ -z "$V_ARCH" || -z "$V_BOOST" || -z "$V_COMPILER" || -z "$V_DEBUG" || -z "$V_OS" ]]; then | ||
echo "Missing expected build info key(s)." | ||
exit 1 | ||
fi | ||
|
||
JSON=$(echo $OUTPUT | tr -d '\r\n' | sed 's/^.\+ JSON: \({ .\+ }\).\+$/\1/') | ||
ACTUAL_BOOST_VERSION=$(echo $JSON | sed 's/^.\+"boost_version": \([0-9]\+\).\+$/\1/') | ||
if [[ "$PLATFORM_TYPE" == "pinned" ]]; then | ||
if [[ -z "$IMAGE_TAG" ]]; then | ||
echo "Missing IMAGE_TAG variable." | ||
exit 1 | ||
fi | ||
FILE=$(ls $EOSIO_ROOT/.cicd/platforms/pinned/$IMAGE_TAG* | head) | ||
BOOST=$(cat $FILE | grep boost | tr -d '\r\n' | sed 's/^.\+boost_\([0-9_]\+\) .\+$/\1/' | head) | ||
BOOST_MAJOR=$(echo $BOOST | sed 's/^\([0-9]\)\+_[0-9]\+_[0-9]\+$/\1/') | ||
BOOST_MINOR=$(echo $BOOST | sed 's/^[0-9]\+_\([0-9]\+\)_[0-9]\+$/\1/') | ||
BOOST_PATCH=$(echo $BOOST | sed 's/^[0-9]\+_[0-9]\+_\([0-9]\)\+$/\1/') | ||
E_BOOST=$(printf "%d%03d%02d" $BOOST_MAJOR $BOOST_MINOR $BOOST_PATCH) | ||
|
||
echo "Expecting boost version \"$EXPECTED_BOOST_VERSION\"..." | ||
if [[ "$EXPECTED_BOOST_VERSION" == "$ACTUAL_BOOST_VERSION" ]]; then | ||
echo "Passed with \"$ACTUAL_BOOST_VERSION\"." | ||
exit 0; | ||
echo "Verifying boost version: \"$E_BOOST\" == \"$V_BOOST\"." | ||
if [[ "$E_BOOST" != "$V_BOOST" ]]; then | ||
echo "Expected boost version \"$E_BOOST\" does not match actual \"$V_BOOST\"." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo 'Failed!' | ||
echo "\"$EXPECTED_BOOST_VERSION\" != \"$ACTUAL_BOOST_VERSION\"" | ||
exit 1 | ||
echo "Validation of build info complete." | ||
exit 0 |