Add test2 for knight-posix

This commit is contained in:
Jeremiah Orians 2019-02-23 20:18:53 -05:00
parent b085022577
commit ee1abde0d4
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
35 changed files with 149 additions and 50 deletions

View File

@ -27,6 +27,7 @@ Added support for \0
Added support for GET_MACHINE_FLAGS in tests
Added --architecture flag
Added first knight-posix test
Added second knight-posix test
** Changed
Converted M2-Planet to use GNU style error message
@ -37,6 +38,7 @@ Updated hex2 to current version
Updated get_machine to current version
Updated to mescc-tools 0.6.0 syntax
Changed default architecture to knight-native
Moved x86 specific exit.c and putchar.c to test/common_x86/functions
** Fixed
Fixed typo in file headers

View File

@ -64,7 +64,8 @@ results:
# tests
test: test00-x86-binary \
test00-knight-posix-binary \
test01-binary \
test01-x86-binary \
test01-knight-posix-binary \
test02-binary \
test03-binary \
test04-binary \
@ -98,8 +99,11 @@ test00-x86-binary: M2-Planet | results
test00-knight-posix-binary: M2-Planet | results
test/test00/hello-knight-posix.sh
test01-binary: M2-Planet | results
test/test01/hello.sh
test01-x86-binary: M2-Planet | results
test/test01/hello-x86.sh
test01-knight-posix-binary: M2-Planet | results
test/test01/hello-knight-posix.sh
test02-binary: M2-Planet | results
test/test02/hello.sh

View File

@ -0,0 +1,25 @@
/* Copyright (C) 2016 Jeremiah Orians
* 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/>.
*/
// CONSTANT EXIT_FAILURE 1
// CONSTANT EXIT_SUCCESS 0
void exit(int value)
{
/* Until we need to do a better job */
asm("HALT");
}

View File

@ -0,0 +1,23 @@
/* Copyright (C) 2016 Jeremiah Orians
* 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/>.
*/
void putchar(int c)
{
asm("LOAD R0 R14 0"
"FALSE R1"
"FPUTC");
}

View File

@ -1,6 +1,7 @@
96dcb1cde9bc98c736fb33146982215f4509ae8539475e513e9cef326c78cbda test/results/test00-knight-posix-binary
c52562bd0aabb86ce8ca177f22f8d0455769b444df2d4d62894faab63b7151d8 test/results/test00-x86-binary
eae96857f2b6d8e8ba86ac06e72345ea572622b358b23978bb5f2db1baadf41c test/results/test01-binary
fab674644b9519e8ec39e254e6b13fe5eccb9f861f7d9e7d2f736d40875b7546 test/results/test01-knight-posix-binary
eae96857f2b6d8e8ba86ac06e72345ea572622b358b23978bb5f2db1baadf41c test/results/test01-x86-binary
8ead336d2f3f72d5874230492e0472edec61d355905e8636e3dfb2731695037c test/results/test02-binary
2313cb3f1a2b9eb6bf15f8d43418e15d6c16f7f1b5c22700fdfc2b38beb59192 test/results/test03-binary
b7ddb37063c541c6a315809c4438aa235d6702f54bb64f4ffc88dbe78617de81 test/results/test04-binary

View File

@ -0,0 +1,44 @@
#! /bin/sh
## Copyright (C) 2017 Jeremiah Orians
## 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
# Build the test
bin/M2-Planet --architecture knight-posix -f test/common_knight/functions/putchar.c \
-f test/common_knight/functions/exit.c \
-f test/test01/library_call.c \
-o test/test01/library_call.M1 || exit 1
# Macro assemble with libc written in M1-Macro
M1 -f test/common_knight/knight_defs.M1 \
-f test/common_knight/libc-core.M1 \
-f test/test01/library_call.M1 \
--BigEndian \
--architecture knight-posix \
-o test/test01/library_call.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_knight/ELF-knight.hex2 -f test/test01/library_call.hex2 --BigEndian --architecture knight-posix --BaseAddress 0x0 -o test/results/test01-knight-posix-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ]
then
# Verify that the compiled program returns the correct result
out=$(./test/results/test01-knight-posix-binary 2>&1)
[ 42 = $? ] || exit 3
[ "$out" = "Hello mes" ] || exit 4
fi
exit 0

View File

@ -17,8 +17,8 @@
set -x
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test01/library_call.c \
-o test/test01/library_call.M1 || exit 1
@ -31,13 +31,13 @@ M1 -f test/common_x86/x86_defs.M1 \
-o test/test01/library_call.hex2 || exit 2
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test01/library_call.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test01-binary --exec_enable || exit 3
hex2 -f test/common_x86/ELF-i386.hex2 -f test/test01/library_call.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test01-x86-binary --exec_enable || exit 3
# Ensure binary works if host machine supports test
if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ]
then
# Verify that the compiled program returns the correct result
out=$(./test/results/test01-binary 2>&1)
out=$(./test/results/test01-x86-binary 2>&1)
[ 42 = $? ] || exit 3
[ "$out" = "Hello mes" ] || exit 4
fi

View File

@ -17,8 +17,8 @@
set -x
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test02/if.c \
-o test/test02/if.M1 || exit 1

View File

@ -17,8 +17,8 @@
set -x
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test03/constant.c \
-o test/test03/constant.M1 || exit 1

View File

@ -17,8 +17,8 @@
set -x
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test04/call.c \
-o test/test04/call.M1 || exit 1

View File

@ -17,8 +17,8 @@
set -x
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test05/string.c \
-o test/test05/string.M1 || exit 1

View File

@ -17,7 +17,7 @@
set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/test06/for.c \
-o test/test06/for.M1 || exit 1

View File

@ -17,8 +17,8 @@
set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test07/do.c \
-o test/test07/do.M1 || exit 1

View File

@ -17,8 +17,8 @@
set -x
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f functions/malloc.c \
-f test/test08/struct.c \
-o test/test08/struct.M1 || exit 1

View File

@ -17,8 +17,8 @@
set -x
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test09/goto.c \
-o test/test09/goto.M1 || exit 1

View File

@ -17,8 +17,8 @@
set -x
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f functions/malloc.c \
-f test/test10/nested_struct.c \
-o test/test10/nested_struct.M1 || exit 1

View File

@ -22,7 +22,7 @@ then
./bin/M2-Planet --architecture x86 -f functions/file.c \
-f functions/malloc.c \
-f functions/calloc.c \
-f functions/exit.c \
-f test/common_x86/functions/exit.c \
-f functions/match.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
@ -42,7 +42,7 @@ then
./bin/M2-Planet-seed --architecture x86 -f functions/file.c \
-f functions/malloc.c \
-f functions/calloc.c \
-f functions/exit.c \
-f test/common_x86/functions/exit.c \
-f functions/match.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
@ -78,7 +78,7 @@ ${CC} ${CFLAGS} \
./bin/M2-Planet-gcc --architecture x86 -f functions/file.c \
-f functions/malloc.c \
-f functions/calloc.c \
-f functions/exit.c \
-f test/common_x86/functions/exit.c \
-f functions/match.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
@ -122,7 +122,7 @@ then
./test/results/test100-binary --architecture x86 -f functions/file.c \
-f functions/malloc.c \
-f functions/calloc.c \
-f functions/exit.c \
-f test/common_x86/functions/exit.c \
-f functions/match.c \
-f functions/in_set.c \
-f functions/numerate_number.c \

View File

@ -17,8 +17,8 @@
set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test11/break-do.c \
-o test/test11/break-do.M1 || exit 1

View File

@ -17,8 +17,8 @@
set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test12/break-for.c \
-o test/test12/break-for.M1 || exit 1

View File

@ -17,8 +17,8 @@
set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f test/test13/break-while.c \
-o test/test13/break-while.M1 || exit 1

View File

@ -17,7 +17,7 @@
set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/test14/basic_args.c \
-o test/test14/basic_args.M1 || exit 1

View File

@ -18,7 +18,7 @@
set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/file.c \
-f functions/putchar.c \
-f test/common_x86/functions/putchar.c \
-f test/test15/file_read.c \
-o test/test15/file_read.M1 || exit 1

View File

@ -18,7 +18,7 @@
set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/file.c \
-f functions/putchar.c \
-f test/common_x86/functions/putchar.c \
-f test/test16/file_write.c \
-o test/test16/file_write.M1 || exit 1

View File

@ -19,7 +19,7 @@ set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/malloc.c \
-f functions/calloc.c \
-f functions/putchar.c \
-f test/common_x86/functions/putchar.c \
-f test/test17/memset.c \
-o test/test17/memset.M1 || exit 1

View File

@ -20,7 +20,7 @@ set -ex
bin/M2-Planet --architecture x86 -f functions/file.c \
-f functions/malloc.c \
-f functions/calloc.c \
-f functions/exit.c \
-f test/common_x86/functions/exit.c \
-f functions/match.c \
-f functions/in_set.c \
-f functions/numerate_number.c \

View File

@ -17,8 +17,8 @@
set -x
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
-f functions/exit.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f test/common_x86/functions/exit.c \
-f functions/malloc.c \
-f test/test20/struct.c \
-o test/test20/struct.M1 || exit 1

View File

@ -17,7 +17,7 @@
set -x
# Build the test
./bin/M2-Planet --architecture x86 -f functions/exit.c \
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
-f functions/file.c \
-f functions/file_print.c \
-f functions/malloc.c \

View File

@ -17,7 +17,7 @@
set -x
# Build the test
./bin/M2-Planet --architecture x86 -f functions/exit.c \
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
-f functions/file.c \
-f functions/file_print.c \
-f functions/malloc.c \

View File

@ -17,7 +17,7 @@
set -x
# Build the test
./bin/M2-Planet --architecture x86 -f functions/exit.c \
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
-f functions/file.c \
-f functions/file_print.c \
-f functions/malloc.c \

View File

@ -17,7 +17,7 @@
set -x
# Build the test
./bin/M2-Planet --architecture x86 -f functions/exit.c \
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
-f functions/file.c \
-f functions/file_print.c \
-f functions/malloc.c \

View File

@ -17,7 +17,7 @@
set -x
# Build the test
./bin/M2-Planet --architecture x86 -f functions/exit.c \
./bin/M2-Planet --architecture x86 -f test/common_x86/functions/exit.c \
-f functions/file.c \
-f functions/file_print.c \
-f functions/malloc.c \

View File

@ -25,7 +25,7 @@ set -x
-f functions/match.c \
-f functions/file.c \
-f functions/file_print.c \
-f functions/exit.c \
-f test/common_x86/functions/exit.c \
-f test/test26/lisp.c \
-f test/test26/lisp_cell.c \
-f test/test26/lisp_eval.c \

View File

@ -17,9 +17,9 @@
set -ex
# Build the test
bin/M2-Planet --architecture x86 -f functions/putchar.c \
bin/M2-Planet --architecture x86 -f test/common_x86/functions/putchar.c \
-f functions/getchar.c \
-f functions/exit.c \
-f test/common_x86/functions/exit.c \
-f functions/malloc.c \
-f test/test99/cc500.c \
-o test/test99/cc0.M1 || exit 1