History

More cleanup tests

test3 wasn't working originally.

Michael Matz committed 7 years ago

Commit 08e22d81 parent 4cc802a2 files · +43 −2Browse files

Unified · Split

2 files
  1. tests/tests2/101_cleanup.c +38 −2
  2. tests/tests2/101_cleanup.expect +5 −0
tests/tests2/101_cleanup.c+38−2
@@ -1,5 +1,4 @@
1−#include <tcclib.h>
2−
1+extern int printf(const char*, ...);
32 static int glob_i = 0;
43
54 void incr_glob_i(int *i)
@@ -115,6 +114,41 @@ void test_ret2() · 109 unmodified lines
115114 }
116115 }
117116
117+void test2(void) {
118+ int chk = 0;
119+again:
120+ if (!chk) {
121+ char * __attribute__ ((cleanup(check2))) stop_that = "test2";
122+ chk++;
123+ goto again;
124+ }
125+}
126+
127+int test3(void) {
128+ char * __attribute__ ((cleanup(check2))) stop_that = "three";
129+ int chk = 0;
130+
131+ if (chk) {
132+ {
133+ outside:
134+ {
135+ char * __attribute__ ((cleanup(check2))) stop_that = "two";
136+ printf("---- %d\n", chk);
137+ }
138+ }
139+ }
140+ if (!chk)
141+ {
142+ char * __attribute__ ((cleanup(check2))) stop_that = "one";
143+
144+ if (!chk) {
145+ chk = 1;
146+ goto outside;
147+ }
148+ }
149+ return 0;
150+}
151+
118152 int main()
119153 {
120154 int i __attribute__ ((__cleanup__(check))) = 0, not_i;
@@ -138,6 +172,8 @@ int main() · 17 unmodified lines
138172 printf("because what if free was call inside cleanup function\n", test());
139173 test_ret();
140174 test_ret2();
175+ test2();
176+ test3();
141177 return i;
142178 }
143179
tests/tests2/101_cleanup.expect+5−0
@@ -10,6 +10,11 @@ str: that · 9 unmodified lines
1010 str: this should appear only once
1111 str: -that2
1212 str: -that
13+str: test2
14+str: one
15+---- 1
16+str: two
17+str: three
1318 ---- 0
1419 ---- 1
1520 str: plop

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t