]> granicus.if.org Git - jq/commitdiff
Fuzz JSON parser
authorNicolas Williams <nico@cryptonector.com>
Sat, 27 Dec 2014 01:31:47 +0000 (19:31 -0600)
committerNicolas Williams <nico@cryptonector.com>
Sat, 27 Dec 2014 05:05:57 +0000 (23:05 -0600)
tests/run

index 878e697ad9bfbd195ff2e4cc926041caa74817f1..09703e11a889e5f3c7b8fd3157422faf8f8dd5f0 100755 (executable)
--- a/tests/run
+++ b/tests/run
@@ -123,6 +123,21 @@ $VALGRIND $Q ./jq -c '. as $d|path(..) as $p|$d|getpath($p)|scalars_or_empty|[$p
 $VALGRIND $Q ./jq --stream -c '.|select(length==2)' < "$PWD/tests/torture/input0.json" > $d/out1
 diff $d/out0 $d/out1
 
+## Fuzz parser
+
+if dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null; then
+    # Have a /dev/urandom, good
+    set -x
+    $VALGRIND $Q ./jq --seq . $d/rand >/dev/null 2>&1
+    $VALGRIND $Q ./jq --seq --stream . $d/rand >/dev/null 2>&1
+    dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null
+    $VALGRIND $Q ./jq --seq . $d/rand >/dev/null 2>&1
+    $VALGRIND $Q ./jq --seq --stream . $d/rand >/dev/null 2>&1
+    dd if=/dev/urandom bs=16 count=1024 > $d/rand 2>/dev/null
+    $VALGRIND $Q ./jq --seq . $d/rand >/dev/null 2>&1
+    $VALGRIND $Q ./jq --seq --stream . $d/rand >/dev/null 2>&1
+fi
+
 ## Test library/module system
 
 mods=$PWD/tests/modules