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.7k
/
Copy pathprint-build-info.sh
executable file
·63 lines (55 loc) · 2.26 KB
/
print-build-info.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -eo pipefail
# The purpose of this test is to ensure that the output of the "nodeos --print-build-info" command.
# This includes verifying valid output in JSON shape and checking parameters (only boost for now).
echo '##### Nodeos Print Build Info Test #####'
# orient ourselves
[[ -z "$BUILD_ROOT" ]] && export 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) || :"
echo "$ $PRINT_BUILD_INFO"
OUTPUT="$(eval $PRINT_BUILD_INFO)"
OUTPUT=$(echo "$OUTPUT" | tr -d '\r\n')
OUTPUT=$(echo "$OUTPUT" | sed -E 's/^.+JSON://')
OUTPUT=$(echo "$OUTPUT" | sed -E 's/}.+$/}/')
JQ_OUTPUT=$(echo "$OUTPUT" | jq type)
EXIT_CODE=$?
if [[ "$EXIT_CODE" -ne 0 ]]; then
echo "Not valid JSON type."
exit $EXIT_CODE
fi
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
if [[ "$PLATFORM_TYPE" == "pinned" ]]; then
if [[ -z "$IMAGE_TAG" ]]; then
echo "Missing IMAGE_TAG variable."
exit 1
fi
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/')
BOOST_PATCH=$(echo $BOOST | sed -E 's/^[0-9]+_[0-9]+_([0-9])+$/\1/')
E_BOOST=$(printf "%d%03d%02d" $BOOST_MAJOR $BOOST_MINOR $BOOST_PATCH)
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 "Validation of build info complete."
exit 0