From 8f749a27662923a6ae79ab798f54df2b5356de86 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 23 Apr 2022 14:49:51 +0200 Subject: [PATCH] [ tests ] remote control test revision --- build.sh | 12 ++++++--- test.sh | 32 ++++++++++++++++++++++++ test/remote.sh | 68 +++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 94 insertions(+), 18 deletions(-) create mode 100755 test.sh diff --git a/build.sh b/build.sh index da97847e..01f39d14 100755 --- a/build.sh +++ b/build.sh @@ -102,10 +102,12 @@ test() { # for arm32: qemu-arm-static # for win64: wine # - ./src/elinks$1 \ - --no-connect \ - --dump \ - ./test/hello.html + #./src/elinks$1 \ + #--no-connect \ + #--dump \ + #./test/hello.html + # more complete testing + ./test.sh } pub() { @@ -123,6 +125,7 @@ info() { file ./src/elinks$1 ls -lh ./src/elinks$1 ls -l ./src/elinks$1 + ./src/elinks --version } set_arch() { @@ -207,6 +210,7 @@ select SEL in $CC_SEL; do elif [ "$SEL" = "exit" ]; then exit fi + echo "--[ elinks build system ]--" echo "--[ Compiler: " $CC " ]--" echo "--[ Host : " $MAKE_HOST " ]--" done diff --git a/test.sh b/test.sh new file mode 100755 index 00000000..9bb55938 --- /dev/null +++ b/test.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# shell script to test elinks binary +# + +clear + +echo ' --/ \--' +echo ' --[ Welcome to the elinks test helper ]--' +echo ' --[ ]--' +echo ' --[ [*] use option 1 to run dump test ]--' +echo ' --\ /--' +echo ' ' + +# SET TEST +prep_test() { + if [ "$1" = "hello" ]; then + ./src/elinks --dump ./test/hello.html + fi +} + +# MAIN LOOP +prep_test hello +OPTS="hello exit" +select SEL in $OPTS; do + if [ ! "$SEL" = "exit" ]; then + prep_test $SEL + else + exit + fi + echo "--[ Current test : " $SEL" ]--" +done diff --git a/test/remote.sh b/test/remote.sh index 7efcee92..7b4b71aa 100755 --- a/test/remote.sh +++ b/test/remote.sh @@ -1,16 +1,36 @@ -#!/bin/sh +#!/bin/bash # # Test various -remote use cases. Start an ELinks instance before # running the test. All arguments to this test script will be passed to # ELinks. Set ELINKS to change the binary to execute ELinks. # # XXX: The test will affect your current ELinks configurations. If you -# do not want this pass --config-dir to avoid this. +# do not want this pass -config-dir to avoid this. +# +# FIXME: Maybe make this script eun more automatic by using screen. +# +# EDIT: There is now -session-ring and -base-session +# used to prevent intererence with existing running elinks +# +# DOC: For this test GNU screen is recommended. If I assume You'll +# be in the elinks sources directory and there isn't and elinks +# currently running (ps axf | grep elinks). Then use: +# +# $ screen -S test +# +# then ctrl+a and c - create new screen and create new elinks instance +# +# $ ./src/elinks +# +# then return to the original window using ctrl + a and a +# and execute the elinks remote control tests: +# +# $ ./test/remote.sh +# +# If everything is well the remote commands should be executed in the +# running elinks session and You'll see the results if You press: +# ctrl+a and a # -# FIXME: Maybe make this script eun more automatic by using screen. - -elinks=${ELINKS:-elinks} -args="$@" die() { @@ -20,26 +40,42 @@ die() test_remote() { + #echo $args + #echo $1 desc="$1"; shift testno=$(expr "$testno" + 1) - echo "Test $testno: $desc" - echo " > $elinks $confdir --remote '$@'" - "$elinks" $args --remote "$@" - echo "Press return to continue..." - read + echo "[*] test $testno: $desc " + #echo " > $elinks $confdir --remote '$@'" + $elinks $args --remote "$@" + #echo "Press return to continue..." + #read } -elinks=${ELINKS:-elinks} -testno=0 +# MAIN SETUP +# elinks binary +elinks="`pwd`/src/elinks" +#elinks="$elinks -config-dir /home/`whoami`/.elinks" +# custom args +args="$@" +# command to start new elinks session ring +testno=100 +# go to current directory in the shell script +cd `pwd` -"$elinks" $args --remote "ping()" || die "Start ELinks instance to proceed" +# MAIN PROGRAM +echo "[=] Starting remote testing: " $elinks +# tests 010 if remote is working +$elinks $args --remote "ping()" || die "Start ELinks instance to proceed" + +# tests 020 infoBoxes test_remote "infoBox(): no quote" "infoBox(Hello World.)" test_remote "infoBox(): quote" 'infoBox("Hello World.")' test_remote "infoBox(): single quote (not considered as quote chars)" "infoBox('Hello World.')" test_remote "infoBox(): quoted quote" 'infoBox("Hello ""quoted"" World.")' test_remote "infoBox(): quoted string with comma" 'infoBox("Comma, a different kind of punctuation.")' +# tests 030 open url test_remote "openURL(): prompt URL" "openURL()" test_remote "openURL(): in current tab" 'openURL("http://elinks.cz/")' test_remote "openURL(): in new tab" 'openURL(http://elinks.cz/news.html, new-tab)' @@ -48,9 +84,13 @@ test_remote "openURL(): in new tab" 'openURL("http://elinks.cz/news.html", "new- test_remote "openURL(): in new window (requires that ELinks runs in screen or a window environment)" \ "openURL(http://elinks.cz/search.html, new-window)" + +# tests 040 open new window test_remote "xfeDoCommand(): open new window (requires that ELinks runs in screen or a window environment)" \ "xfeDoCommand(openBrowser)" +# tests 050 add bookmark test_remote "addBookmark()" 'addBookmark("http://127.0.0.1/")' +# tests 060 single url test_remote "ELinks extension: single URL" "/"