hello-x86.sh 2.5 KB

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