xref: /freebsd/tools/regression/pthread/unwind/Test.cpp (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 
2 static int destructed;
3 static int destructed2;
4 
5 class Test {
6 public:
7 	Test() { printf("Test::Test()\n"); }
8 	~Test() { printf("Test::~Test()\n"); destructed = 1; }
9 };
10 
11 void
12 cleanup_handler(void *arg __unused)
13 {
14 	destructed2 = 1;
15 	printf("%s()\n", __func__);
16 }
17 
18 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
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