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