run_test.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #! /bin/sh
  2. ## Copyright (C) 2017 Jeremiah Orians
  3. ## This file is part of M2-Planet.
  4. ##
  5. ## M2-Planet is free software: you can redistribute it and/or modify
  6. ## it under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation, either version 3 of the License, or
  8. ## (at your option) any later version.
  9. ##
  10. ## M2-Planet is distributed in the hope that it will be useful,
  11. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ## GNU General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  17. set -ex
  18. ARCH="$1"
  19. . test/env.inc.sh
  20. TMPDIR="test/test0030/tmp-${ARCH}"
  21. mkdir -p ${TMPDIR}
  22. # Build the test
  23. bin/M2-Planet \
  24. --architecture ${ARCH} \
  25. --debug \
  26. -f test/test0030/fixed_int.c \
  27. -o ${TMPDIR}/fixed_int.M1 \
  28. || exit 1
  29. # Build debug footer
  30. blood-elf \
  31. ${BLOOD_ELF_WORD_SIZE_FLAG} \
  32. -f ${TMPDIR}/fixed_int.M1 \
  33. ${ENDIANNESS_FLAG} \
  34. --entry _start \
  35. -o ${TMPDIR}/fixed_int-footer.M1 \
  36. || exit 2
  37. # Macro assemble with libc written in M1-Macro
  38. M1 \
  39. -f M2libc/${ARCH}/${ARCH}_defs.M1 \
  40. -f M2libc/${ARCH}/libc-core.M1 \
  41. -f ${TMPDIR}/fixed_int.M1 \
  42. -f ${TMPDIR}/fixed_int-footer.M1 \
  43. ${ENDIANNESS_FLAG} \
  44. --architecture ${ARCH} \
  45. -o ${TMPDIR}/fixed_int.hex2 \
  46. || exit 2
  47. # Resolve all linkages
  48. hex2 \
  49. -f M2libc/${ARCH}/ELF-${ARCH}-debug.hex2 \
  50. -f ${TMPDIR}/fixed_int.hex2 \
  51. ${ENDIANNESS_FLAG} \
  52. --architecture ${ARCH} \
  53. --base-address ${BASE_ADDRESS} \
  54. -o test/results/test0030-${ARCH}-binary \
  55. || exit 3
  56. # Ensure binary works if host machine supports test
  57. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "${ARCH}" ]
  58. then
  59. . ./sha256.sh
  60. # Verify that the resulting file works
  61. ./test/results/test0030-${ARCH}-binary || exit 4
  62. fi
  63. exit 0