hello-knight-posix.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 -x
  18. TMPDIR="test/test0030/tmp-knight-posix"
  19. mkdir -p ${TMPDIR}
  20. # Build the test
  21. bin/M2-Planet \
  22. --architecture knight-posix \
  23. -f test/test0030/fixed_int.c \
  24. -o ${TMPDIR}/fixed_int.M1 \
  25. || exit 1
  26. # Macro assemble with libc written in M1-Macro
  27. M1 \
  28. -f M2libc/knight/knight_defs.M1 \
  29. -f M2libc/knight/libc-core.M1 \
  30. -f ${TMPDIR}/fixed_int.M1 \
  31. --big-endian \
  32. --architecture knight-posix \
  33. -o ${TMPDIR}/fixed_int.hex2 \
  34. || exit 2
  35. # Resolve all linkages
  36. hex2 \
  37. -f M2libc/knight/ELF-knight.hex2 \
  38. -f ${TMPDIR}/fixed_int.hex2 \
  39. --big-endian \
  40. --architecture knight-posix \
  41. --base-address 0x0 \
  42. -o test/results/test0030-knight-posix-binary \
  43. || exit 3
  44. # Ensure binary works if host machine supports test
  45. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ] && [ ! -z "${KNIGHT_EMULATION}" ]
  46. then
  47. # Verify that the resulting file works
  48. vm --POSIX-MODE --rom ./test/results/test0030-knight-posix-binary --memory 2M
  49. [ 0 = $? ] || exit 3
  50. elif [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ]
  51. then
  52. # Verify that the compiled program returns the correct result
  53. ./test/results/test0030-knight-posix-binary
  54. [ 0 = $? ] || exit 3
  55. fi
  56. exit 0