diff options
author | Oxore <oxore@protonmail.com> | 2023-04-27 22:31:59 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2023-04-27 22:34:51 +0300 |
commit | e57b4a0a762c7951de3d9c9cc1c5eff886296835 (patch) | |
tree | f38ac65dbc7be95eec2022c54ccba5dbc8dbcea7 /test_random.bash | |
parent | f29646694f52c4af4957c2263c8d44b91a0ae781 (diff) |
Impl random test
Diffstat (limited to 'test_random.bash')
-rw-r--r-- | test_random.bash | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test_random.bash b/test_random.bash new file mode 100644 index 0000000..81c8295 --- /dev/null +++ b/test_random.bash @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: Unlicense +# +# Tests against m68k-none-elf-as. + +AS=m68k-none-elf-as +OBJCOPY=m68k-none-elf-objcopy +LD="m68k-none-elf-ld -Ttest.ld" +DISASM="./cmake-build/m68k-disasm -fabs-marks -frel-marks -fmarks" +TEST_DIR=/tmp/m68k-disasm-tests + +set -e +CRED="\033[31m" +CGREEN="\033[32m" +CRST="\033[39m" + +rm -rf ${TEST_DIR} +mkdir -p ${TEST_DIR} + +run_test_random() { + local pass_number=$1 + local test_name_sanitized=${pass_number//[^a-zA-Z0-9_\-]/-} + local file_orig_bin=${TEST_DIR}/${test_name_sanitized}.orig.bin + local file_asm=${TEST_DIR}/${test_name_sanitized}.S + local file_as_o=${TEST_DIR}/${test_name_sanitized}.as.o + local file_as_elf=${TEST_DIR}/${test_name_sanitized}.as.elf + local file_as_bin=${TEST_DIR}/${test_name_sanitized}.as.bin + echo -ne "Test random, pass ${pass_number}... " + dd if=/dev/urandom of=${file_orig_bin} bs=1024 count=1 + ${DISASM} -o ${file_asm} ${file_orig_bin} + ${AS} -o ${file_as_o} ${file_asm} + ${LD} -o ${file_as_elf} ${file_as_o} + ${OBJCOPY} ${file_as_elf} -O binary ${file_as_bin} + if ! cmp ${file_orig_bin} ${file_as_bin} >/dev/null 2>&1; then + echo -e "${CRED}FAIL${CRST}: output and input binaries do not match" + echo ${file_orig_bin} + echo ${file_as_bin} + else + echo -e "${CGREEN}OK${CRST}" + #cat ${file_asm} + fi +} + +for i in `seq 1 10`; do + run_test_random $i +done |