File: test-enable_stack_by_name.c

package info (click to toggle)
libfiu 1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ansic: 2,633; python: 973; makefile: 599; sh: 309
file content (47 lines) | stat: -rw-r--r-- 700 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

#include <fiu-control.h>
#include <fiu.h>

int __attribute__((noinline)) func1()
{
	/*
	int nptrs;
	void *buffer[100];
	nptrs = backtrace(buffer, 100);
	backtrace_symbols_fd(buffer, nptrs, 1);
	*/

	return fiu_fail("fp-1") != 0;
}

int __attribute__((noinline)) func2()
{
	return func1();
}

int main(void)
{
	int r;

	fiu_init(0);
	r = fiu_enable_stack_by_name("fp-1", 1, NULL, 0, "func2", -1);
	if (r != 0) {
		printf("NOTE: fiu_enable_stack_by_name() failed, "
		       "skipping test\n");
		return 0;
	}

	assert(func1() == 0);
	assert(func2() == 1);

	fiu_disable("fp-1");

	assert(func1() == 0);
	assert(func2() == 0);

	return 0;
}