summaryrefslogtreecommitdiff
path: root/test.bash
diff options
context:
space:
mode:
authorOxore <oxore@protonmail.com>2023-04-20 23:54:59 +0300
committerOxore <oxore@protonmail.com>2023-04-20 23:54:59 +0300
commit25762ee11dadb333f5b63c359abb615dc5f16b09 (patch)
tree73e77a58727de299d6e7ac38d2497af91d0f1fbb /test.bash
parent32e67b15a32560a63a0f83c2b9f28259c00a7df5 (diff)
Refactor tests
Diffstat (limited to 'test.bash')
-rw-r--r--test.bash100
1 files changed, 55 insertions, 45 deletions
diff --git a/test.bash b/test.bash
index 49a7a02..c6fce55 100644
--- a/test.bash
+++ b/test.bash
@@ -15,7 +15,33 @@ rm -rf ${TEST_DIR}
mkdir -p ${TEST_DIR}
echo "0" >${TRACE_FILE}
-run_test() {
+run_test_simple() {
+ test_name=$1
+ data=$2
+ file_orig_bin=${TEST_DIR}/${test_name}.orig.bin
+ file_asm=${TEST_DIR}/${test_name}.S
+ file_as_o=${TEST_DIR}/${test_name}.as.o
+ file_as_bin=${TEST_DIR}/${test_name}.as.bin
+ echo -ne "Test ${test_name}... "
+ echo -ne "${data}" >${file_orig_bin}
+ ./cmake-build/m68k-disasm -t ${TRACE_FILE} -o ${file_asm} ${file_orig_bin}
+ ${AS} -o ${file_as_o} ${file_asm}
+ ${OBJCOPY} ${file_as_o} -O binary ${file_as_bin}
+ if ! cmp ${file_orig_bin} ${file_as_bin} >/dev/null 2>&1; then
+ echo "FAIL"
+ cat ${file_asm}
+ echo ${file_orig_bin}
+ hexdump -Cv ${file_orig_bin} | head -n1
+ echo ${file_as_bin}
+ hexdump -Cv ${file_as_bin} | head -n1
+ break;
+ else
+ echo "OK"
+ cat ${file_asm}
+ fi
+}
+
+run_test_iterative() {
test_name=$1
prefix=$2
offset=$3
@@ -27,24 +53,8 @@ run_test() {
file_as_o=${TEST_DIR}/${test_name}.as.o
file_as_bin=${TEST_DIR}/${test_name}.as.bin
for i in $(seq 0 $(( step )) $(( count*step-1 )) ); do
- echo -ne "Test ${test_name}:$(( i / step ))... "
value=$(printf "%02x\n" $(( offset+i )))
- echo -ne "${prefix}\x${value}${suffix}" >${file_orig_bin}
- ./cmake-build/m68k-disasm -t ${TRACE_FILE} -o ${file_asm} ${file_orig_bin}
- ${AS} -o ${file_as_o} ${file_asm}
- ${OBJCOPY} ${file_as_o} -O binary ${file_as_bin}
- if ! cmp ${file_orig_bin} ${file_as_bin} >/dev/null 2>&1; then
- echo "FAIL"
- cat ${file_asm}
- echo ${file_orig_bin}
- hexdump -Cv ${file_orig_bin} | head -n1
- echo ${file_as_bin}
- hexdump -Cv ${file_as_bin} | head -n1
- break;
- else
- echo "OK"
- #cat ${file_asm}
- fi
+ run_test_simple $test_name "${prefix}\x${value}${suffix}"
done
}
@@ -52,89 +62,89 @@ jsr_m2() {
# 4e90..4e97
#
# All registers
- run_test ${FUNCNAME} "\x4e" 0x90 8 1 ""
+ run_test_iterative ${FUNCNAME} "\x4e" 0x90 8 1 ""
}
jsr_m5() {
# (4ea8..4eaf) xxxx
#
# Zero value
- run_test ${FUNCNAME} "\x4e" 0xa8 8 1 "\x00\x00"
+ run_test_simple ${FUNCNAME} "\x4e\xa8\x00\x00"
# Positive value, all registers
- run_test ${FUNCNAME} "\x4e" 0xa8 8 1 "\x00\x0a"
+ run_test_iterative ${FUNCNAME} "\x4e" 0xa8 8 1 "\x00\x0a"
# Negative value
- run_test ${FUNCNAME} "\x4e" 0xa8 1 1 "\x80\x0f"
+ run_test_simple ${FUNCNAME} "\x4e\xa8\x80\x0f"
}
jsr_m6() {
# (4eb0..4eb7) xxxx
#
# Positive value, Arbitrary An register
- run_test ${FUNCNAME} "\x4e" 0xb0 8 1 "\x00\x0f"
+ run_test_iterative ${FUNCNAME} "\x4e" 0xb0 8 1 "\x00\x0f"
# Negative value
- run_test ${FUNCNAME} "\x4e" 0xb0 1 1 "\x00\xf0"
+ run_test_simple ${FUNCNAME} "\x4e\xb0\x00\xf0"
# Zero displacement
- run_test ${FUNCNAME} "\x4e" 0xb0 1 1 "\x00\x00"
+ run_test_simple ${FUNCNAME} "\x4e\xb0\x00\x00"
# Address register
- run_test ${FUNCNAME} "\x4e" 0xb0 1 1 "\x80\x0a"
+ run_test_simple ${FUNCNAME} "\x4e\xb0\x80\x0a"
# Long displacement, positive
- run_test ${FUNCNAME} "\x4e" 0xb0 1 1 "\x08\x0c"
+ run_test_simple ${FUNCNAME} "\x4e\xb0\x08\x0c"
# Long displacement, negative
- run_test ${FUNCNAME} "\x4e" 0xb0 1 1 "\x08\xb0"
+ run_test_simple ${FUNCNAME} "\x4e\xb0\x08\xb0"
# Arbitrary Xn2
- run_test ${FUNCNAME} "\x4e\xb0" 0x00 8 0x10 "\x0f"
+ run_test_iterative ${FUNCNAME} "\x4e\xb0" 0x00 8 0x10 "\x0f"
}
jsr_m7_xn0() {
# 43b8 xxxx Word displacement
#
# Zero value
- run_test ${FUNCNAME} "\x4e\xb8\x00" 0x00 1 1 ""
+ run_test_simple ${FUNCNAME} "\x4e\xb8\x00\x00"
# Positive value
- run_test ${FUNCNAME} "\x4e\xb8\x00" 0x1f 1 1 ""
+ run_test_simple ${FUNCNAME} "\x4e\xb8\x00\x1f"
# Negative value
- run_test ${FUNCNAME} "\x4e\xb8" 0x8a 1 1 "\x0c"
+ run_test_simple ${FUNCNAME} "\x4e\xb8\x8a\x0c"
}
jsr_m7_xn1() {
# 43b9 xxxx Long displacement
#
# Zero value
- run_test ${FUNCNAME} "\x4e\xb9\x00\x00\x00" 0x00 1 1 ""
+ run_test_simple ${FUNCNAME} "\x4e\xb9\x00\x00\x00\x00"
# Positive value
- run_test ${FUNCNAME} "\x4e\xb9\x10\xbb\x43" 0x1f 1 1 ""
+ run_test_simple ${FUNCNAME} "\x4e\xb9\x10\xbb\x43\x1f"
# Negative value
- run_test ${FUNCNAME} "\x4e\xb9\x80\xcc\xd9" 0x8a 1 1 ""
+ run_test_simple ${FUNCNAME} "\x4e\xb9\x80\xcc\xd9\x8a"
}
jsr_m7_xn2() {
# 43ba xxxx
#
# Zero value
- run_test ${FUNCNAME} "\x4e\xba\x00" 0x00 1 1 ""
+ run_test_simple ${FUNCNAME} "\x4e\xba\x00\x00"
# Positive value
- run_test ${FUNCNAME} "\x4e\xba\x00" 0x1f 1 1 ""
+ run_test_simple ${FUNCNAME} "\x4e\xba\x00\x1f"
# Negative value
- run_test ${FUNCNAME} "\x4e\xba" 0x8a 1 1 "\x0c"
+ run_test_simple ${FUNCNAME} "\x4e\xba\x8a\x0c"
}
jsr_m7_xn3() {
# 43bb xxxx
#
# Positive value, Arbitrary Xn register
- run_test ${FUNCNAME} "\x4e\xbb" 0x00 8 0x10 "\x1a"
+ run_test_iterative ${FUNCNAME} "\x4e\xbb" 0x00 8 0x10 "\x1a"
# Negative value
- run_test ${FUNCNAME} "\x4e" 0xbb 1 1 "\x00\xf0"
+ run_test_simple ${FUNCNAME} "\x4e\xbb\x00\xf0"
# Zero displacement
- run_test ${FUNCNAME} "\x4e" 0xbb 1 1 "\x00\x00"
+ run_test_simple ${FUNCNAME} "\x4e\xbb\x00\x00"
# Address register
- run_test ${FUNCNAME} "\x4e" 0xbb 1 1 "\x80\x0a"
+ run_test_simple ${FUNCNAME} "\x4e\xbb\x80\x0a"
# Long displacement, positive
- run_test ${FUNCNAME} "\x4e" 0xbb 1 1 "\x08\x0c"
+ run_test_simple ${FUNCNAME} "\x4e\xbb\x08\x0c"
# Long displacement, negative
- run_test ${FUNCNAME} "\x4e" 0xbb 1 1 "\x08\xb0"
+ run_test_simple ${FUNCNAME} "\x4e\xbb\x08\xb0"
# Arbitrary Xn2
- run_test ${FUNCNAME} "\x4e\xbb" 0x00 8 0x10 "\x0f"
+ run_test_iterative ${FUNCNAME} "\x4e\xbb" 0x00 8 0x10 "\x0f"
}
jsr_m2