From: Barry Jaspan Date: Thu, 17 Oct 1996 20:21:19 +0000 (+0000) Subject: * config/unix.exp, lib/lib.t: begin in process of making these X-Git-Tag: krb5-1.0-freeze1~234 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7a0553ec1d296df83a2e6660aae44a1115f9ea2c;p=krb5.git * 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] git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9188 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kadm5/unit-test/ChangeLog b/src/lib/kadm5/unit-test/ChangeLog index 997b41086..d304338eb 100644 --- a/src/lib/kadm5/unit-test/ChangeLog +++ b/src/lib/kadm5/unit-test/ChangeLog @@ -1,3 +1,15 @@ +Thu Oct 17 16:14:11 1996 Barry Jaspan + + * 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 * Makefile.in: Only try to run tests if both runtest and the tcl diff --git a/src/lib/kadm5/unit-test/Makefile.in b/src/lib/kadm5/unit-test/Makefile.in index c2fb0c403..1b65576ca 100644 --- a/src/lib/kadm5/unit-test/Makefile.in +++ b/src/lib/kadm5/unit-test/Makefile.in @@ -86,44 +86,20 @@ unit-test-server-setup:: 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 diff --git a/src/lib/kadm5/unit-test/api.0/crte-principal.exp b/src/lib/kadm5/unit-test/api.0/crte-principal.exp index 7e2c65d03..a3f69b978 100644 --- a/src/lib/kadm5/unit-test/api.0/crte-principal.exp +++ b/src/lib/kadm5/unit-test/api.0/crte-principal.exp @@ -868,10 +868,13 @@ proc test32 {} { 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 @@ -1090,10 +1093,13 @@ proc test36 {} { 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 diff --git a/src/lib/kadm5/unit-test/api.0/mod-principal.exp b/src/lib/kadm5/unit-test/api.0/mod-principal.exp index 0577e5800..f80dede0e 100644 --- a/src/lib/kadm5/unit-test/api.0/mod-principal.exp +++ b/src/lib/kadm5/unit-test/api.0/mod-principal.exp @@ -924,8 +924,6 @@ test "modify-principal 24" 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" ])} { @@ -997,9 +995,11 @@ proc test24 {} { 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" @@ -1159,7 +1159,7 @@ proc test28 {} { } 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 @@ -1211,8 +1211,8 @@ proc test28 {} { 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" diff --git a/src/lib/kadm5/unit-test/api.2/crte-principal.exp b/src/lib/kadm5/unit-test/api.2/crte-principal.exp index e4731f828..85b2da2c4 100644 --- a/src/lib/kadm5/unit-test/api.2/crte-principal.exp +++ b/src/lib/kadm5/unit-test/api.2/crte-principal.exp @@ -868,9 +868,11 @@ proc test32 {} { 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" @@ -1090,10 +1092,13 @@ proc test36 {} { 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 diff --git a/src/lib/kadm5/unit-test/api.2/mod-principal.exp b/src/lib/kadm5/unit-test/api.2/mod-principal.exp index d7713909d..eebeb1425 100644 --- a/src/lib/kadm5/unit-test/api.2/mod-principal.exp +++ b/src/lib/kadm5/unit-test/api.2/mod-principal.exp @@ -924,8 +924,6 @@ test "modify-principal 24" 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" ])} { @@ -997,9 +995,11 @@ proc test24 {} { 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" @@ -1159,7 +1159,7 @@ proc test28 {} { } 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 @@ -1211,8 +1211,8 @@ proc test28 {} { 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" diff --git a/src/lib/kadm5/unit-test/config/unix.exp b/src/lib/kadm5/unit-test/config/unix.exp index ed576ce35..07a91fd31 100644 --- a/src/lib/kadm5/unit-test/config/unix.exp +++ b/src/lib/kadm5/unit-test/config/unix.exp @@ -14,25 +14,42 @@ if {[info exists exp_version_4]} { 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" } @@ -107,7 +124,10 @@ proc api_start {} { 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 diff --git a/src/lib/kadm5/unit-test/lib/lib.t b/src/lib/kadm5/unit-test/lib/lib.t index 110514de8..4a1c86747 100644 --- a/src/lib/kadm5/unit-test/lib/lib.t +++ b/src/lib/kadm5/unit-test/lib/lib.t @@ -1,6 +1,36 @@ 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 @@ -12,7 +42,7 @@ proc cmd {command} { -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 } } } @@ -25,7 +55,7 @@ proc tcl_cmd {command} { -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 } } } @@ -42,7 +72,7 @@ proc one_line_succeed_test {command} { } "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 } } } @@ -58,7 +88,7 @@ proc one_line_fail_test {command code} { -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 } } } @@ -73,7 +103,7 @@ proc one_line_fail_test_nochk {command} { -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 } } } @@ -84,174 +114,83 @@ proc resync {} { 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."