Harden LinuxCNC wasm and native probe workflows
This commit is contained in:
60
test-linuxcnc-wasm-tooldata-runtime-symbols.sh
Executable file
60
test-linuxcnc-wasm-tooldata-runtime-symbols.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
linuxcnc_root=${LINUXCNC_ROOT:-../linuxcnc}
|
||||
cxx=${CXX:-g++}
|
||||
build_dir=$(mktemp -d "${TMPDIR:-/tmp}/cnc_sim_linuxcnc_wasm_tooldata_runtime_symbols.XXXXXX")
|
||||
|
||||
if [[ ! -d "$linuxcnc_root" ]]; then
|
||||
echo "missing LinuxCNC root: $linuxcnc_root" >&2
|
||||
exit 1
|
||||
fi
|
||||
trap 'rm -rf "$build_dir"' EXIT
|
||||
|
||||
common_flags=(
|
||||
-std=c++17
|
||||
-DULAPI
|
||||
-I "$(pwd)/core/wasm_shims"
|
||||
-I "$linuxcnc_root/src"
|
||||
-I "$linuxcnc_root/src/emc"
|
||||
-I "$linuxcnc_root/src/emc/nml_intf"
|
||||
-I "$linuxcnc_root/src/emc/rs274ngc"
|
||||
-I "$linuxcnc_root/src/emc/motion"
|
||||
-I "$linuxcnc_root/include"
|
||||
)
|
||||
|
||||
"$cxx" "${common_flags[@]}" \
|
||||
-c core/wasm_shims/tooldata/tooldata_runtime_stubs.cc \
|
||||
-o "$build_dir/tooldata_runtime_stubs.o"
|
||||
|
||||
nm --defined-only "$build_dir/tooldata_runtime_stubs.o" \
|
||||
| awk '$2 ~ /^[A-Z]$/ {print $3}' \
|
||||
| LC_ALL=C sort -u \
|
||||
> "$build_dir/runtime.exports"
|
||||
|
||||
expected_exports=(
|
||||
tool_nml_register
|
||||
tooldata_db_getall
|
||||
tooldata_db_init
|
||||
tooldata_db_notify
|
||||
)
|
||||
|
||||
printf '%s\n' "${expected_exports[@]}" | LC_ALL=C sort -u > "$build_dir/expected.exports"
|
||||
|
||||
comm -23 "$build_dir/expected.exports" "$build_dir/runtime.exports" > "$build_dir/missing.exports"
|
||||
if [[ -s "$build_dir/missing.exports" ]]; then
|
||||
echo "missing wasm tooldata runtime stub exports:" >&2
|
||||
cat "$build_dir/missing.exports" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
comm -13 "$build_dir/expected.exports" "$build_dir/runtime.exports" > "$build_dir/unexpected.exports"
|
||||
if [[ -s "$build_dir/unexpected.exports" ]]; then
|
||||
echo "unexpected wasm tooldata runtime stub exports:" >&2
|
||||
cat "$build_dir/unexpected.exports" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "linuxcnc wasm tooldata runtime symbol probe passed"
|
||||
Reference in New Issue
Block a user