finish eval scripts

This commit is contained in:
Alwin Berger 2022-06-14 23:54:47 +02:00
parent 948ce540e8
commit aa7d78affe
2 changed files with 26 additions and 19 deletions

View File

@ -1,9 +1,11 @@
BENCHDIR = target/bench BENCHDIR = target/bench
TARGET = tmr.axf TNAME = tmrint
TARGET_TRACE = $(BENCHDIR)/traces/tmr_worst.ron TARGET = $(TNAME).axf
TARGET_EDGES = $(BENCHDIR)/edges/tmr_worst.ron TARGET_TRACE = $(BENCHDIR)/traces/$(TNAME)_worst.ron
TARGET_EDGES = $(BENCHDIR)/edges/$(TNAME)_worst.ron
RUNTIME = 3600 RUNTIME = 3600
COMMON_FLAGS = benchmark,dump_infos,fuzz_interrupt INT_FLAG = ,fuzz_interrupt
COMMON_FLAGS = benchmark,dump_infos$(INT_FLAG)
NUM_JOB = 3 NUM_JOB = 3
NUM_ITERATIONS = 10 NUM_ITERATIONS = 10
LOCKFILE = /tmp/bench_sem LOCKFILE = /tmp/bench_sem
@ -14,7 +16,7 @@ $(BENCHDIR)/bin:
mkdir -p $@ mkdir -p $@
$(BENCHDIR)/target_random: $(BENCHDIR)/target_random:
cargo build --bin fuzzer --target-dir $@ --features benchmark,dump_infos,fuzz_interrupt,sched_queue,fuzz_random cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),sched_queue,fuzz_random
$(BENCHDIR)/target_known_edges: $(BENCHDIR)/target_known_edges:
cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_known_edges,sched_queue cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_known_edges,sched_queue
@ -29,7 +31,7 @@ $(BENCHDIR)/target_state:
cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_state,sched_state cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_state,sched_state
$(BENCHDIR)/target_state_afl: $(BENCHDIR)/target_state_afl:
cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_state,sched_state cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_state,feed_afl,sched_state
$(BENCHDIR)/target_state_afl_int: $(BENCHDIR)/target_state_afl_int:
cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_state,sched_state,muta_interrupt cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_state,sched_state,muta_interrupt
@ -46,11 +48,11 @@ $(BENCHDIR)/target_graph_afl:
$(BENCHDIR)/target_graph_muta_afl: $(BENCHDIR)/target_graph_muta_afl:
cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_graph,sched_graph,feed_afl,muta_snip,muta_input,muta_suffix cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_graph,sched_graph,feed_afl,muta_snip,muta_input,muta_suffix
$(BENCHDIR)/target_graph_all: $(BENCHDIR)/target_graph_muta_afl_int:
cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_graph,sched_graph,feed_afl,muta_snip,muta_input,muta_suffix,muta_interrupt cargo build --bin fuzzer --target-dir $@ --features $(COMMON_FLAGS),feed_graph,sched_graph,feed_afl,muta_snip,muta_input,muta_suffix,muta_interrupt
binaries: $(BENCHDIR)/target_random $(BENCHDIR)/target_known_edges $(BENCHDIR)/target_afl_queue $(BENCHDIR)/target_afl_mapmax $(BENCHDIR)/target_state $(BENCHDIR)/target_state_afl $(BENCHDIR)/target_state_afl_int \ binaries: $(BENCHDIR)/target_random $(BENCHDIR)/target_known_edges $(BENCHDIR)/target_afl_queue $(BENCHDIR)/target_afl_mapmax $(BENCHDIR)/target_state $(BENCHDIR)/target_state_afl $(BENCHDIR)/target_state_afl_int \
$(BENCHDIR)/target_graph $(BENCHDIR)/target_graph_muta $(BENCHDIR)/target_graph_afl $(BENCHDIR)/target_graph_muta_afl $(BENCHDIR)/target_graph_all $(BENCHDIR)/target_graph $(BENCHDIR)/target_graph_muta $(BENCHDIR)/target_graph_afl $(BENCHDIR)/target_graph_muta_afl $(BENCHDIR)/target_graph_muta_afl_int
# variants: known_edges, afl_queue, afl_mapmax, state, state_afl, graph, graph_muta, graph_afl, graph_all # variants: known_edges, afl_queue, afl_mapmax, state, state_afl, graph, graph_muta, graph_afl, graph_all
$(BENCHDIR)/bench_%.log: $(BENCHDIR)/target_% $(TARGET_TRACE) $(BENCHDIR)/bench_%.log: $(BENCHDIR)/target_% $(TARGET_TRACE)
@ -63,20 +65,22 @@ $(BENCHDIR)/bench_%.log: $(BENCHDIR)/target_% $(TARGET_TRACE)
mkdir -p $(BENCHDIR)/infos/$$CASE ; \ mkdir -p $(BENCHDIR)/infos/$$CASE ; \
./fuzzer_bench.sh $</debug/fuzzer $(TARGET) --libafl-traces $(TARGET_TRACE) --libafl-fuzztime $(RUNTIME) \ ./fuzzer_bench.sh $</debug/fuzzer $(TARGET) --libafl-traces $(TARGET_TRACE) --libafl-fuzztime $(RUNTIME) \
--libafl-dump $(BENCHDIR)/infos/$$CASE/$$i \ --libafl-dump $(BENCHDIR)/infos/$$CASE/$$i \
--libafl-edges $(TARGET_EDGES) --libafl-exectimes $(BENCHDIR)/execs/$$CASE\_$$i.exec > $@_$$i || \ --libafl-edges $(TARGET_EDGES) --libafl-exectimes $(BENCHDIR)/execs/$$CASE\_$$i.exec > $@_$$i && \
sed -i "1 i\\$$CASE " $(BENCHDIR)/execs/$$CASE\_$$i.exec || \ sed -i "1 i\\$$CASE " $(BENCHDIR)/execs/$$CASE\_$$i.exec && \
$(RELEASE) & \ $(RELEASE) & \
done done
for i in $@_*; do tail -n 1 $$i >> $@; done wait
for i in $@_*; do tail -n 1 $$i >> $@; done
benchmarks_all: target/bench/bench_known_edges.log target/bench/bench_afl_queue.log target/bench/bench_afl_mapmax.log target/bench/bench_state.log target/bench/bench_state_afl.log target/bench/bench_state_afl_int.log \ benchmarks_noint: target/bench/bench_known_edges.log target/bench/bench_afl_queue.log target/bench/bench_afl_mapmax.log target/bench/bench_state.log target/bench/bench_state_afl.log \
target/bench/bench_graph.log target/bench/bench_graph_muta.log target/bench/bench_graph_afl.log target/bench/bench_graph_muta_afl.log target/bench/bench_graph_all.log target/bench/bench_graph.log target/bench/bench_graph_muta.log target/bench/bench_graph_afl.log target/bench/bench_graph_muta_afl.log
# target/bench/bench_graph_all.log target/bench/bench_state_afl_int.log
benchmarks_int_mut: target/bench/bench_graph_muta_afl.log target/bench/bench_graph_all.log target/bench/bench_state_afl.log target/bench/bench_state_afl_int.log benchmarks_int: target/bench/bench_graph_muta_afl.log target/bench/bench_graph_muta_afl_int.log target/bench/bench_state_afl.log target/bench/bench_state_afl_int.log target/bench/bench_afl_mapmax.log
benchmark_random: target/bench/bench_random.log benchmark_random: target/bench/bench_random.log
all: binaries benchmarks_all all: binaries benchmarks_noint
clean_bench: clean_bench:
rm -rf $(BENCHDIR)/bench_* rm -rf $(BENCHDIR)/bench_*
@ -104,4 +108,4 @@ reset_sem:
grep "Qemu Ticks:"; \ grep "Qemu Ticks:"; \
done done
$(TARGET_TRACE): tmr.case $(TARGET_TRACE): $(TNAME).case

View File

@ -12,21 +12,24 @@ if [[ $2 != "lock" ]] && [[ $2 != "release" ]]; then echo "Parameter 2: must be
if [[ $2 = "lock" ]]; then if [[ $2 = "lock" ]]; then
SEM='' SEM=''
while [[ -z $SEM ]]; do while [[ -z $SEM ]]; do
if (( $(cat $1 ) == 0 )); then sleep 1; wait; continue; fi
if mkdir $1_lockdir > /dev/null 2>&1 ; then if mkdir $1_lockdir > /dev/null 2>&1 ; then
VAL=$(cat $1) VAL=$(cat $1)
if (( $VAL > 0 )) if (( $VAL > 0 ))
then then
SEM=$(sed -i "s@$VAL@$(( $VAL - 1))@w /dev/stdout" $1) SEM=$(sed -i "s@$VAL@$(( $VAL - 1))@w /dev/stdout" $1)
echo "Take $VAL -> $SEM" echo "Take $VAL -> $SEM"
rmdir $1_lockdir
else else
rmdir $1_lockdir
sleep 1; wait sleep 1; wait
fi fi
else else
sleep 0.1; sleep 0.5;
fi fi
done done
rmdir $1_lockdir
else else
echo "Attempt unlock"
SEM='' SEM=''
while [[ -z $SEM ]]; do while [[ -z $SEM ]]; do
if mkdir $1_lockdir > /dev/null 2>&1 ; then if mkdir $1_lockdir > /dev/null 2>&1 ; then
@ -36,8 +39,8 @@ else
else else
sleep 0.1; sleep 0.1;
fi fi
rmdir $1_lockdir
done done
rmdir $1_lockdir
fi fi
#SEM=''; while [[ -z SEM ]]; do VAL=$(cat /tmp/test); if (( $VAL > 0 )); then SEM=$(sed -i "s@$VAL@$(( $VAL - 1))@w /dev/stdout" /tmp/test); else sleep 1; wait; fi; done #SEM=''; while [[ -z SEM ]]; do VAL=$(cat /tmp/test); if (( $VAL > 0 )); then SEM=$(sed -i "s@$VAL@$(( $VAL - 1))@w /dev/stdout" /tmp/test); else sleep 1; wait; fi; done