Files
wasm-simulator/test-linuxcnc-wasm-runtime-link.sh

41 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
# LinuxCNC source basis: src/emc/rs274ngc/rs274ngc_pre.cc provides read() and
# execute(), interp_convert.cc converts G0/G2/M30, and emcops.cc/dummyemcstat.cc
# provide the EMC status symbols required by this runtime link probe.
manifest=${1:-linuxcnc-rs274-wasm-source-files.txt}
preflight_cache_dir=${CNC_SIM_PREFLIGHT_CACHE_DIR:-build/wasm-probe-preflight-cache}
probe=$(CNC_SIM_PREFLIGHT_CACHE_DIR="$preflight_cache_dir" ./build-linuxcnc-wasm-link-probe.sh --mode runtime "$manifest")
probe_dir=$(dirname "$probe")
symbol_file="$probe_dir/runtime.symbols"
symbol_signature="$probe_dir/runtime.symbols.signature"
symbol_next_signature="$probe_dir/runtime.symbols.signature.next"
{
printf 'PROBE=%s\n' "$probe"
printf 'SYMBOL_RULE_VERSION=1\n'
stat -c 'PROBE_STAT=%n:%s:%y' "$probe"
} > "$symbol_next_signature"
if [[ ! -f "$symbol_file" || ! -f "$symbol_signature" ]] || ! cmp -s "$symbol_signature" "$symbol_next_signature"; then
nm -C "$probe" > "$symbol_file"
mv "$symbol_next_signature" "$symbol_signature"
else
rm -f "$symbol_next_signature"
fi
grep -F "cnc_sim_parse_program" "$symbol_file" >/dev/null
grep -F "parse_linuxcnc_rs274_backend" "$symbol_file" >/dev/null
grep -F "parse_gcode_with_backend" "$symbol_file" >/dev/null
grep -F "Interp::read(char const*)" "$symbol_file" >/dev/null
grep -F "Interp::init()" "$symbol_file" >/dev/null
grep -F "EMC_STAT::EMC_STAT()" "$symbol_file" >/dev/null
grep -E '(^| )emcStatus$' "$symbol_file" >/dev/null
grep -E '(^| )wordexp($| )' "$symbol_file" >/dev/null
grep -E '(^| )wordfree($| )' "$symbol_file" >/dev/null
"$probe"
echo "linuxcnc wasm runtime link probe passed"