#!/bin/sh test_add64() { result=$("${QEMU}" -B 0x80000000 -s 2k tests/math_add64.elf) # 3.5 # 3.75 # 1.25 # -1.25 expected=$(cat << END 00000003.80000000 00000003.C0000000 00000001.C0000000 FFFFFFFF.C0000000 END ) # TODO: Ideally this test would allow calling the binary repeatedly with # different inputs. test $? -eq 0 && test "$result" = "$expected" } test_mul() { result=$("${QEMU}" -B 0x80000000 -s 2k tests/math_mul.elf) expected=$(cat << END 0000000F 0000003F 0063FF9C FFFFFFEB END ) # TODO: Ideally this test would allow calling the binary repeatedly with # different inputs. test $? -eq 0 && test "$result" = "$expected" } test_div() { result=$("${QEMU}" -B 0x80000000 -s 2k tests/math_div.elf) expected=$(cat << END 00000000 00000007 0000028F 55555553 END ) # TODO: Ideally this test would allow calling the binary repeatedly with # different inputs. test $? -eq 0 && test "$result" = "$expected" } test_divmod() { result=$("${QEMU}" -B 0x80000000 -s 2k tests/math_divmod.elf) expected=$(cat << END 00000000,00000003 00000007,00000000 0000028F,00000023 END ) # TODO: Ideally this test would allow calling the binary repeatedly with # different inputs. test $? -eq 0 && test "$result" = "$expected" } test_clz() { result=$("${QEMU}" -B 0x80000000 -s 2k tests/math_clz.elf) expected=$(cat << END 00000020 0000001F 0000001E 0000001E 0000001C 00000018 00000014 00000010 0000000C 00000008 00000004 00000000 00000000 00000010 END ) # TODO: Ideally this test would allow calling the binary repeatedly with # different inputs. test $? -eq 0 && test "$result" = "$expected" }