From 08e22d8ad22e3aea79e79114d388e0828786cfbc Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 28 Jan 2019 05:52:36 +0100 Subject: [PATCH] More cleanup tests test3 wasn't working originally. --- tests/tests2/101_cleanup.c | 40 +++++++++++++++++++++++++++++++-- tests/tests2/101_cleanup.expect | 5 +++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/tests/tests2/101_cleanup.c b/tests/tests2/101_cleanup.c index 4cabf41c..14ff3bd6 100644 --- a/tests/tests2/101_cleanup.c +++ b/tests/tests2/101_cleanup.c @@ -1,5 +1,4 @@ -#include - +extern int printf(const char*, ...); static int glob_i = 0; void incr_glob_i(int *i) @@ -115,6 +114,41 @@ void test_ret2() } } +void test2(void) { + int chk = 0; +again: + if (!chk) { + char * __attribute__ ((cleanup(check2))) stop_that = "test2"; + chk++; + goto again; + } +} + +int test3(void) { + char * __attribute__ ((cleanup(check2))) stop_that = "three"; + int chk = 0; + + if (chk) { + { + outside: + { + char * __attribute__ ((cleanup(check2))) stop_that = "two"; + printf("---- %d\n", chk); + } + } + } + if (!chk) + { + char * __attribute__ ((cleanup(check2))) stop_that = "one"; + + if (!chk) { + chk = 1; + goto outside; + } + } + return 0; +} + int main() { int i __attribute__ ((__cleanup__(check))) = 0, not_i; @@ -138,6 +172,8 @@ int main() printf("because what if free was call inside cleanup function\n", test()); test_ret(); test_ret2(); + test2(); + test3(); return i; } diff --git a/tests/tests2/101_cleanup.expect b/tests/tests2/101_cleanup.expect index d4a35594..a5a76a8a 100644 --- a/tests/tests2/101_cleanup.expect +++ b/tests/tests2/101_cleanup.expect @@ -10,6 +10,11 @@ str: that str: this should appear only once str: -that2 str: -that +str: test2 +str: one +---- 1 +str: two +str: three ---- 0 ---- 1 str: plop