diff --git a/makefile b/makefile index ede4e54..d7a42e0 100644 --- a/makefile +++ b/makefile @@ -92,6 +92,7 @@ clean: ./test/test24/cleanup.sh ./test/test25/cleanup.sh ./test/test26/cleanup.sh + ./test/test27/cleanup.sh ./test/test99/cleanup.sh ./test/test100/cleanup.sh @@ -130,6 +131,7 @@ test: test00-aarch64-binary \ test24-aarch64-binary \ test25-aarch64-binary \ test26-aarch64-binary \ + test27-aarch64-binary \ test99-aarch64-binary \ test100-aarch64-binary \ test00-amd64-binary \ @@ -159,6 +161,7 @@ test: test00-aarch64-binary \ test24-amd64-binary \ test25-amd64-binary \ test26-amd64-binary \ + test27-amd64-binary \ test99-amd64-binary \ test100-amd64-binary \ test00-knight-posix-binary \ @@ -186,6 +189,7 @@ test: test00-aarch64-binary \ test22-knight-posix-binary \ test23-knight-posix-binary \ test24-knight-posix-binary \ + test27-knight-posix-binary \ test99-knight-posix-binary \ test100-knight-posix-binary \ test00-knight-native-binary\ @@ -233,6 +237,7 @@ test: test00-aarch64-binary \ test24-armv7l-binary \ test25-armv7l-binary \ test26-armv7l-binary \ + test27-armv7l-binary \ test99-armv7l-binary \ test100-armv7l-binary \ test00-x86-binary \ @@ -262,6 +267,7 @@ test: test00-aarch64-binary \ test24-x86-binary \ test25-x86-binary \ test26-x86-binary \ + test27-x86-binary \ test99-x86-binary \ test100-x86-binary | results sha256sum -c test/test.answers @@ -434,6 +440,9 @@ test25-amd64-binary: M2-Planet | results test26-amd64-binary: M2-Planet | results test/test26/hello-amd64.sh +test27-amd64-binary: M2-Planet | results + test/test27/hello-amd64.sh + test99-amd64-binary: M2-Planet | results test/test99/hello-amd64.sh @@ -515,6 +524,9 @@ test23-knight-posix-binary: M2-Planet | results test24-knight-posix-binary: M2-Planet | results test/test24/hello-knight-posix.sh +test27-knight-posix-binary: M2-Planet | results + test/test27/hello-knight-posix.sh + test99-knight-posix-binary: M2-Planet | results test/test99/hello-knight-posix.sh @@ -656,6 +668,9 @@ test25-armv7l-binary: M2-Planet | results test26-armv7l-binary: M2-Planet | results test/test26/hello-armv7l.sh +test27-armv7l-binary: M2-Planet | results + test/test27/hello-armv7l.sh + test99-armv7l-binary: M2-Planet | results test/test99/hello-armv7l.sh @@ -743,6 +758,9 @@ test25-x86-binary: M2-Planet | results test26-x86-binary: M2-Planet | results test/test26/hello-x86.sh +test27-x86-binary: M2-Planet | results + test/test27/hello-x86.sh + test99-x86-binary: M2-Planet | results test/test99/hello-x86.sh diff --git a/test/test.answers b/test/test.answers index f7c47df..49c30bc 100644 --- a/test/test.answers +++ b/test/test.answers @@ -153,6 +153,11 @@ f414d86f296579ce1f9b6d21734c447ffe7327d324d43dfed5f4c1d20b322915 test/results/t 60206125928d77a758cd73ec8e85f8592423ce678570ebbe7876b71dc38aaeaf test/results/test26-amd64-binary 649349e01a90ce93ba72ba1b9bb81a9bd9d79b580ddff366173c98835c10b976 test/results/test26-armv7l-binary 576511f1f6699e7798bcab2f36bf8eb86825fd13748770b17f46c3a691200b01 test/results/test26-x86-binary +12de91f702b0ced71801c1662dc0a3e253158238e1d1a0b9bc54015a24fd77cc test/results/test27-aarch64-binary +1250294c2fddcdd37072fef4c753de3bd5b1a5f754d75448044211116be08bd9 test/results/test27-amd64-binary +669af3d269283cb44ae6f29ff7f0522e615380befe0a5a5e0fe731f122236f0a test/results/test27-armv7l-binary +d83e0aae5b335f34a528bbb6c213bbef9d993abae335e0f909183bc6debfd37b test/results/test27-knight-posix-binary +cc21839d9b89016cb9ccc059dfbe19c2490c2527975401812d950bf12f716c85 test/results/test27-x86-binary fd72ce6ebbf8263ef9fdff9ca7d789a55ba399ab222c2f5f93b138c61830376d test/results/test99-aarch64-binary 717c42e1a1a91ef5b67ce298bc92a148418a5dec6761a358a52b22a01f16c928 test/results/test99-amd64-binary 4e759b212b087824f7b0f14c5147272c9984c4a4d00074b2fd771c3d004c9aec test/results/test99-armv7l-binary diff --git a/test/test27/.gitignore b/test/test27/.gitignore new file mode 100644 index 0000000..f19c6dc --- /dev/null +++ b/test/test27/.gitignore @@ -0,0 +1,18 @@ +## 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 . +# Ignore the files created by script +*.M1 +*.hex2 diff --git a/test/test27/chdir.c b/test/test27/chdir.c new file mode 100644 index 0000000..7b0b3a6 --- /dev/null +++ b/test/test27/chdir.c @@ -0,0 +1,72 @@ +/* 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 . + */ + +#define MAX_STRING 4096 +// CONSTANT MAX_STRING 4096 + +int main() +{ + char* current_path = calloc(MAX_STRING, sizeof(char)); + getcwd(current_path, MAX_STRING); + char* base_path = calloc(MAX_STRING, sizeof(char)); + copy_string(base_path, current_path); + + /* Test they all evaluate to the same */ + char* current_path_getwd = calloc(MAX_STRING, sizeof(char)); + getwd(current_path_getwd); + if(!match(current_path, current_path_getwd)) + { + return 1; + } + char* current_path_dir_name = calloc(MAX_STRING, sizeof(char)); + current_path_dir_name = get_current_dir_name(); + if(!match(current_path, current_path_dir_name)) + { + return 2; + } + + /* Test chdir works */ + int chdir_rc = chdir(prepend_string(base_path, "/test/test27")); + if(chdir_rc != 0) + { + return 3; + } + getcwd(current_path, MAX_STRING); + if(!match(current_path, prepend_string(base_path, "/test/test27"))) + { + return 4; + } + chdir(prepend_string(current_path, "/../..")); + getcwd(current_path, MAX_STRING); + + /* Test fchdir works */ + FILE* fchdir_fd = open(prepend_string(base_path, "/test/test27"), 0, 0); + int fchdir_rc = fchdir(fchdir_fd); + if(fchdir_rc != 0) + { + return 5; + } + getcwd(current_path, MAX_STRING); + if(!match(current_path, prepend_string(base_path, "/test/test27"))) + { + return 6; + } + chdir(prepend_string(current_path, "/../..")); + + /* All tests passed */ + return 0; +} diff --git a/test/test27/cleanup.sh b/test/test27/cleanup.sh new file mode 100755 index 0000000..a3c57c6 --- /dev/null +++ b/test/test27/cleanup.sh @@ -0,0 +1,19 @@ +#! /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 . +rm -f test/test27/chdir.M1 +rm -f test/test27/chdir.hex2 +exit 0 diff --git a/test/test27/hello-aarch64.sh b/test/test27/hello-aarch64.sh new file mode 100755 index 0000000..5cd873e --- /dev/null +++ b/test/test27/hello-aarch64.sh @@ -0,0 +1,52 @@ +#! /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 aarch64 \ + -f test/common_aarch64/functions/chdir.c \ + -f test/common_aarch64/functions/malloc.c \ + -f test/common_aarch64/functions/getcwd.c \ + -f test/common_aarch64/functions/exit.c \ + -f test/common_aarch64/functions/file.c \ + -f functions/calloc.c \ + -f functions/string.c \ + -f functions/match.c \ + -f functions/file_print.c \ + -f test/test27/chdir.c \ + -o test/test27/chdir.M1 || exit 1 + +# Macro assemble with libc written in M1-Macro +M1 -f test/common_aarch64/aarch64_defs.M1 \ + -f test/common_aarch64/libc-core.M1 \ + -f test/test27/chdir.M1 \ + --LittleEndian \ + --architecture aarch64 \ + -o test/test27/chdir.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/common_aarch64/ELF-aarch64.hex2 -f test/test27/chdir.hex2 --LittleEndian --architecture aarch64 --BaseAddress 0x40000 -o test/results/test27-aarch64-binary --exec_enable || exit 3 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "aarch64" ] +then + . ./sha256.sh + # Verify that the resulting file works + ./test/results/test27-aarch64-binary + [ 0 = $? ] || exit 4 +fi +exit 0 diff --git a/test/test27/hello-amd64.sh b/test/test27/hello-amd64.sh new file mode 100755 index 0000000..af6fb49 --- /dev/null +++ b/test/test27/hello-amd64.sh @@ -0,0 +1,52 @@ +#! /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 amd64 \ + -f test/common_amd64/functions/chdir.c \ + -f test/common_amd64/functions/malloc.c \ + -f test/common_amd64/functions/getcwd.c \ + -f test/common_amd64/functions/exit.c \ + -f test/common_amd64/functions/file.c \ + -f functions/calloc.c \ + -f functions/string.c \ + -f functions/match.c \ + -f functions/file_print.c \ + -f test/test27/chdir.c \ + -o test/test27/chdir.M1 || exit 1 + +# Macro assemble with libc written in M1-Macro +M1 -f test/common_amd64/amd64_defs.M1 \ + -f test/common_amd64/libc-core.M1 \ + -f test/test27/chdir.M1 \ + --LittleEndian \ + --architecture amd64 \ + -o test/test27/chdir.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/common_amd64/ELF-amd64.hex2 -f test/test27/chdir.hex2 --LittleEndian --architecture amd64 --BaseAddress 0x00600000 -o test/results/test27-amd64-binary --exec_enable || exit 3 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "amd64" ] +then + . ./sha256.sh + # Verify that the resulting file works + ./test/results/test27-amd64-binary + [ 0 = $? ] || exit 4 +fi +exit 0 diff --git a/test/test27/hello-armv7l.sh b/test/test27/hello-armv7l.sh new file mode 100755 index 0000000..6ab4e29 --- /dev/null +++ b/test/test27/hello-armv7l.sh @@ -0,0 +1,52 @@ +#! /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 armv7l \ + -f test/common_armv7l/functions/chdir.c \ + -f test/common_armv7l/functions/malloc.c \ + -f test/common_armv7l/functions/getcwd.c \ + -f test/common_armv7l/functions/exit.c \ + -f test/common_armv7l/functions/file.c \ + -f functions/calloc.c \ + -f functions/string.c \ + -f functions/match.c \ + -f functions/file_print.c \ + -f test/test27/chdir.c \ + -o test/test27/chdir.M1 || exit 1 + +# Macro assemble with libc written in M1-Macro +M1 -f test/common_armv7l/armv7l_defs.M1 \ + -f test/common_armv7l/libc-core.M1 \ + -f test/test27/chdir.M1 \ + --LittleEndian \ + --architecture armv7l \ + -o test/test27/chdir.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/common_armv7l/ELF-armv7l.hex2 -f test/test27/chdir.hex2 --LittleEndian --architecture armv7l --BaseAddress 0x10000 -o test/results/test27-armv7l-binary --exec_enable || exit 3 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "armv7l" ] +then + . ./sha256.sh + # Verify that the resulting file works + ./test/results/test27-armv7l-binary + [ 0 = $? ] || exit 4 +fi +exit 0 diff --git a/test/test27/hello-knight-posix.sh b/test/test27/hello-knight-posix.sh new file mode 100755 index 0000000..9c2d4cb --- /dev/null +++ b/test/test27/hello-knight-posix.sh @@ -0,0 +1,52 @@ +#! /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/chdir.c \ + -f test/common_knight/functions/malloc.c \ + -f test/common_knight/functions/getcwd.c \ + -f test/common_knight/functions/exit.c \ + -f test/common_knight/functions/file.c \ + -f functions/calloc.c \ + -f functions/string.c \ + -f functions/match.c \ + -f functions/file_print.c \ + -f test/test27/chdir.c \ + -o test/test27/chdir.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/test27/chdir.M1 \ + --BigEndian \ + --architecture knight-posix \ + -o test/test27/chdir.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/test27/chdir.hex2 --BigEndian --architecture knight-posix --BaseAddress 0x0 -o test/results/test27-knight-posix-binary --exec_enable || exit 3 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "knight*" ] +then + . ./sha256.sh + # Verify that the resulting file works + ./test/results/test27-knight-posix-binary + [ 0 = $? ] || exit 4 +fi +exit 0 diff --git a/test/test27/hello-x86.sh b/test/test27/hello-x86.sh new file mode 100755 index 0000000..49c2eff --- /dev/null +++ b/test/test27/hello-x86.sh @@ -0,0 +1,54 @@ +#! /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 x86 \ + -f test/common_x86/functions/chdir.c \ + -f test/common_x86/functions/malloc.c \ + -f test/common_x86/functions/getcwd.c \ + -f test/common_x86/functions/fork.c \ + -f test/common_x86/functions/execve.c \ + -f test/common_x86/functions/exit.c \ + -f test/common_x86/functions/file.c \ + -f functions/calloc.c \ + -f functions/string.c \ + -f functions/match.c \ + -f functions/file_print.c \ + -f test/test27/chdir.c \ + -o test/test27/chdir.M1 || exit 1 + +# Macro assemble with libc written in M1-Macro +M1 -f test/common_x86/x86_defs.M1 \ + -f test/common_x86/libc-core.M1 \ + -f test/test27/chdir.M1 \ + --LittleEndian \ + --architecture x86 \ + -o test/test27/chdir.hex2 || exit 2 + +# Resolve all linkages +hex2 -f test/common_x86/ELF-i386.hex2 -f test/test27/chdir.hex2 --LittleEndian --architecture x86 --BaseAddress 0x8048000 -o test/results/test27-x86-binary --exec_enable || exit 3 + +# Ensure binary works if host machine supports test +if [ "$(get_machine ${GET_MACHINE_FLAGS})" = "x86" ] +then + . ./sha256.sh + # Verify that the resulting file works + ./test/results/test27-x86-binary + [ 0 = $? ] || exit 4 +fi +exit 0