about summary refs log tree commit diff
path: root/test/test-floatingpoint.c
diff options
context:
space:
mode:
authorhexcoder- <heiko@hexco.de>2020-07-13 10:35:43 +0200
committerhexcoder- <heiko@hexco.de>2020-07-13 10:35:43 +0200
commit5a26656ea1095083def4c82918116b2d5cb2e641 (patch)
tree2c852397ee807ec79633e2c78bbe65c3971280c3 /test/test-floatingpoint.c
parentabb0d47985d22d8090540e987b2173d80c574439 (diff)
downloadafl++-5a26656ea1095083def4c82918116b2d5cb2e641.tar.gz
add floating point test cases. One for fuzzing (test-floatingpoint.c) and one for testing all cases with the instrumented program (test-fp_cases.c)
Diffstat (limited to 'test/test-floatingpoint.c')
-rw-r--r--test/test-floatingpoint.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test-floatingpoint.c b/test/test-floatingpoint.c
new file mode 100644
index 00000000..f78b5d9f
--- /dev/null
+++ b/test/test-floatingpoint.c
@@ -0,0 +1,18 @@
+#include <stdlib.h>
+#include <unistd.h>
+
+int main(void)
+{
+    long double magic;
+
+    ssize_t bytes_read = read(STDIN_FILENO, &magic, sizeof(magic));
+    if (bytes_read < (ssize_t)sizeof(magic)) {
+        return 1;
+    }
+
+    if( (-magic == 15.0 + 0.5 + 0.125 + 0.03125 + 0.0078125) ){ /* 15 + 1/2 + 1/8 + 1/32 + 1/128 */
+        abort();
+    }
+
+    return 0;
+}