+Thu Oct 17 16:14:11 1996 Barry Jaspan <bjaspan@mit.edu>
+
+ * config/unix.exp, lib/lib.t: begin in process of making these
+ unit tests less horribly inefficient
+
+ * api.[02]/crte-principal.exp, api.[02].mod-principal: update unit
+ tests for new pw_expiration semantics [krb5-admin/87]
+
+ * Makefile.in: ditch the capi and sapi hack, just the api for
+ everything, and rename the log files after the tests complete so
+ they are both kept around for viewing [krb5-admin/82]
+
Mon Oct 14 07:04:27 1996 Ezra Peisach <epeisach@kangaroo.mit.edu>
* Makefile.in: Only try to run tests if both runtest and the tcl
unit-test-server-cleanup::
$(ENV_SETUP) $(STOP_SERVERS_LOCAL)
-unit-test-client-body: capi.0 capi.2 site.exp test-noauth test-destroy test-handle-client
- $(ENV_SETUP) $(RUNTEST) --tool capi API=$(CLNTTCL) KINIT=$(BUILDTOP)/clients/kinit/kinit KDESTROY=$(BUILDTOP)/clients/kdestroy/kdestroy KADMIN_LOCAL=$(BUILDTOP)/kadmin/cli/kadmin.local RPC=1
-
-#
-# This is unfortunate. We want to have a single set of directories
-# api.* but treat them as two separate tools (capi and sapi). We
-# specify --srcdir in $(RUNTEST) so that unit tests files do not need
-# to exist as symlinks in the source tree. However, we can't check in
-# the capi and sapi symlinks into CVS. Therefore, we need to create
-# them *in the source tree* at run time.
-#
-# Another alternative would be to run $(RUNTEST) without --srcdir in
-# this one directory, or just stop using a separate tool name for
-# client and server tests; that would prevent us from keeping the
-# separate log files around, and might bite us in the future.
-#
-capi.0: $(srcdir)/api.0
- -rm -f $(srcdir)/capi.0
- ln -s $(srcdir)/api.0 $(srcdir)/capi.0
-
-capi.2: $(srcdir)/api.2
- -rm -f $(srcdir)/capi.2
- ln -s $(srcdir)/api.2 $(srcdir)/capi.2
-
-sapi.0: $(srcdir)/api.0
- -rm -f $(srcdir)/sapi.0
- ln -s $(srcdir)/api.0 $(srcdir)/sapi.0
-
-sapi.1: $(srcdir)/api.1
- -rm -f $(srcdir)/sapi.1
- ln -s $(srcdir)/api.1 $(srcdir)/sapi.1
-
-sapi.2: $(srcdir)/api.2
- -rm -f $(srcdir)/sapi.2
- ln -s $(srcdir)/api.2 $(srcdir)/sapi.2
-
-unit-test-server-body: sapi.0 sapi.1 sapi.2 site.exp randkey-test test-handle-server lock-test
- $(ENV_SETUP) $(RUNTEST) --tool sapi API=$(SRVTCL) LOCKTEST=./lock-test KADMIN_LOCAL=$(BUILDTOP)/kadmin/cli/kadmin.local RPC=0
+unit-test-client-body: site.exp test-noauth test-destroy test-handle-client
+ $(ENV_SETUP) $(RUNTEST) --tool api RPC=1 API=$(CLNTTCL) \
+ KINIT=$(BUILDTOP)/clients/kinit/kinit \
+ KDESTROY=$(BUILDTOP)/clients/kdestroy/kdestroy \
+ KADMIN_LOCAL=$(BUILDTOP)/kadmin/cli/kadmin.local
+ -mv api.log capi.log
+ -mv api.sum capi.sum
+
+unit-test-server-body: site.exp randkey-test test-handle-server lock-test
+ $(ENV_SETUP) $(RUNTEST) --tool api RPC=0 API=$(SRVTCL) \
+ LOCKTEST=./lock-test \
+ KADMIN_LOCAL=$(BUILDTOP)/kadmin/cli/kadmin.local
+ -mv api.log sapi.log
+ -mv api.sum sapi.sum
clean::
$(RM) init-test client_init.o init-test.o
return
}
}
- if { [expr "$mod_date + $pw_max_life - $pw_expire"] > 5 } {
- fail "$test: pw_expire is wrong"
+ if { $pw_expire != 0 } {
+ fail "$test: pw_expire $pw_expire should be 0"
return
+ } else {
+ pass "$test"
}
+
if { ! [cmd {ovsec_kadm_destroy $server_handle}]} {
error "$test: unexpected failure in destroy"
return
return
}
}
- if { [expr "$mod_date + $pw_max_life - $pw_expire"] > 5 } {
- fail "$test: pw_expire is wrong"
+ if { $pw_expire != 999999999 } {
+ fail "$test: pw_expire $pw_expire should be 999999999"
return
+ } else {
+ pass "$test"
}
+
if { ! [cmd {ovsec_kadm_destroy $server_handle}]} {
error "$test: unexpected failure in destroy"
return
proc test24 {} {
global test
global prompt
-# set prms_id 1358
-# setup_xfail {*-*-*} $prms_id
if {! (( [principal_exists "$test/a"]) ||
[create_principal_pol "$test/a" "test-pol" ])} {
return
}
}
- if { [expr "$pw_mod_date + $pw_max_life"] != $pw_expire } {
- fail "$test: pw_expire is wrong"
+ if { $pw_expire != 0 } {
+ fail "$test: pw_expire $pw_expire should be 0"
return
+ } else {
+ pass "$test"
}
if { ! [cmd {ovsec_kadm_destroy $server_handle}]} {
error "$test: unexpected failure in destroy"
}
if { ! [cmd [format {
ovsec_kadm_modify_principal $server_handle \
- {"%s/a" 0 0 900 0 0 0 0 0 0 0 0} {OVSEC_KADM_PW_EXPIRATION}
+ {"%s/a" 0 0 999999999 0 0 0 0 0 0 0 0} {OVSEC_KADM_PW_EXPIRATION}
} $test]]} {
fail "$test: modify failed"
return
return
}
}
- if { [expr "$pw_mod_date + $pw_max_life"] == $pw_expire } {
- fail "$test: pw_expire is wrong"
+ if { $pw_expire != 999999999 } {
+ fail "$test: pw_expire $pw_expire should be 999999999"
return
}
pass "$test"
return
}
}
- if { [expr "$mod_date + $pw_max_life - $pw_expire"] > 5 } {
- fail "$test: pw_expire is wrong"
+ if { $pw_expire != 0 } {
+ fail "$test: pw_expire $pw_expire should be 0"
return
+ } else {
+ pass "$test"
}
if { ! [cmd {kadm5_destroy $server_handle}]} {
error "$test: unexpected failure in destroy"
return
}
}
- if { [expr "$mod_date + $pw_max_life - $pw_expire"] > 5 } {
+ if { $pw_expire != 999999999 } {
fail "$test: pw_expire is wrong"
return
+ } else {
+ pass "$test"
}
+
if { ! [cmd {kadm5_destroy $server_handle}]} {
error "$test: unexpected failure in destroy"
return
proc test24 {} {
global test
global prompt
-# set prms_id 1358
-# setup_xfail {*-*-*} $prms_id
if {! (( [principal_exists "$test/a"]) ||
[create_principal_pol "$test/a" "test-pol" ])} {
return
}
}
- if { [expr "$pw_mod_date + $pw_max_life"] != $pw_expire } {
- fail "$test: pw_expire is wrong"
+ if { $pw_expire != 0 } {
+ fail "$test: pw_expire $pw_expire should be 0"
return
+ } else {
+ pass "$test"
}
if { ! [cmd {kadm5_destroy $server_handle}]} {
error "$test: unexpected failure in destroy"
}
if { ! [cmd [format {
kadm5_modify_principal $server_handle \
- {"%s/a" 0 0 900 0 0 0 0 0 0 0 0} {KADM5_PW_EXPIRATION}
+ {"%s/a" 0 0 999999999 0 0 0 0 0 0 0 0} {KADM5_PW_EXPIRATION}
} $test]]} {
fail "$test: modify failed"
return
return
}
}
- if { [expr "$pw_mod_date + $pw_max_life"] == $pw_expire } {
- fail "$test: pw_expire is wrong"
+ if { $pw_expire != 999999999 } {
+ fail "$test: pw_expire $pw_expire should be 999999999"
return
}
pass "$test"
set wait_status_index 3
}
+# Variables for keeping track of api process state
+set api_pid "0"
+
proc api_exit {} {
global spawn_id
+ global api_pid
# puts stdout "Starting api_exit (spawn_id $spawn_id)."
catch {close} errMsg
catch {wait} errMsg
-# puts stdout "Finishing api_exit."
+ puts stdout "Finishing api_exit for $api_pid."
+ set api_pid "0"
+}
+
+proc api_isrunning {pid} {
+ global api_pid
+
+# puts stdout "testing $pid, api_pid is $api_pid"
+ if {$pid == $api_pid} {
+ return 1;
+ } else {
+ return 0;
+ }
}
proc api_version {} {
}
proc api_start {} {
- global API
+ global API
global env
global spawn_id
global prompt
+ global api_pid
- spawn $API
+ set pid [spawn $API]
expect {
-re "$prompt$" {}
eof { error "EOF starting API" }
eof { error "EOF setting API varibles"}
timeout { error "timeout setting API varibles"}
}
-# puts stdout "Finishing api_start (spawn_id $spawn_id)."
+
+ set api_pid $pid
+ puts stdout "Finishing api_start (spawn_id $spawn_id, pid $api_pid)."
+ return $pid
}
api_start
global timeout
set timeout 60
+set lib_pid 0
+
+#
+# The functions in this library used to be responsible for bazillions
+# of wasted api_starts. Now, they all just use their own library
+# handle so they are not interrupted when the main tests call init or
+# destroy. They have to keep track of when the api exists and
+# restarts, though, since the lib_handle needs to be re-opened in that
+# case.
+#
+proc lib_start_api {} {
+ global spawn_id lib_pid
+
+ if {! [api_isrunning $lib_pid]} {
+ api_exit
+ set lib_pid [api_start]
+ if {! [cmd {
+ ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \
+ $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \
+ lib_handle
+ }]} {
+ error "$test: unexpected failure in init"
+ return
+ }
+ puts stdout "--- restarted api ($lib_pid) for lib"
+ } else {
+ puts stdout "+++ api $lib_pid already running for lib"
+ }
+}
+
proc cmd {command} {
global prompt
global spawn_id
-re "ERROR .*$prompt$" { return 0 }
"wrong # args" { error "$test: wrong number args"; return 0 }
timeout { fail "$test: timeout"; return 0 }
- eof { fail "$test: eof"; api_exit; api_start; return 0 }
+ eof { fail "$test: eof"; api_exit; lib_start_api; return 0 }
}
}
-re "$prompt$" { return 1}
"wrong # args" { error "$test: wrong number args"; return 0 }
timeout { error_and_restart "timeout" }
- eof { api_exit; api_start; return 0 }
+ eof { api_exit; lib_start_api; return 0 }
}
}
}
"wrong # args" { error "$test: wrong number args"; return 0 }
timeout { fail "$test: timeout"; return 0 }
- eof { fail "$test: eof"; api_exit; api_start; return 0 }
+ eof { fail "$test: eof"; api_exit; lib_start_api; return 0 }
}
}
-re "OK .*$prompt$" { fail "$test: bad success"; return 0 }
"wrong # args" { error "$test: wrong number args"; return 0 }
timeout { fail "$test: timeout"; return 0 }
- eof { fail "$test: eof"; api_exit; api_start; return 0 }
+ eof { fail "$test: eof"; api_exit; lib_start_api; return 0 }
}
}
-re "OK .*$prompt$" { fail "$test: bad success"; return 0 }
"wrong # args" { error "$test: wrong number args"; return 0 }
timeout { fail "$test: timeout"; return 0 }
- eof { fail "$test: eof"; api_exit; api_start; return 0 }
+ eof { fail "$test: eof"; api_exit; lib_start_api; return 0 }
}
}
expect {
-re "$prompt$" {}
"wrong # args" { error "$test: wrong number args"; return 0 }
- eof { api_exit; api_start }
+ eof { api_exit; lib_start_api }
}
}
proc create_principal {name} {
- api_exit
- api_start
-
- set ret [expr {
- [cmd {
- ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \
- $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \
- server_handle
- }] &&
- [cmd [format {
- ovsec_kadm_create_principal $server_handle [simple_principal \
- "%s"] {OVSEC_KADM_PRINCIPAL} "%s"
- } $name $name]]
- }]
-
- cmd {ovsec_kadm_destroy $server_handle}
+ lib_start_api
- api_exit
- api_start
+ set ret [cmd [format {
+ ovsec_kadm_create_principal $lib_handle [simple_principal \
+ "%s"] {OVSEC_KADM_PRINCIPAL} "%s"
+ } $name $name]]
return $ret
}
proc create_policy {name} {
- api_exit
- api_start
+ lib_start_api
- set ret [expr {
- [cmd {
- ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \
- $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \
- server_handle
- }] &&
- [cmd [format {
- ovsec_kadm_create_policy $server_handle [simple_policy "%s"] \
+ set ret [cmd [format {
+ ovsec_kadm_create_policy $lib_handle [simple_policy "%s"] \
{OVSEC_KADM_POLICY}
} $name $name]]
- }]
-
- cmd {ovsec_kadm_destroy $server_handle}
-
- api_exit
- api_start
return $ret
}
proc create_principal_pol {name policy} {
- api_exit
- api_start
+ lib_start_api
- set ret [expr {
- [cmd {
- ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \
- $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \
- server_handle
- }] &&
- [cmd [format {
- ovsec_kadm_create_principal $server_handle [princ_w_pol "%s" \
+ set ret [cmd [format {
+ ovsec_kadm_create_principal $lib_handle [princ_w_pol "%s" \
"%s"] {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY} "%s"
- } $name $policy $name]]
- }]
-
- cmd {ovsec_kadm_destroy $server_handle}
-
- api_exit
- api_start
+ } $name $policy $name]]
return $ret
}
proc delete_principal {name} {
- api_exit
- api_start
-
- set ret [expr {
- [cmd {
- ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \
- $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \
- server_handle
- }] &&
- [cmd [format {
- ovsec_kadm_delete_principal $server_handle "%s"
- } $name]]
- }]
-
- cmd {ovsec_kadm_destroy $server_handle}
+ lib_start_api
- api_exit
- api_start
+ set ret [cmd [format {
+ ovsec_kadm_delete_principal $lib_handle "%s"
+ } $name]]
return $ret
}
proc delete_policy {name} {
- api_exit
- api_start
+ lib_start_api
- set ret [expr {
- [cmd {
- ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \
- $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \
- server_handle
- }] &&
- [cmd [format {ovsec_kadm_delete_policy $server_handle "%s"} $name]]
- }]
-
- cmd {ovsec_kadm_destroy $server_handle}
-
- api_exit
- api_start
+ set ret [cmd [format {ovsec_kadm_delete_policy $lib_handle "%s"} $name]]
return $ret
}
proc principal_exists {name} {
- api_exit
- api_start
-
# puts stdout "Starting principal_exists."
- set ret [expr {
- [cmd {
- ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \
- $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \
- server_handle
- }] &&
- [cmd [format {
- ovsec_kadm_get_principal $server_handle "%s" principal
- } $name]]
- }]
-
- cmd {ovsec_kadm_destroy $server_handle}
+ lib_start_api
- api_exit
- api_start
+ set ret [cmd [format {
+ ovsec_kadm_get_principal $lib_handle "%s" principal
+ } $name]]
-# puts stdout "Finishing principal_exists."
+# puts stdout "Finishing principal_exists."
return $ret
}
proc policy_exists {name} {
- api_exit
- api_start
+ lib_start_api
# puts stdout "Starting policy_exists."
- set ret [expr {
- [cmd {
- ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null \
- $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 \
- server_handle
- }] &&
- [cmd [format {
- ovsec_kadm_get_policy $server_handle "%s" policy
+ set ret [cmd [format {
+ ovsec_kadm_get_policy $lib_handle "%s" policy
} $name]]
- }]
-
- cmd {ovsec_kadm_destroy $server_handle}
-
- api_exit
- api_start
# puts stdout "Finishing policy_exists."