* changes to use runtest --srcdir:
authorBarry Jaspan <bjaspan@mit.edu>
Mon, 23 Sep 1996 20:34:32 +0000 (20:34 +0000)
committerBarry Jaspan <bjaspan@mit.edu>
Mon, 23 Sep 1996 20:34:32 +0000 (20:34 +0000)
- Makefile.in: rewrote [csapi].* links to work in srcdir (boo,
  hiss)
- move lib.t to lib/lib.t
- api.*/*.exp: s/source lib.t/load_lib lib.t/

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

34 files changed:
src/lib/kadm5/unit-test/ChangeLog
src/lib/kadm5/unit-test/Makefile.in
src/lib/kadm5/unit-test/api.0/chpass-principal.exp
src/lib/kadm5/unit-test/api.0/crte-policy.exp
src/lib/kadm5/unit-test/api.0/crte-principal.exp
src/lib/kadm5/unit-test/api.0/destroy.exp
src/lib/kadm5/unit-test/api.0/dlte-policy.exp
src/lib/kadm5/unit-test/api.0/dlte-principal.exp
src/lib/kadm5/unit-test/api.0/get-policy.exp
src/lib/kadm5/unit-test/api.0/get-principal.exp
src/lib/kadm5/unit-test/api.0/init.exp
src/lib/kadm5/unit-test/api.0/mod-policy.exp
src/lib/kadm5/unit-test/api.0/mod-principal.exp
src/lib/kadm5/unit-test/api.0/randkey-principal.exp
src/lib/kadm5/unit-test/api.0/rename-principal.exp
src/lib/kadm5/unit-test/api.1/lock.exp
src/lib/kadm5/unit-test/api.2/chpass-principal-v2.exp
src/lib/kadm5/unit-test/api.2/chpass-principal.exp
src/lib/kadm5/unit-test/api.2/crte-policy.exp
src/lib/kadm5/unit-test/api.2/crte-principal.exp
src/lib/kadm5/unit-test/api.2/destroy.exp
src/lib/kadm5/unit-test/api.2/dlte-policy.exp
src/lib/kadm5/unit-test/api.2/dlte-principal.exp
src/lib/kadm5/unit-test/api.2/get-policy.exp
src/lib/kadm5/unit-test/api.2/get-principal-v2.exp
src/lib/kadm5/unit-test/api.2/get-principal.exp
src/lib/kadm5/unit-test/api.2/init-v2.exp
src/lib/kadm5/unit-test/api.2/init.exp
src/lib/kadm5/unit-test/api.2/mod-policy.exp
src/lib/kadm5/unit-test/api.2/mod-principal.exp
src/lib/kadm5/unit-test/api.2/randkey-principal-v2.exp
src/lib/kadm5/unit-test/api.2/randkey-principal.exp
src/lib/kadm5/unit-test/config/unix.exp
src/lib/kadm5/unit-test/lib/lib.t [new file with mode: 0644]

index 1e58383c148398ff46e603208a815d408ed0f0de..1f8057854105c476d12b684e8bc340ddf024d638 100644 (file)
@@ -1,3 +1,11 @@
+Mon Sep 23 16:31:24 1996  Barry Jaspan  <bjaspan@mit.edu>
+
+       * changes to use runtest --srcdir:
+       - Makefile.in: rewrote [csapi].* links to work in srcdir (boo,
+       hiss)
+       - move lib.t to lib/lib.t
+       - api.*/*.exp: s/source lib.t/load_lib lib.t/
+       
 Fri Sep 20 16:51:26 1996  Barry Jaspan  <bjaspan@mit.edu>
 
        * created Makefile.in and configure.in
index 3544beea7d1456d991f31abcc7e7e356e6e8a023..915c70ebe30674249622042784d9e67f93210d6c 100644 (file)
@@ -87,28 +87,41 @@ unit-test-server-setup::
 unit-test-server-cleanup::
        $(ENV_SETUP) $(STOP_SERVERS_LOCAL)
 
-capi.0: api.0
-       -rm -f capi.0
-       ln -s api.0 capi.0
-
-capi.2: api.2
-       -rm -f capi.2
-       ln -s api.2 capi.2
-
 unit-test-client-body: capi.0 capi.2 site.exp test-noauth test-destroy test-handle-client test-sizes
        $(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
 
-sapi.0: api.0
-       -rm -f sapi.0
-       ln -s api.0 sapi.0
+#
+# 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: api.1
-       -rm -f sapi.1
-       ln -s api.1 sapi.1
+sapi.1: $(srcdir)/api.1
+       -rm -f $(srcdir)/sapi.1
+       ln -s $(srcdir)/api.1 $(srcdir)/sapi.1
 
-sapi.2: api.2
-       -rm -f sapi.2
-       ln -s api.2 sapi.2
+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 test-sizes
        $(ENV_SETUP) $(RUNTEST) --tool sapi API=$(SRVTCL) LOCKTEST=./lock-test KADMIN_LOCAL=$(BUILDTOP)/kadmin/cli/kadmin.local RPC=0
index 12fa3b9d160d4f41c5b595d11941ed732bcbb81d..6e69e5700a8fa2cb1f2a349a1f5731f7d6fa3a64 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index dbf4f1cbc10d3a42550ad3bc57379ed729817b02..685631b06472c2fabc1170008543ae1de56b58ad 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 12c300793a9fdebd488dbea75733f712e58bdb62..7e2c65d03aba3333570c56d65057a5d005af70fe 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 31b844786124432def9033a86818e661d0098aa7..a8572518d53b9180016968d6d387d78332b109eb 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 7f349b02cdeb93f5db3e792c3cab58e580157591..28ab827d39b865e5012e29353b42d391c94095ab 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index bb52301df3befdd22844c29785c4c0d6802c11af..255252eac55c1e5038cf61ac275a97a465943a58 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 
 api_exit
 api_start
index 329e7886abff32ed97f8290536046219235e328e..813bf3899f37314413e624539223e056a997830a 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 05937055eb2d4642cc9cd5d879d52f09ca7ab9ec..83c86b3fd4e32dfcd52b2c85816232c915acd9c7 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 03b9284fdbeb793a1fd426ae080919c6851818bb..08fed8b18444f75d1b20b98c3322e413889b21ee 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 
 # Assumptions:
 # 
index 67f8457b6a9feda4a731b34e6f902cb8e8e7d034..c0dd93e641badf5757ca20949ead57213966c50e 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index c4bc2bed18b406d7f0522f0535c8c11c15260a2a..0577e580034b1711aa0d35a869905a0fc0ee136c 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 259cd8f03135b473d417860758eaed0914564bb2..1a10ad57834966b2f1c9086e23f81d6aa26010c2 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 56e41295526959dd5fe2235ca49c2b3d68231ae9..c318249afb56b99ed1de3819b7a3b26f7aa8fc7b 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 504a110ad485bcb1f9170de94197a4b0175b696a..d6d3faf4d74800249ea535eb59e4029888693a65 100644 (file)
@@ -3,7 +3,7 @@
 # (whichs runs through all api tests) will still have it locked, and
 # these tests will fail.
 
-source lib.t
+load_lib lib.t
 
 api_exit
 
index 88aed8bca9950124cc71dc9fe6d2ab8c3b894f1a..40a78c9858a7d36a5d7f6f09bac7eb61f43f640a 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 3efdfa9b90f0cddf77afb267826395fa73818a4d..c4ac30f6b10e991bba7b00b945e00119a1a4e2cf 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index b0ea04630ded40d3aae1df12340328df303cded6..273af3fa6ee3bbcc88948f4c3ca71c4f6e7cc613 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 653d1222a8700c067d3b6929f03f251ca93f8542..e4731f8285b23977440148f5d41112a57fceb69a 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 808f0b401c4720abe8599b1cf34e1b3be800cc65..5de40ef03e42f590a2ed692d5796c023f917bce4 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 95a57dc201a4f8c05d33496393c3c84acd868564..8fdea0b0467a46499f29a88e3ce06bf8ac789d21 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index fe157e880be94b2bbfdc011535c39f673a446711..43a4238a40b0ace2a6f52d678e3f53c306336621 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 
 api_exit
 api_start
index ff41c17b9bac78d46738799a39d8a7528d925e06..5afece9dc3a9debc6655a82d9d3598dc2a2e7677 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 486d1a6ab3d8d17452b507da71352dfbef77e861..191a2f3dff7abd739ffe4cb2445a17754f9dbed4 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 4f91b33bb24d0383e1958372f6c357cdf6605888..6d33910022ec8e61eb232ecbc0985b44c0c74f3c 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 61736b80ff1a245bffdca367a3a1cf116837a814..140ff86e8fc9d4ca8f001982105ac4f357cb91c2 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 
 api_exit
 api_start
index ef9573c6709b0e2e28209a21893100b9ffbd9ad8..9707d3bf31bb930aaf1135b033893a1956a54d06 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 
 # Assumptions:
 # 
index 07e2e62dbf275e0d52168570f566469de1c64cb1..4ca0e3e8536da94b6a078c958eae3c3764474225 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 5e24e08b02ab22cd19a301598d01a5602280ace9..d7713909d348194f07344ad3bfc5e1cb04db5fa3 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index c3dfd18df5e3a4ddbf02c0139b7abdbf00246353..5c8fdc5e50e2bbf34104d6f7ae825956eefdb631 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index d693a2ac1e3760ab634598520afd6de5570566aa..fb11c4801f3a2751adb4b68138c5e3125b212676 100644 (file)
@@ -1,4 +1,4 @@
-source lib.t
+load_lib lib.t
 api_exit
 api_start
 
index 7b8e2ea4f75cf7870a937e9c10e4b85578c6e48d..ed576ce3582541c202cafd16b2079cbc4269a950 100644 (file)
@@ -1,3 +1,4 @@
+set prompt "% "
 set stty_init {-onlcr -opost intr \^C kill \^U}
 set kadmin_local $KADMIN_LOCAL
 
diff --git a/src/lib/kadm5/unit-test/lib/lib.t b/src/lib/kadm5/unit-test/lib/lib.t
new file mode 100644 (file)
index 0000000..110514d
--- /dev/null
@@ -0,0 +1,367 @@
+global timeout
+set timeout 60
+
+proc cmd {command} {
+    global prompt
+    global spawn_id
+    global test
+
+    send "[string trim $command]\n"
+    expect {
+       -re "OK .*$prompt$" { return 1 }
+        -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 }
+    }
+}
+
+proc tcl_cmd {command} {
+    global prompt
+    global spawn_id
+
+    send "[string trim $command]\n"
+    expect {
+       -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 }
+    }
+}
+
+proc one_line_succeed_test {command} {
+    global prompt
+    global spawn_id
+    global test
+
+    send "[string trim $command]\n"
+    expect {
+       -re "OK .*$prompt$"             { pass "$test"; return 1 }
+       -re "ERROR .*$prompt$" { 
+               fail "$test: $expect_out(buffer)"; 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 }
+    }
+}
+
+proc one_line_fail_test {command code} {
+    global prompt
+    global spawn_id
+    global test
+
+    send "[string trim $command]\n"
+    expect {
+       -re "ERROR .*$code.*$prompt$"   { pass "$test"; return 1 }
+       -re "ERROR .*$prompt$"  { fail "$test: bad failure"; 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 }
+    }
+}
+
+proc one_line_fail_test_nochk {command} {
+    global prompt
+    global spawn_id
+    global test
+
+    send "[string trim $command]\n"
+    expect {
+       -re "ERROR .*$prompt$"  { pass "$test:"; return 1 }
+       -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 }
+    }
+}
+
+proc resync {} {
+    global prompt
+    global spawn_id
+
+    expect {
+       -re "$prompt$"  {}
+       "wrong # args" { error "$test: wrong number args"; return 0 }
+       eof { api_exit; api_start }
+    }
+}
+
+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}
+
+    api_exit
+    api_start
+
+    return $ret
+}
+
+proc create_policy {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_policy $server_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
+
+    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" \
+                   "%s"] {OVSEC_KADM_PRINCIPAL OVSEC_KADM_POLICY} "%s"
+       } $name $policy $name]]
+    }]
+
+    cmd {ovsec_kadm_destroy $server_handle}
+
+    api_exit
+    api_start
+
+    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}
+
+    api_exit
+    api_start
+
+    return $ret
+}
+
+proc delete_policy {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_policy $server_handle "%s"} $name]]
+    }]
+
+    cmd {ovsec_kadm_destroy $server_handle}
+
+    api_exit
+    api_start
+
+    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}
+
+    api_exit
+    api_start
+
+#    puts stdout "Finishing principal_exists."
+
+    return $ret
+}
+
+proc policy_exists {name} {
+    api_exit
+    api_start
+
+#    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
+       } $name]]
+    }]
+
+    cmd {ovsec_kadm_destroy $server_handle}
+
+    api_exit
+    api_start
+
+#    puts stdout "Finishing policy_exists."
+
+    return $ret
+}
+
+proc error_and_restart {error} {
+    api_exit
+    api_start
+    error $error
+}
+
+proc test {name} {
+   global test verbose
+
+   set test $name
+   if {$verbose >= 1} {
+       puts stdout "At $test"
+   }
+}
+
+proc begin_dump {} {
+    global TOP
+    global RPC
+    
+    if { ! $RPC } {
+#      exec $env(SIMPLE_DUMP) > /tmp/dump.before
+    }
+}
+
+proc end_dump_compare {name} {
+    global  file
+    global  TOP
+    global  RPC
+
+    if { ! $RPC } { 
+#      set file $TOP/admin/lib/unit-test/diff-files/$name
+#      exec $env(SIMPLE_DUMP) > /tmp/dump.after
+#      exec $env(COMPARE_DUMP) /tmp/dump.before /tmp/dump.after $file
+    }
+}
+
+proc kinit { princ pass {opts ""} } {
+       global env;
+        global KINIT
+
+       eval spawn $KINIT $opts $princ
+       expect {
+               -re {Password for .*: $}
+                   {send "$pass\n"}
+               timeout {puts "Timeout waiting for prompt" ; close }
+       }
+
+       # this necessary so close(1) in the child will not sleep waiting for
+       # the parent, which is us, to read pending data.
+
+       expect {
+               eof {}
+       }
+       wait
+}
+
+proc kdestroy {} {
+        global KDESTROY
+       global errorCode errorInfo
+       global env
+
+       if {[info exists errorCode]} {
+               set saveErrorCode $errorCode
+       }
+       if {[info exists errorInfo]} {
+               set saveErrorInfo $errorInfo
+       }
+       catch "system $KDESTROY 2>/dev/null"
+       if {[info exists saveErrorCode]} {
+               set errorCode $saveErrorCode
+       } elseif {[info exists errorCode]} {
+               unset errorCode
+       }
+       if {[info exists saveErrorInfo]} {
+               set errorInfo $saveErrorInfo
+       } elseif {[info exists errorInfo]} {
+               unset errorInfo
+       }
+}
+
+proc create_principal_with_keysalts {name keysalts} {
+    global kadmin_local
+
+    spawn $kadmin_local -e "$keysalts"
+    expect {
+       "kadmin.local:" {}
+       default { error "waiting for kadmin.local prompt"; return 1}
+    }
+    send "ank -pw \"$name\" \"$name\"\n"
+    expect {
+       -re "Principal \"$name.*\" created." {}
+       "kadmin.local:" {
+           error "expecting principal created message"; 
+           return 1
+       }
+       default { error "waiting for principal created message"; return 1 }
+    }
+    expect {
+       "kadmin.local:" {}
+       default { error "waiting for kadmin.local prompt"; return 1 }
+    }
+    close
+    wait
+    return 0
+}
+
+