hello-knight-posix.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. TMPDIR="test/test0031/tmp-knight-posix"
  19. mkdir -p ${TMPDIR}
  20. # Build the test
  21. bin/M2-Planet \
  22. --architecture knight-posix \
  23. -f M2libc/sys/types.h \
  24. -f M2libc/stddef.h \
  25. -f M2libc/sys/utsname.h \
  26. -f M2libc/knight/linux/unistd.c \
  27. -f M2libc/knight/linux/fcntl.c \
  28. -f M2libc/knight/linux/sys/stat.c \
  29. -f M2libc/fcntl.c \
  30. -f M2libc/stdlib.c \
  31. -f M2libc/stdio.h \
  32. -f M2libc/stdio.c \
  33. -f M2libc/bootstrappable.c\
  34. -f test/test0031/switch.c \
  35. -o ${TMPDIR}/switch.M1 \
  36. || exit 1
  37. # Macro assemble with libc written in M1-Macro
  38. M1 \
  39. -f M2libc/knight/knight_defs.M1 \
  40. -f M2libc/knight/libc-core.M1 \
  41. -f ${TMPDIR}/switch.M1 \
  42. --big-endian \
  43. --architecture knight-posix \
  44. -o ${TMPDIR}/switch.hex2 \
  45. || exit 2
  46. # Resolve all linkages
  47. hex2 \
  48. -f M2libc/knight/ELF-knight.hex2 \
  49. -f ${TMPDIR}/switch.hex2 \
  50. --big-endian \
  51. --architecture knight-posix \
  52. --base-address 0x0 \
  53. -o test/results/test0031-knight-posix-binary \
  54. || exit 3
  55. # Ensure binary works if host machine supports test
  56. if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ] && [ ! -z "${KNIGHT_EMULATION}" ]
  57. then
  58. # Verify that the resulting file works
  59. vm --POSIX-MODE --rom ./test/results/test0031-knight-posix-binary --memory 2M
  60. [ 0 = $? ] || exit 3
  61. elif [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ]
  62. then
  63. # Verify that the compiled program returns the correct result
  64. ./test/results/test0031-knight-posix-binary
  65. [ 0 = $? ] || exit 3
  66. fi
  67. exit 0