Test the sample sever/client in both standalone and pseudo-inetd modes
authorEzra Peisach <epeisach@mit.edu>
Sat, 26 Aug 1995 22:27:24 +0000 (22:27 +0000)
committerEzra Peisach <epeisach@mit.edu>
Sat, 26 Aug 1995 22:27:24 +0000 (22:27 +0000)
Hopefully this will prevent future cases of the documented test-case to
fail.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6601 dc483132-0cff-0310-8789-dd5450dbe970

src/tests/dejagnu/krb-standalone/ChangeLog
src/tests/dejagnu/krb-standalone/sample.exp

index 54ac0d4acdb81a17230501ec3ff472a1a059cb3a..ae8a0a75acbca2c2f933d8b4ca9f95b3283e9a74 100644 (file)
@@ -1,3 +1,7 @@
+Sat Aug 26 17:56:50 1995  Ezra Peisach  (epeisach@kangaroo.mit.edu)
+
+       * sample.exp: Add inetd test
+
 Thu Aug 24 18:48:01 1995  Theodore Y. Ts'o  <tytso@dcl>
 
        * .Sanitize: Update file list
index e16ff2706f4981a219923326de78debfedbb9b58..6180fe92807a0c1d6fe3f8b199cb4d2be990be2b 100644 (file)
@@ -30,6 +30,38 @@ if ![setup_kerberos_db 0] {
     return
 }
 
+proc start_sserver_daemon { inetd } {
+    global spawn_id
+    global sserver_pid
+    global sserver_spawn_id
+    global SSERVER
+    global T_INETD
+    global tmppwd
+
+    # if inetd = 0, then we are running stand-alone
+    if !{$inetd} {
+           # Start the sserver
+           spawn $SSERVER -p 3964 -S $tmppwd/srvtab
+           set sserver_pid [exp_pid]
+           set sserver_spawn_id $spawn_id
+
+           verbose "sserver_spawn is $sserver_spawn_id" 1
+    } else {
+           # Start the sserver
+           spawn $T_INETD 3964 $SSERVER sserver -S $tmppwd/srvtab
+           set sserver_pid [exp_pid]
+           set sserver_spawn_id $spawn_id
+
+           verbose "sserver_spawn (t_inetd) is $sserver_spawn_id" 1
+    }
+
+    # Give sserver some time to start
+    catch "exec sleep 2"
+
+    return 1
+}
+
+
 proc stop_sserver_daemon { } {
     global sserver_pid
     global sserver_spawn_id
@@ -44,19 +76,71 @@ proc stop_sserver_daemon { } {
     return 1
 }
 
+proc stop_check_sserver_daemon { } {
+    global sserver_spawn_id
+    global sserver_pid
+
+    # Check the exit status of sserver - should exit here
+    set status_list [wait -i $sserver_spawn_id]
+    verbose "wait -i $sserver_spawn_id returned $status_list (sserver)"
+    catch "close -i $sserver_spawn_id"
+    if { [lindex $status_list 2] != 0 || [lindex $status_list 3] != 0 } {
+       send_log "exit status: $status_list\n"
+       verbose "exit status: $status_list"
+       fail "sserver"
+    } else {
+       pass "sserver"
+    }
+    # In either case the server shutdown
+    unset sserver_pid
+}
+
+proc test_sclient { msg } {
+    global SCLIENT
+    global hostname
+    global spawn_id
+
+
+    # Test the client
+    spawn $SCLIENT $hostname 3964
+    verbose "sclient_spawn is  $spawn_id" 1
+
+    expect {
+       "sendauth succeeded, reply is:" {
+               verbose "Start proper message"
+       }
+       timeout {
+               fail $msg 
+               return 0
+       }
+       eof {
+               fail $msg 
+               return 0
+       }       
+     }
+
+    expect {
+       "You are krbtest/admin@KRBTEST.COM" {
+               verbose "received valid sample message"}
+       eof {
+               fail $msg 
+               return 0
+           }
+    }
+
+    if ![check_exit_status "ssample"] {
+       return 0
+    }
+
+    return 1
+}
 # We are about to start up a couple of daemon processes.  We do all
 # the rest of the tests inside a proc, so that we can easily kill the
 # processes when the procedure ends.
 
 proc doit { } {
-    global KLIST
-    global KDESTROY
-    global KEY
-    global SSERVER
-    global SCLIENT
     global hostname
-    global tmppwd
-    global spawn_id
+    global KEY
     global sserver_pid
     global sserver_spawn_id
 
@@ -80,60 +164,29 @@ proc doit { } {
        return
     }
 
-    # Start the sserver
-    spawn $SSERVER -p 3964 -S $tmppwd/srvtab
-    set sserver_pid [exp_pid]
-    set sserver_spawn_id $spawn_id
-
-    verbose "sserver_spawn is" $sserver_spawn_id
-
-    # Give sserver some time to start
-    catch "exec sleep 2"
-
-    # Test the client
-    spawn $SCLIENT $hostname 3964
-    expect {
-       "sendauth succeeded, reply is:" {
-               verbose "Start proper message"
-       }
-       timeout {
-               fail "sclient"
-               return
-       }
-       eof {
-               fail "sclient"
-               return
-       }       
+    if ![start_sserver_daemon 0 ] {
+       return 
     }
 
-    expect {
-       "You are krbtest/admin@KRBTEST.COM" {
-               verbose "received valid sample message"}
-       eof {
-               fail "sclient"
-               return 
-           }
+    if ![test_sclient sclient] {
+       return
     }
+    
+    pass "sample - standalone"
 
-    if ![check_exit_status "ssample"] {
-       return
+    stop_check_sserver_daemon
+    
+    if ![start_sserver_daemon 1 ] {
+       return 
     }
-    pass "ssample"
 
-    # Check the exit status of sserver - should exit here
-    set status_list [wait -i $sserver_spawn_id]
-    verbose "wait -i $sserver_spawn_id returned $status_list (sserver)"
-    catch "close -i $sserver_spawn_id"
-    if { [lindex $status_list 2] != 0 || [lindex $status_list 3] != 0 } {
-       send_log "exit status: $status_list\n"
-       verbose "exit status: $status_list"
-       fail "sserver"
-    } else {
-       pass "sserver"
+    if ![test_sclient sclient-inetd] {
+       return
     }
-    # In either case the server shutdown
-    unset sserver_pid
     
+    pass "sample - inetd"
+
+    stop_check_sserver_daemon
     return
 }