Browse Source

Improve tests FPU tests

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Graham MacDonald 6 years ago
parent
commit
ff502dc6fe
2 changed files with 16 additions and 12 deletions
  1. 5 3
      sys/src/regress/fpuexcept.c
  2. 11 9
      sys/src/regress/fpunote.c

+ 5 - 3
sys/src/regress/fpuexcept.c

@@ -17,13 +17,14 @@ fail(const char *msg) {
 
 static float f = 10.0;
 
-int handlenote(void *ureg, char *note)
+int
+handlenote(void *ureg, char *note)
 {
 	if (strstr(note, "Divide-By-Zero")) {
 		pass();
 	}
-	fail("raised exception not divide by zero");
-	return 0;
+	fail("exception raised, but not divide by zero");
+	return 1;
 }
 
 void
@@ -33,3 +34,4 @@ main(void)
 	f = f / 0.0f;
 	fail("divide by zero exception not raised");
 }
+ 

+ 11 - 9
sys/src/regress/fpunote.c

@@ -1,7 +1,7 @@
 #include <u.h>
 #include <libc.h>
 
-// Test that the FPU can be used in note handlers
+// Test that the FPU can be used in note handler
 
 void
 pass(void) {
@@ -15,20 +15,22 @@ fail(const char *msg) {
 	exits("FAIL");
 }
 
-static float f = 0;
+static float correctnote = 0.0f;
 
-int handlenote(void *ureg, char *note)
+int
+handlenote(void *ureg, char *note)
 {
-	// Use the FPU in the note handler - suicides in case of failure
-	f = 1.0;
-	pass();
-	return 0;
+	if (strstr(note, "mynote")) {
+		// suicide here if no fpu support for note handlers
+		correctnote = 1.2f;
+		pass();
+	}
+	return 1;
 }
 
 void
 main(void)
 {
 	atnotify(handlenote, 1);
-	f = f / 0.0f;
-	fail("divide by zero exception not raised");
+	postnote(PNPROC, getpid(), "mynote");
 }