run_test.sh 2.0 KB

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