hello-amd64.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #! /bin/sh
  2. ## Copyright (C) 2017 Jeremiah Orians
  3. ## Copyright (C) 2021 deesix <deesix@tuta.io>
  4. ## This file is part of M2-Planet.
  5. ##
  6. ## M2-Planet is free software: you can redistribute it and/or modify
  7. ## it under the terms of the GNU General Public License as published by
  8. ## the Free Software Foundation, either version 3 of the License, or
  9. ## (at your option) any later version.
  10. ##
  11. ## M2-Planet is distributed in the hope that it will be useful,
  12. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ## GNU General Public License for more details.
  15. ##
  16. ## You should have received a copy of the GNU General Public License
  17. ## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  18. set -x
  19. TMPDIR="test/test0105/tmp-amd64"
  20. mkdir -p ${TMPDIR}
  21. # Build the test
  22. ./bin/M2-Planet \
  23. --architecture amd64 \
  24. -f test/test0105/lisp.h \
  25. -f test/common_amd64/functions/malloc.c \
  26. -f functions/calloc.c \
  27. -f functions/in_set.c \
  28. -f test/common_amd64/functions/file.c \
  29. -f test/common_amd64/functions/exit.c \
  30. -f functions/numerate_number.c \
  31. -f functions/match.c \
  32. -f functions/file_print.c \
  33. -f test/test0105/lisp.c \
  34. -f test/test0105/lisp_cell.c \
  35. -f test/test0105/lisp_eval.c \
  36. -f test/test0105/lisp_print.c \
  37. -f test/test0105/lisp_read.c \
  38. --debug \
  39. --bootstrap-mode \
  40. -o ${TMPDIR}/lisp.M1 \
  41. || exit 1
  42. # Build debug footer
  43. blood-elf \
  44. --64 \
  45. -f ${TMPDIR}/lisp.M1 \
  46. --entry _start \
  47. -o ${TMPDIR}/lisp-footer.M1 \
  48. || exit 2
  49. # Macro assemble with libc written in M1-Macro
  50. M1 \
  51. -f test/common_amd64/amd64_defs.M1 \
  52. -f test/common_amd64/libc-core.M1 \
  53. -f ${TMPDIR}/lisp.M1 \
  54. -f ${TMPDIR}/lisp-footer.M1 \
  55. --LittleEndian \
  56. --architecture amd64 \
  57. -o ${TMPDIR}/lisp.hex2 \
  58. || exit 3
  59. # Resolve all linkages
  60. hex2 \
  61. -f test/common_amd64/ELF-amd64-debug.hex2 \
  62. -f ${TMPDIR}/lisp.hex2 \
  63. --LittleEndian \
  64. --architecture amd64 \
  65. --BaseAddress 0x00600000 \
  66. -o test/results/test0105-amd64-binary \
  67. --exec_enable \
  68. || exit 4
  69. # Ensure binary works if host machine supports test
  70. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ]
  71. then
  72. # Verify that the compiled program returns the correct result
  73. out=$(./test/results/test0105-amd64-binary --version 2>&1 )
  74. [ 0 = $? ] || exit 5
  75. [ "$out" = "Slow_Lisp 0.1" ] || exit 6
  76. # Verify that the resulting file works
  77. out=$(./test/results/test0105-amd64-binary --file test/test0105/test.scm)
  78. [ "$out" = "42" ] || exit 7
  79. fi
  80. exit 0