2019-04-07 22:11:18 +01:00
|
|
|
#! /bin/sh
|
|
|
|
## Copyright (C) 2017 Jeremiah Orians
|
2021-01-11 23:00:00 +00:00
|
|
|
## Copyright (C) 2021 deesix <deesix@tuta.io>
|
2019-04-07 22:11:18 +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/>.
|
|
|
|
|
|
|
|
set -x
|
2021-01-11 23:00:00 +00:00
|
|
|
|
|
|
|
TMPDIR="test/test0104/tmp-armv7l"
|
|
|
|
mkdir -p ${TMPDIR}
|
|
|
|
|
2019-04-07 22:11:18 +01:00
|
|
|
# Build the test
|
2021-01-20 23:00:00 +00:00
|
|
|
bin/M2-Planet \
|
2021-01-11 23:00:00 +00:00
|
|
|
--architecture armv7l \
|
2021-01-20 23:00:00 +00:00
|
|
|
-f M2libc/armv7l/Linux/unistd.h \
|
|
|
|
-f M2libc/stdlib.c \
|
|
|
|
-f M2libc/armv7l/Linux/fcntl.h \
|
|
|
|
-f M2libc/stdio.c \
|
2019-04-07 22:11:18 +01:00
|
|
|
-f functions/file_print.c \
|
|
|
|
-f functions/match.c \
|
|
|
|
-f functions/in_set.c \
|
|
|
|
-f functions/numerate_number.c \
|
2020-02-28 23:27:12 +00:00
|
|
|
-f test/test0104/kaem.c \
|
2019-04-07 22:11:18 +01:00
|
|
|
--debug \
|
2021-01-11 23:00:00 +00:00
|
|
|
-o ${TMPDIR}/kaem.M1 \
|
2021-01-11 23:00:00 +00:00
|
|
|
|| exit 1
|
2019-04-07 22:11:18 +01:00
|
|
|
|
|
|
|
# Build debug footer
|
2021-01-11 23:00:00 +00:00
|
|
|
blood-elf \
|
2021-01-11 23:00:00 +00:00
|
|
|
-f ${TMPDIR}/kaem.M1 \
|
2020-05-01 03:35:22 +01:00
|
|
|
--entry _start \
|
2021-01-11 23:00:00 +00:00
|
|
|
-o ${TMPDIR}/kaem-footer.M1 \
|
2021-01-11 23:00:00 +00:00
|
|
|
|| exit 2
|
2019-04-07 22:11:18 +01:00
|
|
|
|
|
|
|
# Macro assemble with libc written in M1-Macro
|
2021-01-11 23:00:00 +00:00
|
|
|
M1 \
|
2021-01-20 23:00:00 +00:00
|
|
|
-f M2libc/armv7l/armv7l_defs.M1 \
|
|
|
|
-f M2libc/armv7l/libc-full.M1 \
|
2021-01-11 23:00:00 +00:00
|
|
|
-f ${TMPDIR}/kaem.M1 \
|
|
|
|
-f ${TMPDIR}/kaem-footer.M1 \
|
2021-01-22 23:00:00 +00:00
|
|
|
--little-endian \
|
2019-04-07 22:11:18 +01:00
|
|
|
--architecture armv7l \
|
2021-01-11 23:00:00 +00:00
|
|
|
-o ${TMPDIR}/kaem.hex2 \
|
2021-01-11 23:00:00 +00:00
|
|
|
|| exit 3
|
2019-04-07 22:11:18 +01:00
|
|
|
|
|
|
|
# Resolve all linkages
|
2021-01-11 23:00:00 +00:00
|
|
|
hex2 \
|
2021-01-20 23:00:00 +00:00
|
|
|
-f M2libc/armv7l/ELF-armv7l-debug.hex2 \
|
2021-01-11 23:00:00 +00:00
|
|
|
-f ${TMPDIR}/kaem.hex2 \
|
2021-01-22 23:00:00 +00:00
|
|
|
--little-endian \
|
2019-04-07 22:11:18 +01:00
|
|
|
--architecture armv7l \
|
2021-01-22 23:00:00 +00:00
|
|
|
--base-address 0x10000 \
|
2020-02-28 23:27:12 +00:00
|
|
|
-o test/results/test0104-armv7l-binary \
|
2021-01-11 23:00:00 +00:00
|
|
|
|| exit 4
|
2019-04-07 22:11:18 +01:00
|
|
|
|
2019-04-21 18:22:41 +01:00
|
|
|
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ]
|
|
|
|
then
|
|
|
|
# Verify that the compiled program returns the correct result
|
2020-02-28 23:27:12 +00:00
|
|
|
out=$(./test/results/test0104-armv7l-binary --version 2>&1 )
|
2019-04-21 18:22:41 +01:00
|
|
|
[ 0 = $? ] || exit 5
|
2020-02-01 22:18:27 +00:00
|
|
|
[ "$out" = "kaem version 0.6.0" ] || exit 6
|
2019-04-21 18:22:41 +01:00
|
|
|
|
|
|
|
# Verify that the resulting file works
|
2020-02-28 23:27:12 +00:00
|
|
|
out=$(./test/results/test0104-armv7l-binary --file test/test0104/kaem.run)
|
2019-04-21 18:22:41 +01:00
|
|
|
[ "$out" = "hello world" ] || exit 7
|
|
|
|
fi
|
2019-04-07 22:11:18 +01:00
|
|
|
exit 0
|