summaryrefslogtreecommitdiff
path: root/test_random.bash
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2024-02-05 01:20:51 +0300
committerOxore <oxore@protonmail.com>2024-02-05 01:21:59 +0300
commit21a9aa92a7cf8767a0fcb33858546dea744c4071 (patch)
treea5313fdaff5c0ed2d3db416d027e6df21d3cd7ff /test_random.bash
parent9fd2eba95beb6c9ce6fb26e1442aa2f68aac9b1f (diff)
Organize source code and tests
Diffstat (limited to 'test_random.bash')
-rw-r--r--test_random.bash63
1 files changed, 0 insertions, 63 deletions
diff --git a/test_random.bash b/test_random.bash
deleted file mode 100644
index 6d2b17c..0000000
--- a/test_random.bash
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/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 -frdc -fxrefs-to -fxrefs-from -flabels -frel-labels -fabs-labels -fshort-ref-local-labels -fimm-hex -ffollow-jumps"
-TEST_DIR=/tmp/m68k-disasm-random-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 blocks_count=$2
- 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=${blocks_count} >/dev/null 2>&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}; then
- echo -e "${CRED}FAIL${CRST}: output and input binaries do not match"
- hexdump -Cv ${file_orig_bin} >${file_orig_bin}.txt
- hexdump -Cv ${file_as_bin} >${file_as_bin}.txt
- echo ${file_orig_bin}
- echo ${file_as_bin}
- exit
- else
- echo -e "${CGREEN}OK${CRST}"
- rm ${file_orig_bin} ${file_asm} ${file_as_o} ${file_as_elf} ${file_as_bin}
- fi
-}
-
-# Tiny tests are mostly for ensuring that bounds checking is working properly,
-# because it is more likely to encounter something that looks like a truncated
-# instruction.
-#
-# If there is an obvious bug, then it will most likely be detected
-# here and it is easier to dissect tiny test blob than huge test trying to debug
-# single test case.
-for i in `seq 1 1000`; do
- run_test_random tiny$i 1
-done
-
-# Huge tests are for the broad coverage. They catch a lot!
-for i in `seq 1 10`; do
- run_test_random huge$i 1024
-done