| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #!/bin/bash
- # tests/term_config.sh -- assert the terminal CONFIG loader and decoder.
- #
- # The shell reads TP3.TRM at startup (TermCfg.Load) instead of having escape
- # sequences patched into it. This suite is that loader's oracle: it feeds a
- # fixture config to a tiny harness and compares every decoded sequence byte for
- # byte. The interesting cases are the ones an eyeball misses:
- #
- # * \e must be ONE ESC byte, not a backslash and an 'e';
- # * ^G must be BEL (07), not '^' and 'G';
- # * the ANSI default must survive when no keys are given;
- # * VT52's GOTO uses %R/%C (raw bytes), which are still just text here - the
- # shell substitutes them, and their presence is pinned so the substitution
- # site cannot silently lose them.
- #
- # It is a separate suite, not part of the shell UI tests, because the loader is
- # pure data: no pty, no screen, no timing.
- set -u
- D=/home/eric/Projets/Projets-Modula2/MyWork/TP3-comp/shell
- GM2=/home/eric/Modula2/Gm2/bin/gm2
- [ -x "$GM2" ] || GM2=/home/eric/bin/Modula2/Gm2/bin/gm2
- cd "$D" || exit 9
- mkdir -p ../tmp
- if [ ! -f Posix.o ] || [ Posix.c -nt Posix.o ]; then
- cc -c Posix.c >../tmp/termcfg_c_posix 2>&1 || {
- echo "COMPILE_FAIL Posix"; grep -m5 "error:" ../tmp/termcfg_c_posix; exit 1; }
- fi
- if [ ! -f TermCfg.o ] || [ TermCfg.mod -nt TermCfg.o ]; then
- $GM2 -fiso -c TermCfg.mod >../tmp/termcfg_c 2>&1 || {
- echo "COMPILE_FAIL TermCfg"; grep -m5 "error:" ../tmp/termcfg_c; exit 1; }
- fi
- if [ ! -x tests/termcfgtest ] || [ tests/TermCfgTest.mod -nt tests/termcfgtest ] \
- || [ TermCfg.o -nt tests/termcfgtest ] || [ Posix.o -nt tests/termcfgtest ]; then
- rm -f tests/termcfgtest
- $GM2 -fiso -o tests/termcfgtest tests/TermCfgTest.mod TermCfg.o Posix.o \
- >../tmp/termcfg_link 2>&1 || {
- echo "LINK_FAIL"; grep -m5 -E "error:|undefined" ../tmp/termcfg_link; exit 1; }
- fi
- pass=0; fail=0
- for name in term_ansi term_vt52; do
- cp "tests/fixtures/$name.trm" ../tmp/term_test.trm || exit 1
- ./tests/termcfgtest > "../tmp/$name.got" 2>&1
- if diff -u "tests/fixtures/$name.hex" "../tmp/$name.got" > "../tmp/$name.diff"; then
- printf ' %-20s PASS\n' "$name"
- pass=$((pass + 1))
- else
- printf ' %-20s FAIL\n' "$name"
- head -20 "../tmp/$name.diff"
- fail=$((fail + 1))
- fi
- done
- # ---- the editor's key map ------------------------------------------------
- if [ ! -f Keys.o ] || [ Keys.mod -nt Keys.o ]; then
- $GM2 -fiso -c Keys.mod >../tmp/termcfg_c_keys 2>&1 || {
- echo "COMPILE_FAIL Keys"; grep -m5 "error:" ../tmp/termcfg_c_keys; exit 1; }
- fi
- if [ ! -x tests/keycfgtest ] || [ tests/KeysTest.mod -nt tests/keycfgtest ] \
- || [ Keys.o -nt tests/keycfgtest ] || [ TermCfg.o -nt tests/keycfgtest ]; then
- rm -f tests/keycfgtest
- $GM2 -fiso -o tests/keycfgtest tests/KeysTest.mod Keys.o TermCfg.o Posix.o \
- >../tmp/keycfg_link 2>&1 || {
- echo "LINK_FAIL KeysTest"; grep -m5 -E "error:|undefined" ../tmp/keycfg_link; exit 1; }
- fi
- for name in key_default key_custom; do
- cp "tests/fixtures/$name.key" ../tmp/key_test.key || exit 1
- ./tests/keycfgtest > "../tmp/$name.got" 2>&1
- if diff -u "tests/fixtures/$name.hex" "../tmp/$name.got" > "../tmp/$name.diff"; then
- printf ' %-20s PASS\n' "$name"
- pass=$((pass + 1))
- else
- printf ' %-20s FAIL\n' "$name"
- head -20 "../tmp/$name.diff"
- fail=$((fail + 1))
- fi
- done
- echo "----------------------------------------------------------------"
- echo "terminal config: $pass passed, $fail failed (of $((pass + fail)))"
- [ "$fail" -eq 0 ] || exit 1
|