diff --git a/CHANGELOG.org b/CHANGELOG.org index 2115009..56c0ff3 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -26,13 +26,7 @@ Added support for octal and binary numbers 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 -Added third knight-posix test -Added fourth knight-posix test -Added fifth knight-posix test -Added sixth knight-posix test -Added seventh knight-posix test +Added 10/24 working tests for knight-posix Added working HEAP/malloc to knight-posix ** Changed @@ -45,6 +39,7 @@ 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 +Relocated x86 specific libc.M1 to test/common_x86 ** Fixed Fixed typo in file headers diff --git a/makefile b/makefile index 76cc133..82bb326 100644 --- a/makefile +++ b/makefile @@ -71,6 +71,8 @@ test: test00-knight-posix-binary \ test06-knight-posix-binary \ test07-knight-posix-binary \ test08-knight-posix-binary \ + test09-knight-posix-binary \ + test10-knight-posix-binary \ test00-x86-binary \ test01-x86-binary \ test02-x86-binary \ @@ -80,8 +82,8 @@ test: test00-knight-posix-binary \ test06-x86-binary \ test07-x86-binary \ test08-x86-binary \ - test09-binary \ - test10-binary \ + test09-x86-binary \ + test10-x86-binary \ test11-binary \ test12-binary \ test13-binary \ @@ -127,6 +129,12 @@ test07-knight-posix-binary: M2-Planet | results test08-knight-posix-binary: M2-Planet | results test/test08/hello-knight-posix.sh +test09-knight-posix-binary: M2-Planet | results + test/test09/hello-knight-posix.sh + +test10-knight-posix-binary: M2-Planet | results + test/test10/hello-knight-posix.sh + test00-x86-binary: M2-Planet | results test/test00/hello-x86.sh @@ -154,11 +162,11 @@ test07-x86-binary: M2-Planet | results test08-x86-binary: M2-Planet | results test/test08/hello-x86.sh -test09-binary: M2-Planet | results - test/test09/hello.sh +test09-x86-binary: M2-Planet | results + test/test09/hello-x86.sh -test10-binary: M2-Planet | results - test/test10/hello.sh +test10-x86-binary: M2-Planet | results + test/test10/hello-x86.sh test11-binary: M2-Planet | results test/test11/hello.sh diff --git a/test/test.answers b/test/test.answers index b87cf69..2633d9c 100644 --- a/test/test.answers +++ b/test/test.answers @@ -16,8 +16,10 @@ b5b76320ccda887a30b0bbefc2a5c302c8f2aa3c398d92ef3a79526690b25d6f test/results/t a9a3e332d13ded5f80d7431f8717f26527b3722b33ea57760a9a5723dffc099c test/results/test07-x86-binary 08bc1fb86c1df73b21e0b68e76572a33477f8943abdd16433d00ef231195bd22 test/results/test08-knight-posix-binary f1c01feb865c4d552033186d9ce50dd39468a7e8aebf762886c13ad3e03b5011 test/results/test08-x86-binary -3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-binary -020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-binary +ae993dd3c49b61f8d7d2b3dcf1d182adbf552135491fd903a371ad9122eb0697 test/results/test09-knight-posix-binary +3b39e72f3de90ed690adfaf6145af46157cef2ec5e72867ac577fa27a0229894 test/results/test09-x86-binary +bdea362acff602d855c8298456b59bac78480a5e78af4476646262537175a3f6 test/results/test10-knight-posix-binary +020e86020819cc4963e6185b22e534fcf8306b6cb116f12643f254a24688ff0a test/results/test10-x86-binary 9a0edc49d1078ffc7ed2578e50198e9e7695c2f26151a3d6e76bab7f2db6872c test/results/test100-binary 3fd11bad4a426ce1ff8fd9c6d7d2b943effae9f3f5740b7376e426e9b0555851 test/results/test11-binary f98ab8e4bb35580e0dde96126d7a56aff66bda208d02c8d89390b40d6cff591c test/results/test12-binary diff --git a/test/test09/hello-knight-posix.sh b/test/test09/hello-knight-posix.sh new file mode 100755 index 0000000..48f3d1c --- /dev/null +++ b/test/test09/hello-knight-posix.sh @@ -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 . + +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/test09/goto.c \ + -o test/test09/goto.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/test09/goto.M1 \ + --BigEndian \ + --architecture knight-posix \ + -o test/test09/goto.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/common_knight/ELF-knight.hex2 -f test/test09/goto.hex2 --BigEndian --architecture knight-posix --BaseAddress 0x00 -o test/results/test09-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/test09-knight-posix-binary 2>&1 ) + [ 42 = $? ] || exit 4 + [ "$out" = "Hello mes" ] || exit 5 +fi +exit 0 diff --git a/test/test09/hello.sh b/test/test09/hello-x86.sh similarity index 94% rename from test/test09/hello.sh rename to test/test09/hello-x86.sh index 06d805e..1471804 100755 --- a/test/test09/hello.sh +++ b/test/test09/hello-x86.sh @@ -31,13 +31,13 @@ M1 -f test/common_x86/x86_defs.M1 \ -o test/test09/goto.hex2 || exit 2 # Resolve all linkages -hex2 -f test/common_x86/ELF-i386.hex2 -f test/test09/goto.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test09-binary --exec_enable || exit 3 +hex2 -f test/common_x86/ELF-i386.hex2 -f test/test09/goto.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test09-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/test09-binary 2>&1 ) + out=$(./test/results/test09-x86-binary 2>&1 ) [ 42 = $? ] || exit 4 [ "$out" = "Hello mes" ] || exit 5 fi diff --git a/test/test10/hello-knight-posix.sh b/test/test10/hello-knight-posix.sh new file mode 100755 index 0000000..c859055 --- /dev/null +++ b/test/test10/hello-knight-posix.sh @@ -0,0 +1,45 @@ +#! /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 . + +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/common_knight/functions/malloc.c \ + -f test/test10/nested_struct.c \ + -o test/test10/nested_struct.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/test10/nested_struct.M1 \ + --BigEndian \ + --architecture knight-posix \ + -o test/test10/nested_struct.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/common_knight/ELF-knight.hex2 -f test/test10/nested_struct.hex2 --BigEndian --architecture knight-posix --BaseAddress 0x00 -o test/results/test10-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/test10-knight-posix-binary 2>&1 ) + [ 12 = $? ] || exit 4 + [ "$out" = "35419896642975313541989657891634" ] || exit 5 +fi +exit 0 diff --git a/test/test10/hello.sh b/test/test10/hello-x86.sh similarity index 93% rename from test/test10/hello.sh rename to test/test10/hello-x86.sh index 874ff87..1f38c24 100755 --- a/test/test10/hello.sh +++ b/test/test10/hello-x86.sh @@ -32,13 +32,13 @@ M1 -f test/common_x86/x86_defs.M1 \ -o test/test10/nested_struct.hex2 || exit 2 # Resolve all linkages -hex2 -f test/common_x86/ELF-i386.hex2 -f test/test10/nested_struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test10-binary --exec_enable || exit 3 +hex2 -f test/common_x86/ELF-i386.hex2 -f test/test10/nested_struct.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test10-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/test10-binary 2>&1 ) + out=$(./test/results/test10-x86-binary 2>&1 ) [ 12 = $? ] || exit 4 [ "$out" = "35419896642975313541989657891634" ] || exit 5 fi