#!/bin/bash

app_name="amlogic"
inputs_dir="/fuzz/input/"
outputs_dir="/fuzz/fuzz_output/"

# generate screenrc
tmp_screen_rc="/tmp/screenrc.${app_name}"
:> $tmp_screen_rc

for id in {1..6}; do
	id_name="$id"
	if [ $id -lt 10 ]; then
		id_name="0${id_name}"
	fi
	master="S"
	if [ $id = 1 ]; then
		master="M"
	fi
	cmd="sh -c 'afl-fuzz -U -t 5000 -o ${outputs_dir} -i ${inputs_dir} -${master} ${id_name} -- python3 fuzzer.py @@ ; bash'"
	echo "screen -t $master$id_name $id $cmd" >> $tmp_screen_rc
done
screen -c $tmp_screen_rc
