about summary refs log tree commit diff
path: root/collect-values
blob: 6397b0c4d3626c3a115b3f6b2d9046a43e312ecd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
# Variable value collector
# 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-collect-values DURATION STACK_SIZE DEST INPUT COMMAND ARG...
  exit 1
fi
timeout=$1
stack_size=$2
grandparent="$3"
input="$4"
parent="$(basename "$(dirname "$input")")"
output="$grandparent/$parent/$(basename "$input")"
template="${@:5}"
cmd="$(printf %s "$template" | sed "s#@@#$input#g")"
set +e
AFL_USE_QASAN=1 TAOSC_STACK_SIZE=$stack_size TAOSC_OUTPUT=$output \
  timeout -k 0 $timeout afl-qemu-trace $cmd 1>/dev/null 2>&1
exit 0