dovecot-2.2: lib: test-data-stack - ensure t_push() and t_pop() ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 17 08:45:41 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/69b231fdf5d7
changeset: 18871:69b231fdf5d7
user:      Phil Carmody <phil at dovecot.fi>
date:      Wed Jun 17 11:42:30 2015 +0300
description:
lib: test-data-stack - ensure t_push() and t_pop() are balanced in fatal tests
If the t_pop() unexpectedly succeeds, we won't want to do another one upon
entering the function again.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib/test-data-stack.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r 9be3fbad33c5 -r 69b231fdf5d7 src/lib/test-data-stack.c
--- a/src/lib/test-data-stack.c	Wed Jun 17 11:31:02 2015 +0300
+++ b/src/lib/test-data-stack.c	Wed Jun 17 11:42:30 2015 +0300
@@ -158,13 +158,13 @@
 		/* Presume that we need to clean up from the prior test:
 		   undo the evil write, then we will be able to t_pop cleanly,
 		   and finally we can end the test stanza. */
-		if (things_are_messed_up || undo_ptr == NULL || t_id == 999999999)
+		if (things_are_messed_up || undo_ptr == NULL)
 			return FATAL_TEST_ABORT; /* abort, things are messed up with t_pop */
 		*undo_ptr = undo_data;
 		undo_ptr = NULL;
 		/* t_pop musn't abort, that would cause recursion */
 		things_are_messed_up = TRUE;
-		if (t_pop() != t_id)
+		if (t_id != 999999999 && t_pop() != t_id)
 			return FATAL_TEST_ABORT; /* abort, things are messed up with us */
 		things_are_messed_up = FALSE;
 		t_id = 999999999;
@@ -206,6 +206,7 @@
 		*undo_ptr = '*';
 		/* t_pop will now fail */
 		(void)t_pop();
+		t_id = 999999999; /* We're FUBAR, mustn't pop next entry */
 		return FATAL_TEST_FAILURE;
 	}
 
@@ -218,6 +219,7 @@
 		*undo_ptr = '*';
 		/* t_pop will now fail */
 		(void)t_pop();
+		t_id = 999999999; /* We're FUBAR, mustn't pop next entry */
 		return FATAL_TEST_FAILURE;
 	}
 


More information about the dovecot-cvs mailing list