From: Ken Raeburn Date: Wed, 9 Jan 2002 02:23:35 +0000 (+0000) Subject: do database expansion from tcl driver code X-Git-Tag: krb5-1.3-alpha1~895 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e04dfdb788303c16b30e776d01e25ea70be2ba2e;p=krb5.git do database expansion from tcl driver code git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14097 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/rpc/unit-test/ChangeLog b/src/lib/rpc/unit-test/ChangeLog index 9b25f22f0..8463dd8f3 100644 --- a/src/lib/rpc/unit-test/ChangeLog +++ b/src/lib/rpc/unit-test/ChangeLog @@ -1,3 +1,11 @@ +2002-01-08 Ken Raeburn + + * lib/helpers.exp (set_from_env, expect_tcl_prompt, + send_tcl_cmd_await_echo, expect_kadm_ok, setup_database): New + procs. + (top level): Do database setup here... + * Makefile.in (unit-test-setup): ...not here. + 2001-07-26 Ezra Peisach * client.c: Change local variable count from int to unsigned int. diff --git a/src/lib/rpc/unit-test/Makefile.in b/src/lib/rpc/unit-test/Makefile.in index df937cd1b..148c3e20e 100644 --- a/src/lib/rpc/unit-test/Makefile.in +++ b/src/lib/rpc/unit-test/Makefile.in @@ -54,7 +54,7 @@ unit-test-body: unit-test-setup:: $(ENV_SETUP) $(START_SERVERS) - RPC_TEST_SRVTAB=/tmp/rpc_test_v5srvtab $(ENV_SETUP) $(srcdir)/rpc_test_setup.sh +# RPC_TEST_SRVTAB=/tmp/rpc_test_v5srvtab $(ENV_SETUP) $(srcdir)/rpc_test_setup.sh unit-test-cleanup:: $(ENV_SETUP) $(STOP_SERVERS) diff --git a/src/lib/rpc/unit-test/lib/helpers.exp b/src/lib/rpc/unit-test/lib/helpers.exp index c4b76aa0c..66b4d3054 100644 --- a/src/lib/rpc/unit-test/lib/helpers.exp +++ b/src/lib/rpc/unit-test/lib/helpers.exp @@ -16,6 +16,106 @@ if {$exp_version_4} { set wait_status_index 3 } +proc set_from_env {varname default_value} { + global env + upvar $varname v + + if [info exists env($varname)] { + set v $env($varname) + } else { + set v $default_value + } +} +proc expect_tcl_prompt {} { + global kadmin_tcl_spawn_id + expect { + -i $kadmin_tcl_spawn_id + "^% " { } + -re . { error "unexpected output {$expect_out(buffer)} from subprocess, expecting tcl prompt" } + timeout { perror "timeout waiting for tcl prompt" } + eof { perror "eof from subprocess when expecting tcl prompt" } + } +} +proc send_tcl_cmd_await_echo {cmd} { + global kadmin_tcl_spawn_id + send -i $kadmin_tcl_spawn_id "$cmd\n" + expect { + -i $kadmin_tcl_spawn_id + -ex "$cmd\r\n" { } + timeout { perror "timeout waiting for tcl subprocess to echo input" } + eof { perror "eof waiting for tcl subprocess to echo input" } + } +} +proc expect_kadm_ok {} { + global kadmin_tcl_spawn_id + expect { + -i $kadmin_tcl_spawn_id + -re "^OK OVSEC_KADM_OK \[^\n\]*\n" {} + default { error "didn't get ok back" } + } +} +# trying to translate rpc_test_setup.sh into inline tcl... +proc setup_database {} { + global env spawn_id kadmin_tcl_spawn_id TESTDIR MAKE_KEYTAB CANON_HOST + + # XXXXX + set_from_env TOP {/x/x/x/x/x} + send_user "TOP=$TOP\n" + + set_from_env TESTDIR $env(TOP)/testing + set_from_env CLNTTCL $TESTDIR/util/ovsec_kadm_clnt_tcl + set_from_env TCLUTIL $TESTDIR/tcl/util.t + set env(TCLUTIL) $TCLUTIL + set_from_env MAKE_KEYTAB $TESTDIR/scripts/make-host-keytab.pl + set env(PATH) "$TOP/install/admin:$env(PATH)" + + # $VERBOSE ? + + if [info exists spawn_id] { set x $spawn_id } + spawn $CLNTTCL + set kadmin_tcl_spawn_id $spawn_id + if [info exists x] { set spawn_id $x } + + expect_tcl_prompt + send_tcl_cmd_await_echo "source {$TCLUTIL}" + expect_tcl_prompt + send_tcl_cmd_await_echo "set h {$CANON_HOST}" + expect { + -ex "$CANON_HOST\r\n" { } + timeout { perror "timeout waiting for subprocess" } + eof { perror "eof from subprocess" } + } + expect_tcl_prompt + + send_tcl_cmd_await_echo {ovsec_kadm_init admin admin $OVSEC_KADM_ADMIN_SERVICE null $OVSEC_KADM_STRUCT_VERSION $OVSEC_KADM_API_VERSION_1 server_handle} + expect_kadm_ok + expect "^% " + send_tcl_cmd_await_echo {ovsec_kadm_create_principal $server_handle [simple_principal server/$h] {OVSEC_KADM_PRINCIPAL} admin} + expect_kadm_ok + expect "^% " + send_tcl_cmd_await_echo {ovsec_kadm_randkey_principal $server_handle server/$h key} + expect_kadm_ok + expect "^% " + send_tcl_cmd_await_echo {ovsec_kadm_create_principal $server_handle [simple_principal notserver/$h] {OVSEC_KADM_PRINCIPAL} admin} + expect_kadm_ok + expect "^% " + send_tcl_cmd_await_echo {ovsec_kadm_randkey_principal $server_handle notserver/$h key} + expect_kadm_ok + expect "^% " + send_tcl_cmd_await_echo {ovsec_kadm_destroy $server_handle} + expect_kadm_ok + expect "^% " + wait -nowait -i $spawn_id + close -i $spawn_id +} + +if ![info exists CANON_HOST] { + set CANON_HOST [exec $env(QUALNAME)] + setup_database + file delete $env(RPC_TEST_SRVTAB) + exec $env(MAKE_KEYTAB) -princ "server/$CANON_HOST" $env(RPC_TEST_SRVTAB) +} + proc kinit {princ pass lifetime} { global kinit