hello-knight-posix.sh 2.3 KB

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