xref: /freebsd/tools/regression/pthread/unwind/Test.cpp (revision 5956d97f4b3204318ceb6aa9c77bd0bc6ea87a41)
1 /* $FreeBSD$ */
2 
3 static int destructed;
4 static int destructed2;
5 
6 class Test {
7 public:
8 	Test() { printf("Test::Test()\n"); }
9 	~Test() { printf("Test::~Test()\n"); destructed = 1; }
10 };
11 
12 void
13 cleanup_handler(void *arg __unused)
14 {
15 	destructed2 = 1;
16 	printf("%s()\n", __func__);
17 }
18 
19 void
20 check_destruct(void)
21 {
22 	if (!destructed)
23 		printf("Bug, object destructor is not called\n");
24 	else
25 		printf("OK\n");
26 }
27 
28 void
29 check_destruct2(void)
30 {
31 	if (!destructed)
32 		printf("Bug, object destructor is not called\n");
33 	else if (!destructed2)
34 		printf("Bug, cleanup handler is not called\n");
35 	else
36 		printf("OK\n");
37 }
38