2018-05-03 01:56:44 +01:00
|
|
|
#! /bin/sh
|
2018-10-18 00:27:06 +01:00
|
|
|
## Copyright (C) 2017 Jeremiah Orians
|
2021-01-11 23:00:00 +00:00
|
|
|
## Copyright (C) 2021 deesix <deesix@tuta.io>
|
2018-10-18 00:27:06 +01:00
|
|
|
## This file is part of M2-Planet.
|
|
|
|
##
|
|
|
|
## M2-Planet is free software: you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published by
|
|
|
|
## the Free Software Foundation, either version 3 of the License, or
|
|
|
|
## (at your option) any later version.
|
|
|
|
##
|
|
|
|
## M2-Planet is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
## You should have received a copy of the GNU General Public License
|
|
|
|
## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-05-03 01:56:44 +01:00
|
|
|
set -x
|
2021-01-11 23:00:00 +00:00
|
|
|
|
|
|
|
TMPDIR="test/test0020/tmp-knight-posix"
|
|
|
|
mkdir -p ${TMPDIR}
|
|
|
|
|
2018-05-03 01:56:44 +01:00
|
|
|
# Build the test
|
2021-01-11 23:00:00 +00:00
|
|
|
bin/M2-Planet \
|
|
|
|
--architecture knight-posix \
|
|
|
|
-f test/common_knight/functions/putchar.c \
|
2019-03-09 16:56:16 +00:00
|
|
|
-f test/common_knight/functions/exit.c \
|
|
|
|
-f test/common_knight/functions/malloc.c \
|
2020-02-28 23:27:12 +00:00
|
|
|
-f test/test0020/struct.c \
|
2021-01-09 17:29:12 +00:00
|
|
|
--bootstrap-mode \
|
2021-01-11 23:00:00 +00:00
|
|
|
-o ${TMPDIR}/struct.M1 \
|
2021-01-11 23:00:00 +00:00
|
|
|
|| exit 1
|
2018-05-03 01:56:44 +01:00
|
|
|
|
|
|
|
# Macro assemble with libc written in M1-Macro
|
2021-01-11 23:00:00 +00:00
|
|
|
M1 \
|
|
|
|
-f test/common_knight/knight_defs.M1 \
|
2019-03-09 16:56:16 +00:00
|
|
|
-f test/common_knight/libc-core.M1 \
|
2021-01-11 23:00:00 +00:00
|
|
|
-f ${TMPDIR}/struct.M1 \
|
2019-03-09 16:56:16 +00:00
|
|
|
--BigEndian \
|
|
|
|
--architecture knight-posix \
|
2021-01-11 23:00:00 +00:00
|
|
|
-o ${TMPDIR}/struct.hex2 \
|
2021-01-11 23:00:00 +00:00
|
|
|
|| exit 2
|
2018-05-03 01:56:44 +01:00
|
|
|
|
|
|
|
# Resolve all linkages
|
2021-01-11 23:00:00 +00:00
|
|
|
hex2 \
|
|
|
|
-f test/common_knight/ELF-knight.hex2 \
|
2021-01-11 23:00:00 +00:00
|
|
|
-f ${TMPDIR}/struct.hex2 \
|
2021-01-11 23:00:00 +00:00
|
|
|
--BigEndian \
|
|
|
|
--architecture knight-posix \
|
|
|
|
--BaseAddress 0x00 \
|
|
|
|
-o test/results/test0020-knight-posix-binary \
|
|
|
|
--exec_enable \
|
|
|
|
|| exit 3
|
2018-05-03 01:56:44 +01:00
|
|
|
|
|
|
|
# Ensure binary works if host machine supports test
|
2019-03-09 16:56:16 +00:00
|
|
|
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
|
2018-05-03 01:56:44 +01:00
|
|
|
then
|
|
|
|
# Verify that the compiled program returns the correct result
|
2020-02-28 23:27:12 +00:00
|
|
|
out=$(./test/results/test0020-knight-posix-binary 2>&1 )
|
2018-05-03 01:56:44 +01:00
|
|
|
[ 20 = $? ] || exit 4
|
|
|
|
[ "$out" = "35419896642975313541989657891634" ] || exit 5
|
|
|
|
fi
|
|
|
|
exit 0
|