From: Ken Raeburn Date: Sat, 31 Jan 2009 04:39:34 +0000 (+0000) Subject: use t_inetd with a ready message and avoid waiting a lot in non-root tests X-Git-Tag: krb5-1.8-alpha1~745 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2beb2af7dd8e269bf10569099f2183fc23de1ba9;p=krb5.git use t_inetd with a ready message and avoid waiting a lot in non-root tests Change t_inetd to print a ready message when it has started listening on the indicated port number. Look for this message in sample.exp rather than waiting an arbitrary (and usually excessive) 2s each time for the inetd-mode tests. Use run_once to perform the standalone-mode test only once per test suite invocation. Change rsh and rcp tests to start the servers via t_inetd and avoid excessive waiting at startup. In some of my tests, this reduces the tests/dejagnu tests from taking over 6 minutes to taking around 2 minutes. (This does mean the server process will no longer have started up before we launch the client, so it may be slower to respond, but it'll still be faster than the 2s delay we used before even trying to connect.) We can probably eliminate the -D option code from krshd.c now. The tests run as root (rlogin, telnet) still need updating. ticket: 6355 target_version: 1.7 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21855 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/tests/dejagnu/krb-standalone/rcp.exp b/src/tests/dejagnu/krb-standalone/rcp.exp index 94ec240e6..ab6a2c993 100644 --- a/src/tests/dejagnu/krb-standalone/rcp.exp +++ b/src/tests/dejagnu/krb-standalone/rcp.exp @@ -36,7 +36,7 @@ if {![get_hostname] \ proc start_rsh_daemon { } { global REALMNAME - global KRSHD + global KRSHD T_INETD global RCP global tmppwd global krshd_spawn_id @@ -49,21 +49,20 @@ proc start_rsh_daemon { } { } - # The -D argument tells it to accept a single connection, so we - # don't need to use inetd. The portbase+8 is the port to listen at. - # # The -L ENV_SET is for the I/S Athena brokeness in dot files where # LD_LIBRARY_PATH will be overridden causing the "exec csh -c rcp ..." # to fail as the .cshrc is read in. We do not use the -f option as # a users shell might be sh... # Later a proper fix would be to have kshd exec rcp directly # shell indirection... - spawn $KRSHD -k -c -D [expr 8 + $portbase] -P $tmppwd -S $tmppwd/srvtab -M $REALMNAME -L ENV_SET + spawn $T_INETD [expr 8 + $portbase] $KRSHD $KRSHD -k -c -P $tmppwd -S $tmppwd/srvtab -M $REALMNAME -L ENV_SET set krshd_spawn_id $spawn_id set krshd_pid [exp_pid] - # Give the rsh daemon a few seconds to get set up. - sleep 2 + expect { + -ex "Ready!" { } + eof { error "couldn't start t_inetd helper" } + } } # A procedure to stop the rsh daemon. diff --git a/src/tests/dejagnu/krb-standalone/rsh.exp b/src/tests/dejagnu/krb-standalone/rsh.exp index b7c02a2a7..050a71c91 100644 --- a/src/tests/dejagnu/krb-standalone/rsh.exp +++ b/src/tests/dejagnu/krb-standalone/rsh.exp @@ -35,20 +35,20 @@ if {![get_hostname] \ proc start_rsh_daemon { option } { global REALMNAME - global KRSHD + global KRSHD T_INETD global tmppwd global krshd_spawn_id global krshd_pid global portbase - # The -D argument tells it to accept a single connection, so we - # don't need to use inetd. The portbase+8 is the port to listen at. - spawn $KRSHD -k -c -D [expr 8 + $portbase] -S $tmppwd/srvtab -M $REALMNAME -A $option + spawn $T_INETD [expr 8 + $portbase] $KRSHD $KRSHD -k -c -S $tmppwd/srvtab -M $REALMNAME -A $option set krshd_spawn_id $spawn_id set krshd_pid [exp_pid] - # Give the rsh daemon a few seconds to get set up. - sleep 2 + expect { + -ex "Ready!" { } + eof { error "couldn't start t_inetd helper" } + } } # A procedure to stop the rsh daemon. diff --git a/src/tests/dejagnu/krb-standalone/sample.exp b/src/tests/dejagnu/krb-standalone/sample.exp index c19c49e91..326f1848d 100644 --- a/src/tests/dejagnu/krb-standalone/sample.exp +++ b/src/tests/dejagnu/krb-standalone/sample.exp @@ -47,6 +47,9 @@ proc start_sserver_daemon { inetd } { set sserver_spawn_id $spawn_id verbose "sserver_spawn is $sserver_spawn_id" 1 + + # Give sserver some time to start + sleep 2 } else { # Start the sserver spawn $T_INETD [expr 8 + $portbase] $SSERVER sserver -S $tmppwd/srvtab @@ -54,10 +57,12 @@ proc start_sserver_daemon { inetd } { set sserver_spawn_id $spawn_id verbose "sserver_spawn (t_inetd) is $sserver_spawn_id" 1 - } - # Give sserver some time to start - sleep 2 + expect { + -ex "Ready!" { } + eof { error "couldn't start t_inetd helper" } + } + } return 1 } @@ -171,17 +176,19 @@ proc doit { } { return } - if ![start_sserver_daemon 0 ] { - return - } + run_once sample_standalone { + if ![start_sserver_daemon 0 ] { + return + } - if ![test_sclient sclient] { - return - } + if ![test_sclient sclient] { + return + } - pass "sample - standalone" + pass "sample - standalone" - stop_check_sserver_daemon + stop_check_sserver_daemon + } if ![start_sserver_daemon 1 ] { return diff --git a/src/tests/dejagnu/t_inetd.c b/src/tests/dejagnu/t_inetd.c index 6dc91cbbe..aa369d4f1 100644 --- a/src/tests/dejagnu/t_inetd.c +++ b/src/tests/dejagnu/t_inetd.c @@ -110,6 +110,7 @@ main(argc, argv) exit(3); } + printf("Ready!\n"); if ((acc = accept(sock, (struct sockaddr *)&f_inaddr, &namelen)) == -1) { com_err(progname, errno, "accepting");