hello-knight-native.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/test0028/tmp-knight-native"
  19. mkdir -p ${TMPDIR}
  20. # Build the test
  21. bin/M2-Planet \
  22. --architecture knight-native \
  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-native_defs.M1 \
  29. -f M2libc/knight/libc-native.M1 \
  30. -f ${TMPDIR}/fixed_int.M1 \
  31. --big-endian \
  32. --architecture knight-native \
  33. -o ${TMPDIR}/fixed_int.hex2 \
  34. || exit 2
  35. # Resolve all linkages
  36. hex2 \
  37. -f ${TMPDIR}/fixed_int.hex2 \
  38. --big-endian \
  39. --architecture knight-native \
  40. --base-address 0x0 \
  41. -o test/results/test0030-knight-native-binary \
  42. || exit 3
  43. # Ensure binary works if host machine supports test
  44. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight-native" ]
  45. then
  46. # Verify that the compiled program returns the correct result
  47. vm --rom ./test/results/test0030-knight-native-binary
  48. [ 0 = $? ] || exit 3
  49. fi
  50. exit 0