blob: d9f1766c779a8cba048eadafcfde82d35210edf8 (
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
|
#!/usr/bin/env bash
# Run every program of the release tarballs from its own extracted tarball.
#
# smoke-release-tarballs.sh --platform macos|linux|windows --version V \
# --target T --groups FILE --dir DIR [--ldd]
#
# Each tarball DIR/wsjtx-V-T-<tarball>.tar.gz is extracted into a directory of
# its own, so a library only another tarball carries cannot hide a gap, and
# each program runs from a scratch working directory with the library search
# variables unset, for at most 120 s on Linux; Windows programs launch
# through smoke-launch-windows.sh, which allows 20 s and removes the MinGW
# runtime from PATH. --ldd (Linux) also requires
# every library a tarball bundles to resolve to the bundled copy, because a
# build container has the same libraries installed system-wide.
set -euo pipefail
PLATFORM=""; VERSION=""; TARGET=""; GROUPS_FILE=""; DIR=""; LDD=""
while [ "$#" -gt 0 ]; do
case "$1" in
--platform) PLATFORM="$2"; shift 2 ;;
--version) VERSION="$2"; shift 2 ;;
--target) TARGET="$2"; shift 2 ;;
--groups) GROUPS_FILE="$2"; shift 2 ;;
--dir) DIR="$2"; shift 2 ;;
--ldd) LDD=1; shift ;;
*) echo "unknown argument: $1" >&2; exit 2 ;;
esac
done
for option in PLATFORM VERSION TARGET GROUPS_FILE DIR; do
if [ -z "${!option}" ]; then echo "missing --$(echo "${option%_FILE}" | tr '[:upper:]' '[:lower:]')" >&2; exit 2; fi
done
SCRIPTS="$(cd "$(dirname "$0")" && pwd)"
SAMPLE="${SCRIPTS}/../../samples/WSPR/150426_0918.wav"
DIR="$(cd "$DIR" && pwd)"
fail() { echo "::error::$*" >&2; exit 1; }
WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT
run_program() {
local tree="$1" program="$2" scratch="${WORK}/run-${2}" path arguments=() limit=()
mkdir -p "$scratch"
case "$program" in
jt9|jt9stream) arguments=(--help) ;;
wsprd)
[ -f "$SAMPLE" ] || fail "WSPR sample not found: $SAMPLE"
arguments=(-a "$scratch" "$SAMPLE")
;;
encode77) arguments=("CQ K1ABC FN42") ;;
wsprcode|ft4sim|jt4sim|jt65sim|cwsim|sfoxsim) ;;
*) fail "no smoke invocation for ${program}" ;;
esac
case "$PLATFORM" in
macos) path="${tree}/${program}" ;;
linux) path="${tree}/bin/${program}"; limit=(timeout 120) ;;
windows) path="${tree}/${program}.exe" ;;
*) echo "unknown platform: $PLATFORM" >&2; exit 2 ;;
esac
[ -f "$path" ] || fail "${program} is not in ${tree##*/}"
if [ "$PLATFORM" = windows ]; then
(cd "$scratch" && "${SCRIPTS}/smoke-launch-windows.sh" "$path" ${arguments[@]+"${arguments[@]}"}) ||
fail "${program} from ${tree##*/} failed"
return
fi
if ! (cd "$scratch" && env -u LD_LIBRARY_PATH -u LD_PRELOAD -u DYLD_LIBRARY_PATH \
-u DYLD_FALLBACK_LIBRARY_PATH -u DYLD_FRAMEWORK_PATH -u DYLD_INSERT_LIBRARIES \
${limit[@]+"${limit[@]}"} "$path" ${arguments[@]+"${arguments[@]}"} > "${scratch}/output.txt" 2>&1); then
cat "${scratch}/output.txt" >&2
fail "${program} from ${tree##*/} failed"
fi
echo "smoke OK: ${tree##*/}/${path#"${tree}"/}"
}
check_ldd() {
local tree="$1" file line name resolved directory libdir output bundled=() wrong=()
libdir=$(cd "${tree}/lib" && pwd -P)
while IFS= read -r file; do
bundled+=("${file##*/}")
done < <(find "${tree}/lib" -type f)
while IFS= read -r file; do
output=$(env -u LD_LIBRARY_PATH -u LD_PRELOAD ldd "$file" 2>&1) || fail "ldd failed on ${file#"${tree}"/}: ${output}"
while IFS= read -r line; do
case "$line" in
*'=> not found'*) wrong+=("${line%% *}(${file#"${tree}"/}): not found"); continue ;;
*' => '*) ;;
*) continue ;;
esac
read -r name _ resolved _ <<< "$line"
for library in ${bundled[@]+"${bundled[@]}"}; do
[ "$library" = "$name" ] || continue
directory=$(cd "$(dirname "$resolved")" 2>/dev/null && pwd -P) || directory=""
if [ "${directory}/${resolved##*/}" != "${libdir}/${name}" ]; then
wrong+=("${name}(${file#"${tree}"/}): ${resolved}")
fi
done
done <<< "$output"
done < <(find "${tree}/bin" "${tree}/lib" -type f)
[ "${#wrong[@]}" -eq 0 ] || fail "libraries of ${tree##*/} that do not resolve to its bundled copies: ${wrong[*]}"
}
count=0
while IFS= read -r line || [ -n "$line" ]; do
line="${line%$'\r'}"
read -r -a fields <<< "$line" || true
[ "${#fields[@]}" -gt 1 ] || continue
case "${fields[0]}" in '#'*) continue ;; esac
name="wsjtx-${VERSION}-${TARGET}-${fields[0]}"
tarball="${DIR}/${name}.tar.gz"
[ -f "$tarball" ] || fail "release tarball not found: $tarball"
mkdir -p "${WORK}/${fields[0]}"
tar -xzf "$tarball" -C "${WORK}/${fields[0]}"
tree="${WORK}/${fields[0]}/${name}"
[ -d "$tree" ] || fail "${name}.tar.gz does not extract to ${name}/"
if [ -n "$LDD" ]; then check_ldd "$tree"; fi
for program in "${fields[@]:1}"; do
run_program "$tree" "$program"
count=$((count + 1))
done
done < "$GROUPS_FILE"
[ "$count" -gt 0 ] || fail "no programs named in ${GROUPS_FILE}"
echo "ran ${count} programs from their release tarballs"
|