about summary refs log tree commit diff
path: root/sort-inputs
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2025-10-21 17:21:00 +0900
committerNguyễn Gia Phong <cnx@loang.net>2025-10-21 17:21:00 +0900
commit00e6c689330c317dfc3db9b6465a8b3445e29e3b (patch)
tree8eaec60f4cb9a7436e22c80339bdf8a1f6ba65d6 /sort-inputs
parentd64b339e1d9e74d92821ec069e95093ac03bb25d (diff)
downloadtaosc-00e6c689330c317dfc3db9b6465a8b3445e29e3b.tar.gz
Use QASAN 0.0.3.dev2
Diffstat (limited to 'sort-inputs')
-rw-r--r--sort-inputs51
1 files changed, 51 insertions, 0 deletions
diff --git a/sort-inputs b/sort-inputs
new file mode 100644
index 0000000..6d03e70
--- /dev/null
+++ b/sort-inputs
@@ -0,0 +1,51 @@
+#!/bin/sh
+# Input sorter
+# Copyright (C) 2025  Nguyễn Gia Phong
+#
+# This file is part of taosc.
+#
+# Taosc is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Taosc is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with taosc.  If not, see <https://www.gnu.org/licenses/>.
+
+set -eux -o pipefail
+if test $# -lt 6
+then
+  echo Usage: taosc-sort-inputs DURATION BAD GOOD INPUT COMMAND ARG...
+  exit 1
+fi
+timeout=$1
+bad_dir="$2"
+good_dir="$3"
+input="$4"
+template="${@:5}"
+cmd="$(printf %s "$template" | sed "s#@@#$input#g")"
+reached=$(mktemp -u)
+set +e
+AFL_USE_QASAN=1 TAOSC_OUTPUT=$reached timeout -k 0 $timeout \
+  afl-qemu-trace $cmd 1>/dev/null 2>&1
+exit_code=$?
+set -e
+if test -f $reached
+then
+  trap "rm $reached" EXIT
+  if test ! -s $reached
+  then
+    if test $exit_code -gt 128 ||
+      test $exit_code -ge 124 -a $exit_code -le 127 # timeout
+    then
+      cp "$input" "$bad_dir"
+    else
+      cp "$input" "$good_dir"
+    fi
+  fi
+fi