blob: 54e2ed2f12d9b677228d1a485cb063dde4dfde3b (
plain)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "Usage: verify-tsan-deps-linux.sh QT_PREFIX BOOST_PREFIX HAMLIB_PREFIX [CMAKE_CACHE [BINARY]]" >&2
}
if [ "$#" -lt 3 ] || [ "$#" -gt 5 ]; then
usage
exit 2
fi
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# shellcheck source=.github/scripts/tsan-linux-deps-config.sh
. "${script_dir}/tsan-linux-deps-config.sh"
qt_prefix=$1
boost_prefix=$2
hamlib_prefix=$3
cmake_cache=${4:-}
binary=${5:-}
manifest_value() {
local manifest=$1 key=$2
awk -F= -v key="$key" '$1 == key {sub(/^[^=]*=/, ""); print; exit}' "$manifest"
}
cmake_cache_value() {
local cache=$1 key=$2
awk -F= -v key="$key" '$1 ~ ("^" key ":[^=]+$") {sub(/^[^=]*=/, ""); print; exit}' "$cache"
}
verify_cmake_cache_prefix() {
local cache=$1 key=$2 prefix=$3 value
value="$(cmake_cache_value "$cache" "$key")"
if [[ "$value" != "$prefix"/* ]]; then
echo "CMake resolved $key outside $prefix: ${value:-<unset>}" >&2
return 1
fi
}
verify_manifest() {
local dependency=$1 prefix=$2 manifest expected_key actual_key
manifest="${prefix}/.wsjtx-tsan-manifest"
if [ ! -f "$manifest" ]; then
echo "Missing $dependency TSan manifest: $manifest" >&2
return 1
fi
if [ "$(manifest_value "$manifest" dependency)" != "$dependency" ]; then
echo "Unexpected dependency identity in $manifest" >&2
return 1
fi
expected_key="$(tsan_dependency_cache_key "$dependency")"
actual_key="$(manifest_value "$manifest" cache_key)"
if [ "$actual_key" != "$expected_key" ]; then
echo "$dependency TSan cache manifest mismatch" >&2
echo "Expected: $expected_key" >&2
echo "Actual: $actual_key" >&2
return 1
fi
}
verify_dynamic_tsan_symbols() {
local label=$1 library=$2
if [ ! -f "$library" ]; then
echo "Missing $label library: $library" >&2
return 1
fi
if ! nm -D "$library" | awk '$0 ~ /__tsan_/ {found=1} END {exit !found}'; then
echo "$label does not reference the TSan runtime: $library" >&2
return 1
fi
}
verify_manifest qt "$qt_prefix"
verify_manifest boost "$boost_prefix"
verify_manifest hamlib "$hamlib_prefix"
qt_core="${qt_prefix}/lib/libQt5Core.so.5"
boost_candidates=("${boost_prefix}"/lib/libboost_log.so*)
boost_log=${boost_candidates[0]}
hamlib_archive="${hamlib_prefix}/lib/libhamlib.a"
verify_dynamic_tsan_symbols Qt5Core "$qt_core"
verify_dynamic_tsan_symbols Boost.Log "$boost_log"
if [ ! -f "$hamlib_archive" ]; then
echo "Missing Hamlib archive: $hamlib_archive" >&2
exit 1
fi
if ! nm -A "$hamlib_archive" | awk '$0 ~ /__tsan_/ {found=1} END {exit !found}'; then
echo "Hamlib does not reference the TSan runtime: $hamlib_archive" >&2
exit 1
fi
for required in \
"${qt_prefix}/lib/cmake/Qt5Core/Qt5CoreConfig.cmake" \
"${qt_prefix}/lib/cmake/Qt5Test/Qt5TestConfig.cmake" \
"${qt_prefix}/lib/cmake/Qt5Multimedia/Qt5MultimediaConfig.cmake" \
"${qt_prefix}/lib/cmake/Qt5SerialPort/Qt5SerialPortConfig.cmake" \
"${qt_prefix}/lib/cmake/Qt5WebSockets/Qt5WebSocketsConfig.cmake" \
"${boost_prefix}/include/boost/log/core.hpp"; do
if [ ! -e "$required" ]; then
echo "Missing cached TSan dependency file: $required" >&2
exit 1
fi
done
if [ -n "$cmake_cache" ]; then
if [ ! -f "$cmake_cache" ]; then
echo "CMake cache not found: $cmake_cache" >&2
exit 1
fi
verify_cmake_cache_prefix "$cmake_cache" Qt5Core_DIR "$qt_prefix"
verify_cmake_cache_prefix "$cmake_cache" Boost_INCLUDE_DIR "$boost_prefix"
verify_cmake_cache_prefix "$cmake_cache" Boost_LOG_LIBRARY_RELEASE "$boost_prefix"
verify_cmake_cache_prefix "$cmake_cache" Boost_LOG_SETUP_LIBRARY_RELEASE "$boost_prefix"
verify_cmake_cache_prefix "$cmake_cache" Hamlib_INCLUDE_DIR "$hamlib_prefix"
verify_cmake_cache_prefix "$cmake_cache" Hamlib_LIBRARY "$hamlib_prefix"
fi
if [ -n "$binary" ]; then
if [ ! -x "$binary" ]; then
echo "TSan binary not found or not executable: $binary" >&2
exit 1
fi
linked="$(ldd "$binary")"
if ! printf '%s\n' "$linked" | awk -v prefix="$qt_prefix" '$0 ~ /libQt5Core/ && index($0, prefix) {found=1} END {exit !found}'; then
echo "Binary is not using cached TSan Qt: $binary" >&2
exit 1
fi
if ! printf '%s\n' "$linked" | awk -v prefix="$boost_prefix" '$0 ~ /libboost_log/ && index($0, prefix) {found=1} END {exit !found}'; then
echo "Binary is not using cached TSan Boost.Log: $binary" >&2
exit 1
fi
fi
echo "Verified pinned TSan Qt, Boost, and Hamlib prefixes"
|