hello-x86.sh 2.4 KB

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