Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hexagon qemu testbins #127

Merged
merged 10 commits into from
Nov 23, 2023
18 changes: 18 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: rizin-testbins
Upstream-Contact: <[email protected]>
Source: https://rizin.re/

# Sample paragraph, commented out:
#
# Files: src/*
# Copyright: $YEAR $NAME <$CONTACT>
# License: ...

Files: elf/hexagon/rzil/*
Copyright: 2019-2023 Qualcomm Innovation Center, Inc.
License: GPL-2.0-or-later

Files: elf/hexagon/rzil/trace-test-all.sh
Copyright: 2023 Rot127 <[email protected]>
License: LGPL-3.0-only
Binary file added elf/hexagon/rzil/brev
Binary file not shown.
Binary file added elf/hexagon/rzil/circ
Binary file not shown.
Binary file added elf/hexagon/rzil/dual_stores
Binary file not shown.
Binary file added elf/hexagon/rzil/first
Binary file not shown.
Binary file added elf/hexagon/rzil/float_convd
Binary file not shown.
Binary file added elf/hexagon/rzil/float_convs
Binary file not shown.
Binary file added elf/hexagon/rzil/float_madds
Binary file not shown.
Binary file added elf/hexagon/rzil/fpstuff
Binary file not shown.
Binary file added elf/hexagon/rzil/hex_sigsegv
Binary file not shown.
Binary file added elf/hexagon/rzil/hvx_histogram
Binary file not shown.
Binary file added elf/hexagon/rzil/hvx_misc
Binary file not shown.
Binary file added elf/hexagon/rzil/invalid-slots
Binary file not shown.
Binary file added elf/hexagon/rzil/linux-madvise
Binary file not shown.
Binary file added elf/hexagon/rzil/linux-test
Binary file not shown.
Binary file added elf/hexagon/rzil/load_align
Binary file not shown.
Binary file added elf/hexagon/rzil/load_unpack
Binary file not shown.
Binary file added elf/hexagon/rzil/mem_noshuf
Binary file not shown.
Binary file added elf/hexagon/rzil/mem_noshuf_exception
Binary file not shown.
Binary file added elf/hexagon/rzil/misc
Binary file not shown.
Binary file added elf/hexagon/rzil/multi_result
Binary file not shown.
Binary file added elf/hexagon/rzil/overflow
Binary file not shown.
Binary file added elf/hexagon/rzil/preg_alias
Binary file not shown.
Binary file added elf/hexagon/rzil/read_write_overlap
Binary file not shown.
Binary file added elf/hexagon/rzil/reg_mut
Binary file not shown.
130 changes: 130 additions & 0 deletions elf/hexagon/rzil/run-test-sets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/bin/bash

TIMEOUT_QEMU=30
TIMEOUT_RZTRACETEST=180

TEST_BINS=""
for f in $(find . -executable | grep -o "test_.*" | sort); do
ESSENTIAL_TESTS="$f $ESSENTIAL_TESTS"
done

ESSENTIAL_TESTS="$ESSENTIAL_TESTS usr v68_scalar v73_scalar test-vma load_align multi_result overflow first mem_noshuf preg_alias dual_stores mem_noshuf_exception read_write_overlap reg_mut misc"
FLOAT_TESTS="fpstuff"
# Produces traces of >1G. Some of the easily 100G in size
BIGTRACE_TESTS="sha1 sha512 brev circ load_unpack scatter_gather float_convd float_convs float_madds"

run_test() {
if [ "$2" == "NO_OUTPUT" ]; then
timeout --signal=9 "$TIMEOUT_RZTRACETEST" ~/repos/rz-tracetest/rz-tracetest/build/rz-tracetest -n -e -p "$1.trace" 2> /dev/null
else
timeout --signal=9 "$TIMEOUT_RZTRACETEST" ~/repos/rz-tracetest/rz-tracetest/build/rz-tracetest -n -e -p "$1.trace"
fi
}

run_qemu() {
if [ "$2" == "NO_OUTPUT" ]; then
timeout --signal=9 "$TIMEOUT_QEMU" /home/user/repos/qemu/build/qemu-hexagon --tracefile "$1.trace" "$1" > /dev/null 2>&1
else
timeout --signal=9 "$TIMEOUT_QEMU" /home/user/repos/qemu/build/qemu-hexagon --tracefile "$1.trace" "$1"
fi
}

print_help_exit() {
echo "$0 -t [essentials,float,bigtrace] [-s]"
echo " -t Comma separated list of test sets to run."
echo " -s Fail and print error on first occurance."
echo " -i Pass also with unlifted."
echo " -q Run Qemu for each file to generate new traces."
echo ""
echo "Results:"
echo -e " \e[1;32mPASS\e[0m = All succeeded"
echo -e " \e[1;36mPASS\e[0m = All succeeded some unlifted"
echo -e " \e[1;31mFAIL\e[0m = At least one error."
echo ""
echo "Test sets:"
echo " essentials: Basic tests (scalar, branches, mem read/write etc.)."
echo " float: Float instruction tests."
echo " bigtrace: Tests which produce very big trace files (>10GB)"
echo ""
echo "Binaries:"
echo " essentials: $ESSENTIAL_TESTS"
echo " float: $FLOAT_TESTS"
echo " bigtrace: $BIGTRACE_TESTS"
echo ""
echo "Timeouts:"
echo " qemu: $TIMEOUT_QEMU sec"
echo " rz-tracetest: $TIMEOUT_RZTRACETEST sec"
exit 1
}

check_test_result() {
SUCCESS=$( echo "$*" | grep -Eo "success: [0-9]+ [0-9.]+%" | grep -Eo "[0-9.]+%")
SKIPPED=$( echo "$*" | grep -Eo "skipped: [0-9]+ [0-9.]+%" | grep -Eo "[0-9.]+%")
UNLIFTED=$( echo "$*" | grep -Eo "unlifted: [0-9]+ [0-9.]+%" | grep -Eo "[0-9.]+%")
INVALID=$( echo "$*" | grep -Eo "invalid il: [0-9]+ [0-9.]+%" | grep -Eo "[0-9.]+%")
RUNTIME=$( echo "$*" | grep -Eo "vm runtime error: [0-9]+ [0-9.]+%" | grep -Eo "[0-9.]+%")
MISEXEC=$( echo "$*" | grep -Eo "misexecuted: [0-9]+ [0-9.]+%" | grep -Eo "[0-9.]+%")

if [[ $(echo "$INVALID $RUNTIME $MISEXEC" | grep -Eo "[1-9]") ]]; then
# Signal failure
return 2
elif [[ $(echo "$UNLIFTED" | grep -Eo "[1-9]") ]]; then
# Signal unlifted
return 1
elif [[ $(echo "$SUCCESS" | grep -Eo "100\.00%") ]]; then
# Success
return 0
fi
return 5
}

PRINT_HELP=$( echo "$*" | grep -Eo "(\-h)|(--help)")
FAIL_ON_ERROR=$( echo "$*" | grep -o "\-s")
RUN_QEMU=$( echo "$*" | grep -o "\-q")
IGNORE_UNLIFTED=$( echo "$*" | grep -o "\-i")
TEST_SET=$( echo "$*" | grep -Eo "\-t [a-zA-Z,]+")

if [ "$PRINT_HELP" == "-h" ] || [ "$PRINT_HELP" == "--help" ]; then
print_help_exit
fi

if [[ "$TEST_SET" == *"essentials"* ]]; then
TEST_BINS="$TEST_BINS $ESSENTIAL_TESTS"
fi

if [[ "$TEST_SET" == *"float"* ]]; then
TEST_BINS="$TEST_BINS $FLOAT_TESTS"
fi

if [[ "$TEST_SET" == *"bigtrace"* ]]; then
TEST_BINS="$TEST_BINS $BIGTRACE_TESTS"
fi

if [ "$TEST_BINS" == "" ]; then
print_help_exit
fi

for f in ${TEST_BINS}; do
echo -n "$f "

if [ "$RUN_QEMU" == "-q" ]; then
run_qemu "$f" "NO_OUTPUT"
fi

RES=$(run_test "$f" "NO_OUTPUT")
check_test_result $RES
RES="$?"
if [ "$RES" == "0" ]; then
echo -e "[\e[1;32mPASS\e[0m]"
continue
elif [ "$RES" == "1" ] && [ "$IGNORE_UNLIFTED" == "-i" ]; then
echo -e "[\e[1;36mPASS\e[0m]"
continue
fi

echo -e "[\e[1;31mFAIL\e[0m]"
if [ "$FAIL_ON_ERROR" == "-s" ]; then
run_test "$f"
exit 1
fi
done
Binary file added elf/hexagon/rzil/scatter_gather
Binary file not shown.
Binary file added elf/hexagon/rzil/sha1
Binary file not shown.
Binary file added elf/hexagon/rzil/sha512
Binary file not shown.
Binary file added elf/hexagon/rzil/sigbus
Binary file not shown.
Binary file added elf/hexagon/rzil/signal_context
Binary file not shown.
Binary file added elf/hexagon/rzil/signals
Binary file not shown.
Binary file added elf/hexagon/rzil/test-mmap
Binary file not shown.
Binary file added elf/hexagon/rzil/test-vma
Binary file not shown.
Binary file added elf/hexagon/rzil/test_abs
Binary file not shown.
Binary file added elf/hexagon/rzil/test_bitcnt
Binary file not shown.
Binary file added elf/hexagon/rzil/test_bitsplit
Binary file not shown.
Binary file added elf/hexagon/rzil/test_call
Binary file not shown.
Binary file added elf/hexagon/rzil/test_clobber
Binary file not shown.
Binary file added elf/hexagon/rzil/test_cmp
Binary file not shown.
Binary file added elf/hexagon/rzil/test_dotnew
Binary file not shown.
Binary file added elf/hexagon/rzil/test_ext
Binary file not shown.
Binary file added elf/hexagon/rzil/test_fibonacci
Binary file not shown.
Binary file added elf/hexagon/rzil/test_hl
Binary file not shown.
Binary file added elf/hexagon/rzil/test_hwloops
Binary file not shown.
Binary file added elf/hexagon/rzil/test_jmp
Binary file not shown.
Binary file added elf/hexagon/rzil/test_lsr
Binary file not shown.
Binary file added elf/hexagon/rzil/test_mpyi
Binary file not shown.
Binary file added elf/hexagon/rzil/test_packet
Binary file not shown.
Binary file added elf/hexagon/rzil/test_reorder
Binary file not shown.
Binary file added elf/hexagon/rzil/test_round
Binary file not shown.
Binary file added elf/hexagon/rzil/test_vavgw
Binary file not shown.
Binary file added elf/hexagon/rzil/test_vcmpb
Binary file not shown.
Binary file added elf/hexagon/rzil/test_vcmpw
Binary file not shown.
Binary file added elf/hexagon/rzil/test_vlsrw
Binary file not shown.
Binary file added elf/hexagon/rzil/test_vmaxh
Binary file not shown.
Binary file added elf/hexagon/rzil/test_vminh
Binary file not shown.
Binary file added elf/hexagon/rzil/test_vpmpyh
Binary file not shown.
Binary file added elf/hexagon/rzil/test_vspliceb
Binary file not shown.
16 changes: 16 additions & 0 deletions elf/hexagon/rzil/trace-test-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

if [ -z ${QEMU_BIN+x} ]; then
echo "Set QEMU_BIN to the qemu binary which supports BAP's tracing."
exit
fi

for f in $(find -executable); do
if [ -d "$f" ]; then
continue
fi

echo "BEGIN: $f"
$QEMU_BIN -tracefile "$f.trace" "$f"
echo "DONE: $f"
done
Binary file added elf/hexagon/rzil/usr
Binary file not shown.
Binary file added elf/hexagon/rzil/v68_hvx
Binary file not shown.
Binary file added elf/hexagon/rzil/v68_scalar
Binary file not shown.
Binary file added elf/hexagon/rzil/v69_hvx
Binary file not shown.
Binary file added elf/hexagon/rzil/v73_scalar
Binary file not shown.
Binary file added elf/hexagon/rzil/vector_add_int
Binary file not shown.
Loading