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>1extern int printf(const char*, ...);
2
3static int glob_i = 0;2static int glob_i = 0;
4 3
5void incr_glob_i(int *i)4void incr_glob_i(int *i)
@@ -115,6 +114,41 @@ void test_ret2() · 109 unmodified lines
115 }114 }
116}115}
117 116
117void test2(void) {
118 int chk = 0;
119again:
120 if (!chk) {
121 char * __attribute__ ((cleanup(check2))) stop_that = "test2";
122 chk++;
123 goto again;
124 }
125}
126
127int 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
118int main()152int main()
119{153{
120 int i __attribute__ ((__cleanup__(check))) = 0, not_i;154 int i __attribute__ ((__cleanup__(check))) = 0, not_i;
@@ -138,6 +172,8 @@ int main() · 17 unmodified lines
138 printf("because what if free was call inside cleanup function\n", test());172 printf("because what if free was call inside cleanup function\n", test());
139 test_ret();173 test_ret();
140 test_ret2();174 test_ret2();
175 test2();
176 test3();
141 return i;177 return i;
142}178}
143 179
tests/tests2/101_cleanup.expect+5−0
@@ -10,6 +10,11 @@ str: that · 9 unmodified lines
10str: this should appear only once10str: this should appear only once
11str: -that211str: -that2
12str: -that12str: -that
13str: test2
14str: one
15---- 1
16str: two
17str: three
13---- 018---- 0
14---- 119---- 1
15str: plop20str: 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