2018-02-24 02:18:23 +00: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-02-24 02:18:23 +00:00
|
|
|
set -ex
|
2021-01-11 23:00:00 +00:00
|
|
|
|
|
|
|
TMPDIR="test/test1000/tmp-knight-posix"
|
|
|
|
mkdir -p ${TMPDIR}
|
|
|
|
|
2018-02-24 02:18:23 +00:00
|
|
|
# Build the test
|
2021-01-11 23:00:00 +00:00
|
|
|
./bin/M2-Planet \
|
|
|
|
--architecture knight-posix \
|
2021-02-06 05:45:32 +00:00
|
|
|
-f M2libc/knight/Linux/bootstrap.c \
|
2018-06-22 02:33:50 +01:00
|
|
|
-f cc.h \
|
2021-04-04 03:41:52 +01:00
|
|
|
-f M2libc/bootstrappable.c \
|
2020-11-16 01:28:33 +00:00
|
|
|
-f cc_globals.c \
|
2018-06-22 02:33:50 +01:00
|
|
|
-f cc_reader.c \
|
|
|
|
-f cc_strings.c \
|
|
|
|
-f cc_types.c \
|
|
|
|
-f cc_core.c \
|
2021-01-04 12:45:07 +00:00
|
|
|
-f cc_macro.c \
|
2018-06-22 02:33:50 +01:00
|
|
|
-f cc.c \
|
2018-08-26 21:34:31 +01:00
|
|
|
--debug \
|
2021-01-03 03:00:02 +00:00
|
|
|
--bootstrap-mode \
|
2021-01-11 23:00:00 +00:00
|
|
|
-o ${TMPDIR}/cc.M1 \
|
2021-01-11 23:00:00 +00:00
|
|
|
|| exit 1
|
2018-02-24 02:18:23 +00:00
|
|
|
|
|
|
|
# Macro assemble with libc written in M1-Macro
|
2021-01-11 23:00:00 +00:00
|
|
|
M1 \
|
2021-02-06 05:45:32 +00:00
|
|
|
-f M2libc/knight/knight_defs.M1 \
|
|
|
|
-f M2libc/knight/libc-core.M1 \
|
2021-01-11 23:00:00 +00:00
|
|
|
-f ${TMPDIR}/cc.M1 \
|
2021-01-22 23:00:00 +00:00
|
|
|
--big-endian \
|
2019-03-09 16:56:16 +00:00
|
|
|
--architecture knight-posix \
|
2021-01-11 23:00:00 +00:00
|
|
|
-o ${TMPDIR}/cc.hex2 \
|
2021-01-11 23:00:00 +00:00
|
|
|
|| exit 2
|
2018-02-24 02:18:23 +00:00
|
|
|
|
|
|
|
# Resolve all linkages
|
2021-01-11 23:00:00 +00:00
|
|
|
hex2 \
|
2021-02-06 05:45:32 +00:00
|
|
|
-f M2libc/knight/ELF-knight.hex2 \
|
2021-01-11 23:00:00 +00:00
|
|
|
-f ${TMPDIR}/cc.hex2 \
|
2021-01-22 23:00:00 +00:00
|
|
|
--big-endian \
|
2019-03-09 16:56:16 +00:00
|
|
|
--architecture knight-posix \
|
2021-01-22 23:00:00 +00:00
|
|
|
--base-address 0x00 \
|
2021-01-11 23:00:00 +00:00
|
|
|
-o test/results/test1000-knight-posix-binary \
|
|
|
|
|| exit 3
|
2018-02-24 02:18:23 +00:00
|
|
|
|
|
|
|
# Ensure binary works if host machine supports test
|
2021-02-06 05:45:32 +00:00
|
|
|
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ] && [ ! -z "${KNIGHT_EMULATION}" ]
|
2018-02-24 02:18:23 +00:00
|
|
|
then
|
|
|
|
# Verify that the resulting file works
|
2021-02-06 05:45:32 +00:00
|
|
|
execve_image \
|
|
|
|
./test/results/test1000-knight-posix-binary \
|
2021-01-22 23:00:00 +00:00
|
|
|
--architecture x86 \
|
2021-10-01 01:10:28 +01:00
|
|
|
-f M2libc/sys/types.h \
|
|
|
|
-f M2libc/stddef.h \
|
2021-02-18 02:40:59 +00:00
|
|
|
-f M2libc/x86/Linux/unistd.h \
|
|
|
|
-f M2libc/stdlib.c \
|
|
|
|
-f M2libc/x86/Linux/fcntl.h \
|
|
|
|
-f M2libc/stdio.c \
|
2018-02-24 02:18:23 +00:00
|
|
|
-f cc.h \
|
2021-04-04 03:41:52 +01:00
|
|
|
-f M2libc/bootstrappable.c \
|
2020-11-16 01:28:33 +00:00
|
|
|
-f cc_globals.c \
|
2018-02-24 02:18:23 +00:00
|
|
|
-f cc_reader.c \
|
|
|
|
-f cc_strings.c \
|
|
|
|
-f cc_types.c \
|
|
|
|
-f cc_core.c \
|
2021-01-04 12:45:07 +00:00
|
|
|
-f cc_macro.c \
|
2018-02-24 02:18:23 +00:00
|
|
|
-f cc.c \
|
2021-01-22 23:00:00 +00:00
|
|
|
-o test/test1000/proof \
|
2021-02-06 05:45:32 +00:00
|
|
|
>| ${TMPDIR}/image \
|
2021-01-22 23:00:00 +00:00
|
|
|
|| exit 4
|
2018-02-24 02:18:23 +00:00
|
|
|
|
2021-02-06 05:45:32 +00:00
|
|
|
vm \
|
|
|
|
--POSIX-MODE \
|
|
|
|
--rom ${TMPDIR}/image \
|
|
|
|
--memory 10M \
|
|
|
|
|| exit 5
|
|
|
|
|
|
|
|
. ./sha256.sh
|
|
|
|
out=$(sha256_check test/test1000/proof.answer)
|
|
|
|
[ "$out" = "test/test1000/proof: OK" ] || exit 6
|
|
|
|
elif [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight" ]
|
|
|
|
then
|
|
|
|
# Verify that the resulting file works
|
|
|
|
./test/results/test1000-knight-posix-binary \
|
|
|
|
--architecture x86 \
|
2021-10-01 01:10:28 +01:00
|
|
|
-f M2libc/sys/types.h \
|
|
|
|
-f M2libc/stddef.h \
|
2021-02-18 02:40:59 +00:00
|
|
|
-f M2libc/x86/Linux/unistd.h \
|
|
|
|
-f M2libc/stdlib.c \
|
|
|
|
-f M2libc/x86/Linux/fcntl.h \
|
|
|
|
-f M2libc/stdio.c \
|
2021-02-06 05:45:32 +00:00
|
|
|
-f cc.h \
|
2021-04-04 03:41:52 +01:00
|
|
|
-f M2libc/bootstrappable.c \
|
2021-02-06 05:45:32 +00:00
|
|
|
-f cc_globals.c \
|
|
|
|
-f cc_reader.c \
|
|
|
|
-f cc_strings.c \
|
|
|
|
-f cc_types.c \
|
|
|
|
-f cc_core.c \
|
|
|
|
-f cc_macro.c \
|
|
|
|
-f cc.c \
|
|
|
|
-o test/test1000/proof \
|
|
|
|
|| exit 7
|
|
|
|
|
2019-04-07 22:11:18 +01:00
|
|
|
. ./sha256.sh
|
2020-02-28 23:27:12 +00:00
|
|
|
out=$(sha256_check test/test1000/proof.answer)
|
2021-02-06 05:45:32 +00:00
|
|
|
[ "$out" = "test/test1000/proof: OK" ] || exit 8
|
2018-02-24 02:18:23 +00:00
|
|
|
fi
|
|
|
|
exit 0
|