1#include <sys/types.h>
2
3#include <stdio.h>
4
5#include <rumprun/tester.h>
6
7/* Constructor test.  Checks that constructors run in the correct order */
8int myvalue = 2;
9static void __attribute__((constructor(2000),used))
10ctor1(void)
11{
12	myvalue = myvalue * 2;
13}
14
15static void __attribute__((constructor(1000),used))
16ctor2(void)
17{
18	myvalue = myvalue + 2;
19}
20
21static void __attribute__((constructor(1000),used))
22ctor3(void)
23{
24	printf("I'm a constructor!\n");
25}
26
27static void __attribute__((destructor(1000),used))
28dtor1(void)
29{
30	printf("I'm a destructor!\n");
31}
32
33int
34rumprun_test(int argc, char *argv[])
35{
36
37	if (myvalue != 8) {
38		printf("ERROR running constructor test, myvalue=%d, "
39		    "expected 8\n", myvalue);
40		return 1;
41	}
42	return 0;
43}
44