diff options
author | Ken Raeburn <raeburn@mit.edu> | 2002-01-09 02:23:35 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2002-01-09 02:23:35 +0000 |
commit | e04dfdb788303c16b30e776d01e25ea70be2ba2e (patch) | |
tree | e59cb311744e534d9d8dea6d92e9b05812895c0a /src/lib/rpc/unit-test | |
parent | 2357579e7d90ab9501620c206e95cfaaa471c0da (diff) | |
download | krb5-e04dfdb788303c16b30e776d01e25ea70be2ba2e.zip krb5-e04dfdb788303c16b30e776d01e25ea70be2ba2e.tar.gz krb5-e04dfdb788303c16b30e776d01e25ea70be2ba2e.tar.bz2 |
do database expansion from tcl driver code
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14097 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/rpc/unit-test')
-rw-r--r-- | src/lib/rpc/unit-test/ChangeLog | 8 | ||||
-rw-r--r-- | src/lib/rpc/unit-test/Makefile.in | 2 | ||||
-rw-r--r-- | src/lib/rpc/unit-test/lib/helpers.exp | 100 |
3 files changed, 109 insertions, 1 deletions
diff --git a/src/lib/rpc/unit-test/ChangeLog b/src/lib/rpc/unit-test/ChangeLog index 9b25f22..8463dd8 100644 --- a/src/lib/rpc/unit-test/ChangeLog +++ b/src/lib/rpc/unit-test/ChangeLog @@ -1,3 +1,11 @@ +2002-01-08 Ken Raeburn <raeburn@mit.edu> + + * 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 <epeisach@mit.edu> * 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 df937cd..148c3e2 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 c4b76aa..66b4d30 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 |