parallel benchmarks with semaphores
This commit is contained in:
parent
6969b5de5a
commit
948ce540e8
@ -4,10 +4,18 @@ TARGET_TRACE = $(BENCHDIR)/traces/tmr_worst.ron
|
|||||||
TARGET_EDGES = $(BENCHDIR)/edges/tmr_worst.ron
|
TARGET_EDGES = $(BENCHDIR)/edges/tmr_worst.ron
|
||||||
RUNTIME = 3600
|
RUNTIME = 3600
|
||||||
COMMON_FLAGS = benchmark,dump_infos,fuzz_interrupt
|
COMMON_FLAGS = benchmark,dump_infos,fuzz_interrupt
|
||||||
|
NUM_JOB = 3
|
||||||
|
NUM_ITERATIONS = 10
|
||||||
|
LOCKFILE = /tmp/bench_sem
|
||||||
|
LOCK = ./bash_sem.sh $(LOCKFILE) lock
|
||||||
|
RELEASE = ./bash_sem.sh $(LOCKFILE) release
|
||||||
|
|
||||||
$(BENCHDIR)/bin:
|
$(BENCHDIR)/bin:
|
||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
|
$(BENCHDIR)/target_random:
|
||||||
|
cargo build --bin fuzzer --target-dir $@ --features benchmark,dump_infos,fuzz_interrupt,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
|
||||||
|
|
||||||
@ -41,21 +49,23 @@ $(BENCHDIR)/target_graph_muta_afl:
|
|||||||
$(BENCHDIR)/target_graph_all:
|
$(BENCHDIR)/target_graph_all:
|
||||||
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_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_all
|
||||||
|
|
||||||
# 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)
|
||||||
mkdir -p $(BENCHDIR)/execs
|
mkdir -p $(BENCHDIR)/execs
|
||||||
for i in {1..10}; do \
|
for i in {1..$(NUM_ITERATIONS)}; do \
|
||||||
CASE=$$(basename -s.log $@ | cut -d'_' -f 2- ); \
|
CASE=$$(basename -s.log $@ | cut -d'_' -f 2- ); \
|
||||||
[ -f $(BENCHDIR)/execs/$$CASE\_$$i.exec -a -f $@_$$i ] && continue; \
|
[ -f $(BENCHDIR)/execs/$$CASE\_$$i.exec -a -f $@_$$i ] && continue; \
|
||||||
|
$(LOCK); \
|
||||||
echo $$CASE iteration $$i; \
|
echo $$CASE iteration $$i; \
|
||||||
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) & \
|
||||||
done
|
done
|
||||||
for i in $@_*; do tail -n 1 $$i >> $@; done
|
for i in $@_*; do tail -n 1 $$i >> $@; done
|
||||||
|
|
||||||
@ -64,6 +74,8 @@ benchmarks_all: target/bench/bench_known_edges.log target/bench/bench_afl_queue.
|
|||||||
|
|
||||||
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_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
|
||||||
|
|
||||||
|
benchmark_random: target/bench/bench_random.log
|
||||||
|
|
||||||
all: binaries benchmarks_all
|
all: binaries benchmarks_all
|
||||||
|
|
||||||
clean_bench:
|
clean_bench:
|
||||||
@ -74,6 +86,12 @@ clean_aggregate:
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf target/bench
|
rm -rf target/bench
|
||||||
|
echo $(NUM_JOB) > $(LOCKFILE)
|
||||||
|
rm -rf $(LOCKFILE)_lockdir
|
||||||
|
|
||||||
|
reset_sem:
|
||||||
|
echo $(NUM_JOB) > $(LOCKFILE)
|
||||||
|
rm -rf $(LOCKFILE)_lockdir
|
||||||
|
|
||||||
%.case: %_inputs
|
%.case: %_inputs
|
||||||
mkdir -p $(BENCHDIR)/traces $(BENCHDIR)/edges
|
mkdir -p $(BENCHDIR)/traces $(BENCHDIR)/edges
|
||||||
|
43
fuzzers/wcet_qemu_sys/bash_sem.sh
Executable file
43
fuzzers/wcet_qemu_sys/bash_sem.sh
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# A generic counting semaphore in bash
|
||||||
|
# Parameter is the lockfile and operation
|
||||||
|
# Setup:
|
||||||
|
# rm /tmp/test
|
||||||
|
# echo $num > /tmp/test
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if [[ ! -f $1 ]]; then echo "Parameter 1: File Does not exist"; exit; fi
|
||||||
|
if [[ $2 != "lock" ]] && [[ $2 != "release" ]]; then echo "Parameter 2: must be lock or release"; exit; fi
|
||||||
|
if [[ $2 = "lock" ]]; then
|
||||||
|
SEM=''
|
||||||
|
while [[ -z $SEM ]]; do
|
||||||
|
if mkdir $1_lockdir > /dev/null 2>&1 ; then
|
||||||
|
VAL=$(cat $1)
|
||||||
|
if (( $VAL > 0 ))
|
||||||
|
then
|
||||||
|
SEM=$(sed -i "s@$VAL@$(( $VAL - 1))@w /dev/stdout" $1)
|
||||||
|
echo "Take $VAL -> $SEM"
|
||||||
|
else
|
||||||
|
sleep 1; wait
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
sleep 0.1;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rmdir $1_lockdir
|
||||||
|
else
|
||||||
|
SEM=''
|
||||||
|
while [[ -z $SEM ]]; do
|
||||||
|
if mkdir $1_lockdir > /dev/null 2>&1 ; then
|
||||||
|
VAL=$(cat $1)
|
||||||
|
SEM=$(sed -i "s@$VAL@$(( $VAL + 1))@w /dev/stdout" $1)
|
||||||
|
echo "Give $VAL -> $(( $VAL + 1 ))"
|
||||||
|
else
|
||||||
|
sleep 0.1;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rmdir $1_lockdir
|
||||||
|
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
|
Loading…
x
Reference in New Issue
Block a user