hello-amd64.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. # Build the test
  19. ./bin/M2-Planet --architecture amd64 -f test/common_amd64/functions/exit.c \
  20. -f test/common_amd64/functions/file.c \
  21. -f functions/file_print.c \
  22. -f test/common_amd64/functions/malloc.c \
  23. -f functions/calloc.c \
  24. -f functions/match.c \
  25. -f functions/in_set.c \
  26. -f functions/numerate_number.c \
  27. -f functions/string.c \
  28. -f functions/require.c \
  29. -f test/test0102/M1-macro.c \
  30. --debug \
  31. --bootstrap-mode \
  32. -o test/test0102/M1-macro.M1 || exit 1
  33. # Build debug footer
  34. blood-elf --64 -f test/test0102/M1-macro.M1 \
  35. --entry _start \
  36. -o test/test0102/M1-macro-footer.M1 || exit 2
  37. # Macro assemble with libc written in M1-Macro
  38. M1 -f test/common_amd64/amd64_defs.M1 \
  39. -f test/common_amd64/libc-core.M1 \
  40. -f test/test0102/M1-macro.M1 \
  41. -f test/test0102/M1-macro-footer.M1 \
  42. --LittleEndian \
  43. --architecture amd64 \
  44. -o test/test0102/M1-macro.hex2 || exit 3
  45. # Resolve all linkages
  46. hex2 -f test/common_amd64/ELF-amd64-debug.hex2 \
  47. -f test/test0102/M1-macro.hex2 \
  48. --LittleEndian \
  49. --architecture amd64 \
  50. --BaseAddress 0x00600000 \
  51. -o test/results/test0102-amd64-binary \
  52. --exec_enable || exit 4
  53. # Ensure binary works if host machine supports test
  54. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ]
  55. then
  56. # Verify that the compiled program returns the correct result
  57. out=$(./test/results/test0102-amd64-binary --version 2>&1 )
  58. [ 0 = $? ] || exit 5
  59. [ "$out" = "M1 1.0.0" ] || exit 6
  60. # Verify that the resulting file works
  61. ./test/results/test0102-amd64-binary -f \
  62. test/common_x86/x86_defs.M1 \
  63. -f test/common_x86/libc-core.M1 \
  64. -f test/test0100/test.M1 \
  65. --LittleEndian \
  66. --architecture x86 \
  67. -o test/test0102/proof || exit 7
  68. . ./sha256.sh
  69. out=$(sha256_check test/test0102/proof.answer)
  70. [ "$out" = "test/test0102/proof: OK" ] || exit 8
  71. fi
  72. exit 0