git » libfiu » commit d7130e4

tests: Do not fail if fiu_enable_stack*() returns an error

author Alberto Bertogli
2012-08-26 21:23:10 UTC
committer Alberto Bertogli
2012-08-26 21:58:05 UTC
parent aaf11880e2a2653205afba45dfa5e0aa6f40b8d0

tests: Do not fail if fiu_enable_stack*() returns an error

fiu_enable_stack() and fiu_enable_stack_by_name() are only supported on some
platforms; where they're not, an error will be returned.

This small patch avoid failing the tests on that situation. Is not ideal
because the function could fail when it shouldn't, but until we introduce
other changes needed for detecting when it should and should not work, this
prevents the false negative.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

tests/test-enable_stack.c +7 -2
tests/test-enable_stack_by_name.c +8 -2

diff --git a/tests/test-enable_stack.c b/tests/test-enable_stack.c
index 588390c..7c41405 100644
--- a/tests/test-enable_stack.c
+++ b/tests/test-enable_stack.c
@@ -29,13 +29,18 @@ void func2(int should_fail)
 
 int main(void)
 {
+	int r;
+
 	fiu_init(0);
-	fiu_enable_stack("fp-1", 1, NULL, 0, (void *) &func2, -1);
+	r = fiu_enable_stack("fp-1", 1, NULL, 0, (void *) &func2, -1);
+	if (r != 0) {
+		printf("note: fiu_enable_stack() failed, skipping test\n");
+		return 0;
+	}
 
 	func1(0);
 	func2(1);
 
-
 	fiu_disable("fp-1");
 
 	func1(0);
diff --git a/tests/test-enable_stack_by_name.c b/tests/test-enable_stack_by_name.c
index 78c56ce..b901333 100644
--- a/tests/test-enable_stack_by_name.c
+++ b/tests/test-enable_stack_by_name.c
@@ -29,13 +29,19 @@ void func2(int should_fail)
 
 int main(void)
 {
+	int r;
+
 	fiu_init(0);
-	fiu_enable_stack_by_name("fp-1", 1, NULL, 0, "func2", -1);
+	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;
+	}
 
 	func1(0);
 	func2(1);
 
-
 	fiu_disable("fp-1");
 
 	func1(0);