Mercurial > dovecot > core-2.2
changeset 18871:69b231fdf5d7
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@dovecot.fi>
author | Phil Carmody <phil@dovecot.fi> |
---|---|
date | Wed, 17 Jun 2015 11:42:30 +0300 |
parents | 9be3fbad33c5 |
children | e7c896eff939 |
files | src/lib/test-data-stack.c |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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; }