Make kgss test processes run in lock-step
authorGreg Hudson <ghudson@mit.edu>
Mon, 27 Jun 2011 22:23:18 +0000 (22:23 +0000)
committerGreg Hudson <ghudson@mit.edu>
Mon, 27 Jun 2011 22:23:18 +0000 (22:23 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@24994 dc483132-0cff-0310-8789-dd5450dbe970

src/util/gss-kernel-lib/t_kgss_common.c
src/util/gss-kernel-lib/t_kgss_common.h
src/util/gss-kernel-lib/t_kgss_kernel.c
src/util/gss-kernel-lib/t_kgss_user.c

index 1b31634c2457e2f8f8763a792ea331b47af9fc29..211cecc2bca7870b1d259aa88026b457cc002bbe 100644 (file)
@@ -82,3 +82,24 @@ read_data(int fd, void **data_out, size_t *len_out)
     *data_out = data;
     *len_out = len;
 }
+
+/*
+ * Acknowledgements are used to make the parent and child processes operate in
+ * lock-step.  That way, if the child fails, the parent isn't several steps
+ * ahead before it finds out.
+ */
+
+void
+send_ack(int fd)
+{
+    rewrite(fd, "ack", 3);
+}
+
+void
+read_ack(int fd)
+{
+    char buf[3];
+
+    reread(fd, buf, 3);
+    assert(memcmp(buf, "ack", 3) == 0);
+}
index 8225bef28f927dcbac84b583a79e48024e012555..edb38886aa8e120d6f1acd55577c910d68db6f16 100644 (file)
@@ -28,3 +28,5 @@ void rewrite(int fd, const void *data, size_t len);
 void reread(int fd, void *buf, size_t len);
 void send_data(int fd, const void *data, size_t len);
 void read_data(int fd, void **data_out, size_t *len_out);
+void send_ack(int fd);
+void read_ack(int fd);
index 0d70f1f386fb90ccd1d94e87be7f2d67c8a03065..f5914f421cf792773ba5f5001bbacda36ef19a80 100644 (file)
@@ -273,12 +273,21 @@ main(int argc, char **argv)
     krb5_c_random_os_entropy(NULL, 0, &dummy);
 
     read_lucid_context(&acceptor);
+    send_ack(STDOUT_FILENO);
     read_wrap_token(acceptor);
+    send_ack(STDOUT_FILENO);
     read_mic_token(acceptor);
+    send_ack(STDOUT_FILENO);
     read_iov_token(acceptor);
+    send_ack(STDOUT_FILENO);
+
     send_wrap_token(acceptor);
+    read_ack(STDIN_FILENO);
     send_mic_token(acceptor);
+    read_ack(STDIN_FILENO);
     send_iov_token(acceptor);
+    read_ack(STDIN_FILENO);
+
     cleanup_context(acceptor);
     return 0;
 }
index 15fca238a561aa939c2258d53850208e0ccb0576..6c4b638413f03c7431e122f97d6a277e8650f1d8 100644 (file)
@@ -378,13 +378,23 @@ main(int argc, char **argv)
 
     establish_contexts(argv[1], &initiator, &acceptor);
     start_child(&to_child, &from_child, &child_pid);
+
     send_lucid_context(acceptor, to_child);
+    read_ack(from_child);
     send_wrap_token(initiator, to_child);
+    read_ack(from_child);
     send_mic_token(initiator, to_child);
+    read_ack(from_child);
     send_iov_token(initiator, to_child);
+    read_ack(from_child);
+
     read_wrap_token(initiator, from_child);
+    send_ack(to_child);
     read_mic_token(initiator, from_child);
+    send_ack(to_child);
     read_iov_token(initiator, from_child);
+    send_ack(to_child);
+
     cleanup_context(initiator);
     close(to_child);
     close(from_child);