From f33ba01cad58ef8d76e55bf5035c7d2067bca31b Mon Sep 17 00:00:00 2001 From: Adam Saponara Date: Sun, 28 Nov 2021 13:55:10 -0500 Subject: [PATCH] add regression test for #3 --- Makefile | 2 +- tests/run.sh | 12 ++++++++++-- tests/test_invalid_term/expected.ansi | 24 ++++++++++++++++++++++++ tests/test_invalid_term/test.php | 11 +++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 tests/test_invalid_term/expected.ansi create mode 100755 tests/test_invalid_term/test.php diff --git a/Makefile b/Makefile index 02b206c..45116e3 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ all: $(termbox_demos) $(termbox_demos): %: %.c $(CC) -DTB_OPT_TRUECOLOR -DTB_OPT_EGC $(termbox_cflags) $^ -o $@ -$(termbox_o): +$(termbox_o): $(termbox_h) $(CC) -DTB_IMPL -DTB_OPT_TRUECOLOR -DTB_OPT_EGC -fPIC -xc -c $(termbox_cflags) $(termbox_h) -o $@ $(termbox_so): $(termbox_o) diff --git a/tests/run.sh b/tests/run.sh index 367b64b..aef325d 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -9,6 +9,7 @@ main() { local xterm_geom='80x24+0+0' local xterm_bg='grey3' local xterm_fg='grey93' + local single_test_name=${TERMBOX2_TEST_NAME:-} local main_ec=0 check_deps @@ -17,6 +18,13 @@ main() { for test_php in $(find . -type f -wholename '*/test_*/test.php'); do local test_dir=$(dirname $test_php) local test_name=$(basename $test_dir) + + # check if we are running a specific test (TERMBOX2_TEST_NAME) + if [ -n "$single_test_name" -a "$single_test_name" != "$test_name" ]; then + continue + fi + + # begin echo -e "\x1b[1m$test_name\x1b[0m: BEGIN" # make log file @@ -78,7 +86,7 @@ main() { # take screencap # xwd -root -display $x_display -out $test_dir/observed.xwd # graphical - rm -f "$test_dir/observed.*" + rm -f $test_dir/observed.* DISPLAY=$x_display xvkbd -window xterm -text '\S\[Home]' &>/dev/null # ansi local test_log_xterm_count=$(ls -1 ${test_log_xterm}* 2>/dev/null | wc -l) [ "$test_log_xterm_count" -eq 1 ] && cp ${test_log_xterm}* $test_dir/observed.ansi @@ -104,7 +112,7 @@ main() { cat $test_dir/observed.ansi 2>/dev/null | sed 's/^/ /'; echo -e '\x1b[0m' echo -e '\n [xterm observed.ansi.b64]' - base64 $test_dir/observed.ansi | sed 's/^/ /' + base64 $test_dir/observed.ansi 2>/dev/null | sed 's/^/ /' if [ -s "$test_log_php" ]; then echo -e '\n [php log]' diff --git a/tests/test_invalid_term/expected.ansi b/tests/test_invalid_term/expected.ansi new file mode 100644 index 0000000..986bb96 --- /dev/null +++ b/tests/test_invalid_term/expected.ansi @@ -0,0 +1,24 @@ +#5no_segfault + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/test_invalid_term/test.php b/tests/test_invalid_term/test.php new file mode 100755 index 0000000..cec6db4 --- /dev/null +++ b/tests/test_invalid_term/test.php @@ -0,0 +1,11 @@ +ffi->tb_init(); +$test->ffi->tb_shutdown(); + +file_put_contents("/dev/tty", "no_segfault\n"); + +$test->screencap(); -- 2.39.5