Author: mvidner Date: Mon Jun 4 14:40:40 2007 New Revision: 38265 URL: http://svn.opensuse.org/viewcvs/yast?rev=38265&view=rev Log: ag_background: added a test suite. Added: trunk/core/agents-perl/testsuite/ (with props) trunk/core/agents-perl/testsuite/Makefile.am trunk/core/agents-perl/testsuite/attacks.txt trunk/core/agents-perl/testsuite/t-double-status.exp (with props) trunk/core/agents-perl/testsuite/t-echo-sleep.exp (with props) trunk/core/agents-perl/testsuite/t-echo.exp (with props) trunk/core/agents-perl/testsuite/t-norun.exp (with props) trunk/core/agents-perl/testsuite/t-srcmgr1.exp (with props) trunk/core/agents-perl/testsuite/t-srcmgr2.exp (with props) trunk/core/agents-perl/testsuite/totest.txt Modified: trunk/core/agents-perl/Makefile.am trunk/core/agents-perl/ag_background (props changed) trunk/core/package/yast2-core.changes Modified: trunk/core/agents-perl/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/Makefile.am?rev=38265&r1=38264&r2=38265&view=diff ============================================================================== --- trunk/core/agents-perl/Makefile.am (original) +++ trunk/core/agents-perl/Makefile.am Mon Jun 4 14:40:40 2007 @@ -2,7 +2,7 @@ # Makefile.am for core/agents-perl # -SUBDIRS = conf lib doc +SUBDIRS = conf lib doc testsuite agentdir = @execcompdir@/servers_non_y2 Added: trunk/core/agents-perl/testsuite/Makefile.am URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/testsuite/Makefile.am?rev=38265&view=auto ============================================================================== --- trunk/core/agents-perl/testsuite/Makefile.am (added) +++ trunk/core/agents-perl/testsuite/Makefile.am Mon Jun 4 14:40:40 2007 @@ -0,0 +1,9 @@ +TESTS = \ + t-norun.exp \ + t-echo.exp \ + t-echo-sleep.exp \ + t-double-status.exp \ + t-srcmgr1.exp \ + t-srcmgr2.exp + +XFAIL_TESTS = t-srcmgr1.exp Added: trunk/core/agents-perl/testsuite/attacks.txt URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/testsuite/attacks.txt?rev=38265&view=auto ============================================================================== --- trunk/core/agents-perl/testsuite/attacks.txt (added) +++ trunk/core/agents-perl/testsuite/attacks.txt Mon Jun 4 14:40:40 2007 @@ -0,0 +1,9 @@ +test it all on original agent and the new one + +1) possible bug: double assignment of exit status (on eof of both stdout and +stderr) + +2) +try also running more (unrelated) processes to check whether the values are +properly initialized, to simulate indepedent uses of the agent within a single +yast process Added: trunk/core/agents-perl/testsuite/t-double-status.exp URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/testsuite/t-double-status.exp?rev=38265&view=auto ============================================================================== --- trunk/core/agents-perl/testsuite/t-double-status.exp (added) +++ trunk/core/agents-perl/testsuite/t-double-status.exp Mon Jun 4 14:40:40 2007 @@ -0,0 +1,74 @@ +#!/usr/bin/expect -- +# test ... + +set timeout 3 +expect_after { + default { + puts "OOPS, last matched <<$expect_out(buffer)>>" + exit 1 + } + # pass thru agent stderr +# -i $error_spawn_id +# default {send_user $expect_out(buffer)} +} + +#stty -echo + +#set prog "/usr/lib/YaST2/servers_non_y2/ag_background" +set prog "../ag_background" +puts $prog + +# does not work +#spawn "sh" "-c" "PERLDB_OPTS='NonStop=1 AutoTrace=1 frame=6' perl -dS $prog" + +# can pass -d +spawn $prog $argv + +match_max 100000 + +# TODO use a basic loop like in example and docs +# (while running, or while output open? clarify!) + +# sleep: have it still running while this simple test runs +send "`Execute(.run_output_err, \"echo O; echo O; sleep 1; echo OUT; echo >&2 ERR; exit 2\")\r" +expect "(true)$" + +while {1} { + send "`Read(.isrunning)\r" + expect { + "(true)$" {sleep 1} + "(false)$" break + } + +} + +send "`Read(.pid)\r" +expect "(-1)$" +#send_user "\n" + +send "`Read(.store)\r" +expect "(true)$" +send "`Read(.status)\r" +expect "(2)$" + +send "`Read(.lines)\r" +expect "(3)" +# bug in original agent +expect -re "(\"\")?$" +send "`Read(.lines_err)\r" +expect "(1)$" +send "`Read(.newlines)\r" +expect "(3)$" +send "`Read(.newlines_err)\r" +expect "(1)$" +send "`Read(.newout)\r" +expect -ex "\[\"O\",\"O\",\"OUT\",\] " +send "`Read(.newerr)\r" +expect -ex "\[\"ERR\",\] " + +send "`Read(.output_open)\r" +expect "(false)$" +send "`Read(.output_open_err)\r" +expect "(false)$" +send "`result(true)\r" +expect eof Added: trunk/core/agents-perl/testsuite/t-echo-sleep.exp URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/testsuite/t-echo-sleep.exp?rev=38265&view=auto ============================================================================== --- trunk/core/agents-perl/testsuite/t-echo-sleep.exp (added) +++ trunk/core/agents-perl/testsuite/t-echo-sleep.exp Mon Jun 4 14:40:40 2007 @@ -0,0 +1,54 @@ +#!/usr/bin/expect -f +# test agent status before starting a process +set timeout 3 +expect_after { + default { + puts OOPS + exit 1 + } +} + +#stty -echo +spawn ../ag_background +match_max 100000 +expect -exact "" + +# TODO use a basic looplike in example and docs +# (while running, or while output open? clarify!) + +# sleep: have it still running while this simple test runs +send "`Execute(.run, \"echo Hello world; sleep 2\")\r" +expect "(true)" +sleep 1 + +send "`Read(.pid)\r" +expect -re "(\[0-9\]+)" +send_user "\n" + +send "`Read(.store)\r" +expect "(false)" +send "`Read(.isrunning)\r" +expect "(true)" +# still undefined? +send "`Read(.status)\r" +expect "(0)" +send "`Read(.lines)\r" +expect "(1)" +# bug in original agent +expect -re "(\"\")?$" +send "`Read(.lines_err)\r" +expect "(0)" +send "`Read(.newlines)\r" +expect "(1)" +send "`Read(.newlines_err)\r" +expect "(0)" +send "`Read(.newout)\r" +expect -ex "\[\] " +send "`Read(.newerr)\r" +expect -ex "\[\] " +send "`Read(.output_open)\r" +expect "(true)" +send "`Read(.output_open_err)\r" +expect "(true)" +send "`result(true)\r" +expect eof Added: trunk/core/agents-perl/testsuite/t-echo.exp URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/testsuite/t-echo.exp?rev=38265&view=auto ============================================================================== --- trunk/core/agents-perl/testsuite/t-echo.exp (added) +++ trunk/core/agents-perl/testsuite/t-echo.exp Mon Jun 4 14:40:40 2007 @@ -0,0 +1,48 @@ +#!/usr/bin/expect -f +# test agent status before starting a process +set timeout 3 +expect_after { + default { + puts OOPS + exit 1 + } +} + +#stty -echo +spawn ../ag_background +match_max 100000 +expect -exact "" + +# sleep: have it still running while this simple test runs +send "`Execute(.run, \"sleep 2; echo Hello world\")\r" +expect "(true)" + +send "`Read(.pid)\r" +expect -re "(\[0-9\]+)" +send_user "\n" + +send "`Read(.store)\r" +expect "(false)" +send "`Read(.isrunning)\r" +expect "(true)" +# still undefined? +send "`Read(.status)\r" +expect "(0)" +send "`Read(.lines)\r" +expect "(0)" +send "`Read(.lines_err)\r" +expect "(0)" +send "`Read(.newlines)\r" +expect "(0)" +send "`Read(.newlines_err)\r" +expect "(0)" +send "`Read(.newout)\r" +expect -ex "\[\] " +send "`Read(.newerr)\r" +expect -ex "\[\] " +send "`Read(.output_open)\r" +expect "(true)" +send "`Read(.output_open_err)\r" +expect "(true)" +send "`result(true)\r" +expect eof Added: trunk/core/agents-perl/testsuite/t-norun.exp URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/testsuite/t-norun.exp?rev=38265&view=auto ============================================================================== --- trunk/core/agents-perl/testsuite/t-norun.exp (added) +++ trunk/core/agents-perl/testsuite/t-norun.exp Mon Jun 4 14:40:40 2007 @@ -0,0 +1,43 @@ +#!/usr/bin/expect -f +# test agent status before starting a process +set timeout 3 +expect_after { + default { + puts OOPS + exit 1 + } +} + +#stty -echo +spawn ../ag_background +match_max 100000 +expect -exact "" + +send "`Read(.pid)\r" +expect "(-1)" +send_user "\n" + +send "`Read(.store)\r" +expect "(false)" +send "`Read(.isrunning)\r" +expect "(false)" +send "`Read(.status)\r" +expect "(0)" +send "`Read(.lines)\r" +expect "(0)" +send "`Read(.lines_err)\r" +expect "(0)" +send "`Read(.newlines)\r" +expect "(0)" +send "`Read(.newlines_err)\r" +expect "(0)" +send "`Read(.newout)\r" +expect -ex "\[\] " +send "`Read(.newerr)\r" +expect -ex "\[\] " +send "`Read(.output_open)\r" +expect "(false)" +send "`Read(.output_open_err)\r" +expect "(false)" +send "`result(true)\r" +expect eof Added: trunk/core/agents-perl/testsuite/t-srcmgr1.exp URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/testsuite/t-srcmgr1.exp?rev=38265&view=auto ============================================================================== --- trunk/core/agents-perl/testsuite/t-srcmgr1.exp (added) +++ trunk/core/agents-perl/testsuite/t-srcmgr1.exp Mon Jun 4 14:40:40 2007 @@ -0,0 +1,58 @@ +#!/usr/bin/expect -- +# test ... + +set timeout 3 +expect_after { + default { + puts "OOPS, last matched <<$expect_out(buffer)>>" + exit 1 + } + # pass thru agent stderr +# -i $error_spawn_id +# default {send_user $expect_out(buffer)} +} + +#stty -echo + +#set prog "/usr/lib/YaST2/servers_non_y2/ag_background" +set prog "../ag_background" +#puts $prog + +# does not work +#spawn "sh" "-c" "PERLDB_OPTS='NonStop=1 AutoTrace=1 frame=6' perl -dS $prog" + +# can pass -d +spawn $prog $argv + +match_max 100000 + +# TODO use a basic loop like in example and docs +# (while running, or while output open? clarify!) + +# sleep: have it still running while this simple test runs +#send "`Execute(.run_output_err, \"echo O; echo O; exec 1<&-; sleep 2; echo >&2 ERR; exit 113\")\r" +send "`Execute(.run_output_err, \"echo OUT; echo OUT; echo >&2 ERR; exec 1<&- 2<&-; sleep 2; exit 113\")\r" +expect "(true)$" + +while {1} { + send "`Read(.isrunning)\r" + expect { + "(true)$" {sleep 1} + "(false)$" break + } + +} + +send "`Read(.status)\r" +expect "(113)$" + +send "`Read(.newout)\r" +expect -ex "\[\"OUT\",\"OUT\",\] " +send "`Read(.newerr)\r" +expect -ex "\[\"ERR\",\] " + +send "`Execute(.kill, \"\")\r" +expect "(false)$" + +send "`result(true)\r" +expect eof Added: trunk/core/agents-perl/testsuite/t-srcmgr2.exp URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/testsuite/t-srcmgr2.exp?rev=38265&view=auto ============================================================================== --- trunk/core/agents-perl/testsuite/t-srcmgr2.exp (added) +++ trunk/core/agents-perl/testsuite/t-srcmgr2.exp Mon Jun 4 14:40:40 2007 @@ -0,0 +1,57 @@ +#!/usr/bin/expect -- +# test ... + +set timeout 3 +expect_after { + default { + puts "OOPS, last matched <<$expect_out(buffer)>>" + exit 1 + } + # pass thru agent stderr +# -i $error_spawn_id +# default {send_user $expect_out(buffer)} +} + +#stty -echo + +#set prog "/usr/lib/YaST2/servers_non_y2/ag_background" +set prog "../ag_background" +#puts $prog + +# does not work +#spawn "sh" "-c" "PERLDB_OPTS='NonStop=1 AutoTrace=1 frame=6' perl -dS $prog" + +# can pass -d +spawn $prog $argv + +match_max 100000 + + +send "`Execute(.run_output_err, \"seq 100 199; seq 200 249 >&2; exec 1<&- 2<&-; sleep 2; exit 113\")\r" +expect "(true)$" + +send "`Write(.buffer_size, 10)\r"; +expect "(true)$" + +while {1} { + send "`Read(.isrunning)\r" + expect { + "(true)$" {sleep 1} + "(false)$" break + } + +} + +send "`Read(.status)\r" +expect "(113)$" + +send "`Read(.newlines)\r" +expect "(100)$" +send "`Read(.newlines_err)\r" +expect "(50)$" + +send "`Execute(.kill, \"\")\r" +expect "(false)$" + +send "`result(true)\r" +expect eof Added: trunk/core/agents-perl/testsuite/totest.txt URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/agents-perl/testsuite/totest.txt?rev=38265&view=auto ============================================================================== --- trunk/core/agents-perl/testsuite/totest.txt (added) +++ trunk/core/agents-perl/testsuite/totest.txt Mon Jun 4 14:40:40 2007 @@ -0,0 +1,50 @@ +`Execute(.run, "cmd") +`Execute(.run_output, "cmd") +`Execute(.run_output_err, "cmd") + +`Execute(.kill) + +`Read(.pid) +`Read(.isrunning) +`Read(.status) +`Read(.lines) +`Read(.lines_err) +`Read(.newlines) +`Read(.newlines_err) +`Read(.store) +`Read(.newout) +`Read(.newerr) +`Read(.buffer_out) +`Read(.buffer_err) +`Read(.output_open) +`Read(.output_open_err) +`Read(.buffer_size) +`Read(.buffer_size_err) + +`Write(.buffer_size, num) +`Write(.buffer_size_err, num) +`Write(.stdin, "string") + +`result(true) + +-- +`Execute(.run, "sh -c 'exit 0'") +`Read(.pid) # expect positive number +sleep +`Read(.store) #no +`Read(.output_open) +`Read(.output_open_err) +`Read(.isrunning) # no +`Read(.status) +# empty output +# numbers +`Read(.lines) +`Read(.lines_err) +`Read(.newlines) +`Read(.newlines_err) +`Read(.newout) +`Read(.newerr) +# nonlines +`Read(.buffer_out) +`Read(.buffer_err) +`result(true) Modified: trunk/core/package/yast2-core.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/core/package/yast2-core.changes?rev=38265&r1=38264&r2=38265&view=diff ============================================================================== --- trunk/core/package/yast2-core.changes (original) +++ trunk/core/package/yast2-core.changes Mon Jun 4 14:40:40 2007 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Mon Jun 4 14:40:26 CEST 2007 - mvidner@suse.cz + +- ag_background: added a test suite. + +------------------------------------------------------------------- Thu May 24 11:56:41 CEST 2007 - stbinner@suse.de - add missing %run_ldconfig calls -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org