hello-knight-native.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. # Build the test
  19. bin/M2-Planet --architecture knight-native \
  20. -f test/common_knight/functions/putchar-tape2.c \
  21. -f test/common_knight/functions/getchar-tape1.c \
  22. -f test/common_knight/functions/exit-native.c \
  23. -f test/common_knight/functions/malloc.c \
  24. -f test/test0106/cc500.c \
  25. -o test/test0106/cc0.M1 || exit 1
  26. # Macro assemble with libc written in M1-Macro
  27. M1 -f test/common_knight/knight-native_defs.M1 \
  28. -f test/common_knight/libc-native-file.M1 \
  29. -f test/test0106/cc0.M1 \
  30. --BigEndian \
  31. --architecture knight-native \
  32. -o test/test0106/cc0.hex2 || exit 2
  33. # Resolve all linkages
  34. hex2 -f test/test0106/cc0.hex2 --BigEndian --architecture knight-native --BaseAddress 0x00 -o test/results/test0106-knight-native-binary --exec_enable || exit 3
  35. # Ensure binary works if host machine supports test
  36. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
  37. then
  38. . ./sha256.sh
  39. # Verify that the compiled program can compile itself
  40. ./test/results/test0106-binary < test/test0106/cc500.c >| test/test0106/cc1 || exit 4
  41. out=$(sha256_check test/test0106/proof0.answer)
  42. [ "$out" = "test/test0106/cc1: OK" ] || exit 5
  43. fi
  44. exit 0