hello-amd64.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 amd64 \
  20. -f test/common_amd64/functions/file.c \
  21. -f test/common_amd64/functions/malloc.c \
  22. -f functions/calloc.c \
  23. -f test/common_amd64/functions/exit.c \
  24. -f functions/match.c \
  25. -f functions/in_set.c \
  26. -f functions/numerate_number.c \
  27. -f functions/file_print.c \
  28. -f functions/number_pack.c \
  29. -f functions/string.c \
  30. -f functions/require.c \
  31. -f cc.h \
  32. -f cc_reader.c \
  33. -f cc_strings.c \
  34. -f cc_types.c \
  35. -f cc_core.c \
  36. -f cc.c \
  37. --debug \
  38. -o test/test1000/cc.M1 || exit 1
  39. # Build debug footer
  40. blood-elf --64 -f test/test1000/cc.M1 \
  41. --entry _start \
  42. -o test/test1000/cc-footer.M1 || exit 2
  43. # Macro assemble with libc written in M1-Macro
  44. M1 -f test/common_amd64/amd64_defs.M1 \
  45. -f test/common_amd64/libc-core.M1 \
  46. -f test/test1000/cc.M1 \
  47. -f test/test1000/cc-footer.M1 \
  48. --LittleEndian \
  49. --architecture amd64 \
  50. -o test/test1000/cc.hex2 || exit 3
  51. # Resolve all linkages
  52. hex2 -f test/common_amd64/ELF-amd64-debug.hex2 \
  53. -f test/test1000/cc.hex2 \
  54. --LittleEndian \
  55. --architecture amd64 \
  56. --BaseAddress 0x00600000 \
  57. -o test/results/test1000-amd64-binary --exec_enable || exit 4
  58. # Ensure binary works if host machine supports test
  59. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ]
  60. then
  61. # Verify that the resulting file works
  62. ./test/results/test1000-amd64-binary --architecture x86 \
  63. -f test/common_x86/functions/file.c \
  64. -f test/common_x86/functions/malloc.c \
  65. -f functions/calloc.c \
  66. -f test/common_x86/functions/exit.c \
  67. -f functions/match.c \
  68. -f functions/in_set.c \
  69. -f functions/numerate_number.c \
  70. -f functions/file_print.c \
  71. -f functions/number_pack.c \
  72. -f functions/string.c \
  73. -f functions/require.c \
  74. -f cc.h \
  75. -f cc_reader.c \
  76. -f cc_strings.c \
  77. -f cc_types.c \
  78. -f cc_core.c \
  79. -f cc.c \
  80. -o test/test1000/proof || exit 5
  81. . ./sha256.sh
  82. out=$(sha256_check test/test1000/proof.answer)
  83. [ "$out" = "test/test1000/proof: OK" ] || exit 6
  84. [ ! -e bin/M2-Planet ] && mv test/results/test1000-amd64-binary bin/M2-Planet
  85. fi
  86. exit 0