CSmith: add script to generate tests

This commit is contained in:
Théophile Bastian 2019-03-18 20:50:49 +01:00
parent 693a48f070
commit d7c1aaa6b5
3 changed files with 28 additions and 5 deletions

View file

@ -378,8 +378,6 @@ let cleanup_fde (fde_changes: cfa_changes_fde) : cfa_changes_fde =
let process_sub sub : subroutine_cfa_data =
(** Extracts the `cfa_changes_fde` of a subroutine *)
Format.eprintf "Sub %s...@." @@ BStd.Sub.name sub ;
let cfg = BStd.Sub.to_cfg sub in
let next_instr_graph = build_next_instr cfg in

View file

@ -260,7 +260,6 @@ static int process_section(struct internal_state* state,
size_t *written /*, FILE *rela_f */)
{
size_t shndx = elf_ndxscn(s);
fprintf(stderr, "Processing section %lu\n", shndx); //D
GElf_Sym text_sym;
int text_sym_idx = find_section_symbol(state->elf, shndx, &text_sym);
@ -303,8 +302,6 @@ static int process_section(struct internal_state* state,
{
continue;
}
fprintf(stderr, "FDE %lu belongs to this section\n", cur_fde->num); //D
struct dwarfw_fde fde = {
.cie = &cie,
.initial_location = cur_fde->initial_location,

28
csmith/csmith_gen.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
USAGE="$0 output_dir nb_tests"
if [ "$#" -lt 2 ] ; then
>&2 echo -e "Missing argument(s). Usage:\n$USAGE"
exit 1
fi
DIR=$1
NB_TESTS=$2
mkdir -p "$DIR"
echo -n ">>> "
for _num in $(seq 1 $NB_TESTS); do
num=$(printf "%02d" $_num)
echo -ne "\r>>> $num.c "
path="$DIR/$num"
csmith > "$path.c"
echo -ne "\r>>> $num.bin "
gcc -O2 -I/usr/include/csmith-2.3.0/ -w "$path.c" -o "$path.orig.bin"
objcopy --remove-section '.eh_frame' --remove-section '.eh_frame_hdr' \
"$path.orig.bin" "$path.bin"
echo -ne "\r>>> $num.eh.bin "
../synthesize_dwarf.sh "$path.bin" "$path.eh.bin"
done
echo ""