hello-x86.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 x86 -f test/common_x86/functions/malloc.c \
  20. -f functions/calloc.c \
  21. -f test/common_x86/functions/putchar.c \
  22. -f test/test0017/memset.c \
  23. -o test/test0017/memset.M1 || exit 1
  24. # Macro assemble with libc written in M1-Macro
  25. M1 -f test/common_x86/x86_defs.M1 \
  26. -f test/common_x86/libc-core.M1 \
  27. -f test/test0017/memset.M1 \
  28. --LittleEndian \
  29. --architecture x86 \
  30. -o test/test0017/memset.hex2 || exit 2
  31. # Resolve all linkages
  32. hex2 -f test/common_x86/ELF-i386.hex2 -f test/test0017/memset.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test0017-x86-binary --exec_enable || exit 3
  33. # Ensure binary works if host machine supports test
  34. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
  35. then
  36. . ./sha256.sh
  37. # Verify that the resulting file works
  38. ./test/results/test0017-x86-binary >| test/test0017/proof || exit 4
  39. out=$(sha256_check test/test0017/proof.answer)
  40. [ "$out" = "test/test0017/proof: OK" ] || exit 5
  41. fi
  42. exit 0