run.sh (1523B)
1 #!/bin/sh 2 set -eu 3 4 ROOT=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 5 KIT_BUILD_DIR=${KIT_BUILD_DIR:-"$ROOT/build/test/rpn-lang"} 6 OUT="$KIT_BUILD_DIR/out" 7 LOG="$KIT_BUILD_DIR/run.log" 8 RPN_OBJ="$OUT/rpn_lang.o" 9 KIT="$KIT_BUILD_DIR/kit-rpn" 10 11 mkdir -p "$OUT" 12 13 { 14 printf 'build rpn frontend object\n' 15 "${CC:-cc}" -std=c11 -I "$ROOT/include" -c "$ROOT/test/rpn-lang/rpn_lang.c" -o "$RPN_OBJ" 16 printf 'build custom kit driver\n' 17 make -C "$ROOT" custom-bin \ 18 BUILD_DIR="$KIT_BUILD_DIR/base" \ 19 KIT_DRIVER_CUSTOM_BIN="$KIT" \ 20 KIT_DRIVER_EXT_OBJS="$RPN_OBJ" \ 21 KIT_DRIVER_EXT_REGISTER=kit_rpn_register_frontends 22 printf 'compile rpn program with custom driver\n' 23 "$KIT" build-exe -target x86_64-none-elf -nostdlib \ 24 "$ROOT/test/rpn-lang/caller.c" "$ROOT/test/rpn-lang/prog.rpn" \ 25 -o "$OUT/rpn.elf" 26 printf 'inspect symbols\n' 27 "$KIT" nm "$OUT/rpn.elf" 28 printf 'run rpn program with custom driver\n' 29 if "$KIT" run "$ROOT/test/rpn-lang/prog.rpn"; then 30 rpn_status=0 31 else 32 rpn_status=$? 33 fi 34 if [ "$rpn_status" -ne 14 ]; then 35 printf 'expected kit run exit 14, got %s\n' "$rpn_status" 36 exit 1 37 fi 38 printf 'debugger accepts rpn input with custom driver\n' 39 "$KIT" dbg "$ROOT/test/rpn-lang/prog.rpn" --batch --command language 40 printf 'debugger appends rpn snippets with custom driver\n' 41 "$KIT" dbg --batch --language rpn --command 'jit { 2 3 + }' --command language 42 } >"$LOG" 2>&1 43 44 grep ' main$' "$LOG" >/dev/null 45 grep 'Language: rpn' "$LOG" >/dev/null 46 printf 'rpn-lang ok\n'