Fixed continue behavior and added a test to verify correct behavior

This commit is contained in:
Jeremiah Orians 2020-02-28 18:48:58 -05:00
parent 6343e48600
commit 09783ac089
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
13 changed files with 565 additions and 40 deletions

View File

@ -34,6 +34,7 @@ struct type* current_target;
char* break_target_head;
char* break_target_func;
char* break_target_num;
char* continue_target_head;
struct token_list* break_frame;
int current_count;
int Address_of;
@ -1213,11 +1214,13 @@ void process_for()
char* nested_break_head = break_target_head;
char* nested_break_func = break_target_func;
char* nested_break_num = break_target_num;
char* nested_continue_head = continue_target_head;
char* number_string = numerate_number(current_count);
current_count = current_count + 1;
break_target_head = "FOR_END_";
continue_target_head = "FOR_ITER_";
break_target_num = number_string;
break_frame = function->locals;
break_target_func = function->s;
@ -1294,6 +1297,7 @@ void process_for()
break_target_head = nested_break_head;
break_target_func = nested_break_func;
break_target_num = nested_break_num;
continue_target_head = nested_continue_head;
break_frame = nested_locals;
}
@ -1320,11 +1324,13 @@ void process_do()
char* nested_break_head = break_target_head;
char* nested_break_func = break_target_func;
char* nested_break_num = break_target_num;
char* nested_continue_head = continue_target_head;
char* number_string = numerate_number(current_count);
current_count = current_count + 1;
break_target_head = "DO_END_";
continue_target_head = "DO_TEST_";
break_target_num = number_string;
break_frame = function->locals;
break_target_func = function->s;
@ -1337,6 +1343,9 @@ void process_do()
statement();
require(NULL != global_token, "Reached EOF inside of function\n");
emit_out(":DO_TEST_");
uniqueID_out(function->s, number_string);
require_match("ERROR in process_do\nMISSING while\n", "while");
require_match("ERROR in process_do\nMISSING (\n", "(");
expression();
@ -1359,6 +1368,7 @@ void process_do()
break_target_head = nested_break_head;
break_target_func = nested_break_func;
break_target_num = nested_break_num;
continue_target_head = nested_continue_head;
}
@ -1369,11 +1379,13 @@ void process_while()
char* nested_break_head = break_target_head;
char* nested_break_func = break_target_func;
char* nested_break_num = break_target_num;
char* nested_continue_head = continue_target_head;
char* number_string = numerate_number(current_count);
current_count = current_count + 1;
break_target_head = "END_WHILE_";
continue_target_head = "WHILE_";
break_target_num = number_string;
break_frame = function->locals;
break_target_func = function->s;
@ -1414,6 +1426,7 @@ void process_while()
break_target_head = nested_break_head;
break_target_func = nested_break_func;
break_target_num = nested_break_num;
continue_target_head = nested_continue_head;
break_frame = nested_locals;
}
@ -1448,7 +1461,7 @@ void process_break()
if(NULL == break_target_head)
{
line_error();
file_print("Not inside of a loop or case statement", stderr);
file_print("Not inside of a loop or case statement\n", stderr);
exit(EXIT_FAILURE);
}
struct token_list* i = function->locals;
@ -1480,6 +1493,32 @@ void process_break()
require_match("ERROR in break statement\nMissing ;\n", ";");
}
void process_contine()
{
if(NULL == continue_target_head)
{
line_error();
file_print("Not inside of a loop\n", stderr);
exit(EXIT_FAILURE);
}
global_token = global_token->next;
if((KNIGHT_POSIX == Architecture) || (KNIGHT_NATIVE == Architecture)) emit_out("JUMP @");
else if(X86 == Architecture) emit_out("JUMP %");
else if(AMD64 == Architecture) emit_out("JUMP %");
else if(ARMV7L == Architecture) emit_out("^~");
else if(AARCH64 == Architecture) emit_out("LOAD_W16_AHEAD\nSKIP_32_DATA\n&");
emit_out(continue_target_head);
emit_out(break_target_func);
emit_out("_");
emit_out(break_target_num);
if(ARMV7L == Architecture) emit_out(" JUMP_ALWAYS");
else if(AARCH64 == Architecture) emit_out("\nBR_X16");
emit_out("\n");
require_match("ERROR in continue statement\nMissing ;\n", ";");
}
void recursive_statement()
{
global_token = global_token->next;
@ -1596,9 +1635,7 @@ void statement()
}
else if(match("continue", global_token->s))
{
global_token = global_token->next;
emit_out("\n#continue statement\n");
require_match("ERROR in statement\nMissing ;\n", ";");
process_contine();
}
else
{

View File

@ -87,6 +87,7 @@ clean:
./test/test0019/cleanup.sh
./test/test0020/cleanup.sh
./test/test0021/cleanup.sh
./test/test0022/cleanup.sh
./test/test0100/cleanup.sh
./test/test0101/cleanup.sh
./test/test0102/cleanup.sh
@ -126,6 +127,7 @@ test: test0000-aarch64-binary \
test0019-aarch64-binary \
test0020-aarch64-binary \
test0021-aarch64-binary \
test0022-aarch64-binary \
test0100-aarch64-binary \
test0101-aarch64-binary \
test0102-aarch64-binary \
@ -156,6 +158,7 @@ test: test0000-aarch64-binary \
test0019-amd64-binary \
test0020-amd64-binary \
test0021-amd64-binary \
test0022-amd64-binary \
test0100-amd64-binary \
test0101-amd64-binary \
test0102-amd64-binary \
@ -186,6 +189,7 @@ test: test0000-aarch64-binary \
test0019-knight-posix-binary \
test0020-knight-posix-binary \
test0021-knight-posix-binary \
test0022-knight-posix-binary \
test0100-knight-posix-binary \
test0101-knight-posix-binary \
test0102-knight-posix-binary \
@ -232,6 +236,7 @@ test: test0000-aarch64-binary \
test0019-armv7l-binary \
test0020-armv7l-binary \
test0021-armv7l-binary \
test0022-armv7l-binary \
test0100-armv7l-binary \
test0101-armv7l-binary \
test0102-armv7l-binary \
@ -262,6 +267,7 @@ test: test0000-aarch64-binary \
test0019-x86-binary \
test0020-x86-binary \
test0021-x86-binary \
test0022-x86-binary \
test0100-x86-binary \
test0101-x86-binary \
test0102-x86-binary \
@ -338,6 +344,9 @@ test0020-aarch64-binary: M2-Planet | results
test0021-aarch64-binary: M2-Planet | results
test/test0021/hello-aarch64.sh
test0022-aarch64-binary: M2-Planet | results
test/test0022/hello-aarch64.sh
test0100-aarch64-binary: M2-Planet | results
test/test0100/hello-aarch64.sh
@ -428,6 +437,9 @@ test0020-amd64-binary: M2-Planet | results
test0021-amd64-binary: M2-Planet | results
test/test0021/hello-amd64.sh
test0022-amd64-binary: M2-Planet | results
test/test0022/hello-amd64.sh
test0100-amd64-binary: M2-Planet | results
test/test0100/hello-amd64.sh
@ -518,6 +530,9 @@ test0020-knight-posix-binary: M2-Planet | results
test0021-knight-posix-binary: M2-Planet | results
test/test0021/hello-knight-posix.sh
test0022-knight-posix-binary: M2-Planet | results
test/test0022/hello-knight-posix.sh
test0100-knight-posix-binary: M2-Planet | results
test/test0100/hello-knight-posix.sh
@ -656,6 +671,9 @@ test0020-armv7l-binary: M2-Planet | results
test0021-armv7l-binary: M2-Planet | results
test/test0021/hello-armv7l.sh
test0022-armv7l-binary: M2-Planet | results
test/test0022/hello-armv7l.sh
test0100-armv7l-binary: M2-Planet | results
test/test0100/hello-armv7l.sh
@ -746,6 +764,9 @@ test0020-x86-binary: M2-Planet | results
test0021-x86-binary: M2-Planet | results
test/test0021/hello-x86.sh
test0022-x86-binary: M2-Planet | results
test/test0022/hello-x86.sh
test0100-x86-binary: M2-Planet | results
test/test0100/hello-x86.sh

View File

@ -120,47 +120,52 @@ e759aeb73d575fc23e7b71684be8547e6fbd93a2db42e4cf6c987215793e3dbc test/results/t
d9d40f64041a02b6a403fd3c07550cf53f9383e0ec7f7208c9c263d06ea3ce8f test/results/test0020-knight-native-binary
6a59795dbb4397d0efaf1ad613d646ec435eec62db30eb758bcf2499d651520e test/results/test0020-knight-posix-binary
0d1a43723d0482a21028164e33ff116d66302d6042a88eacf08436a351494530 test/results/test0020-x86-binary
004e0ceecf5d0ccf4d335eb4b339b998dba289a54dc7f4feb5a9b433189f0731 test/results/test0021-aarch64-binary
67009c14cd51512b1b48d1575388e62843bdd9317da89aff9d3434fbf9e6fff8 test/results/test0021-amd64-binary
c9ef08680714f024da44b39b51d0f6241ea5530a29397c6eb3812ee1cf568db1 test/results/test0021-armv7l-binary
41c2ee5ea154a29c6449e080d8547cdb18b361060be71751f6d0678a420d228a test/results/test0021-aarch64-binary
41849e833a6ae001d38f33ad7112734dc8e081f642453a7cc0147d43a1949661 test/results/test0021-amd64-binary
3c3b54122f12d58bf245da20eac37dd77669bf09907179a98851118487bdbbd9 test/results/test0021-armv7l-binary
053df6ef480fa16e4f1f6f45f5b833bd98e335c48d841e22f9ea46a64fad4aca test/results/test0021-knight-posix-binary
5709e7b91b29921cabde3f266a529c857c814bbc71802b8d91521c1c616a7d4a test/results/test0021-x86-binary
8e88e82b6955239bada4aaea4cc16ccc45a0ae70b0faddbb0b020c196751d6d6 test/results/test0100-aarch64-binary
0fab8f708839019a8dcda693acf0542c585b00b464a700cdcb64dd0cdfb0b6a0 test/results/test0100-amd64-binary
644b5a7f6f40828cebbca5e6537ce1aaaf9fa4f1451671a40e1cfd4516a30a2d test/results/test0100-armv7l-binary
458f143a44a02098664bf42963dd66c8b6ad2bfa30c9793131b8054b0a30400c test/results/test0021-x86-binary
9cc936e8cd26ad05f68ba5a7d8eb626c980d23749892bd14e8dda506affef75e test/results/test0022-aarch64-binary
e0d7110a6de7638621f07f3d7953fc526e9369124b8a196464e51fcd0ba07e66 test/results/test0022-amd64-binary
f8f622f4123ef8ea760de0e1968012558116f3a7813499f836513fd624778994 test/results/test0022-armv7l-binary
9161b4f8563e5f3a4cb1252fd6fc0736c2b527254558aa007c213dcdc222e0b2 test/results/test0022-knight-posix-binary
4dffefd3137f799c31782594374db27be9f2016cfe4731a5befaa1675bb7dc95 test/results/test0022-x86-binary
598f69fdf241736f0280f8ce6a6f61385f858a8feffff3221b8af9b33b6a4f73 test/results/test0100-aarch64-binary
00068f4aec8b148963ce51fabc76882d7206139f63354bde5229ba8a0428a41f test/results/test0100-amd64-binary
bcd50fa1a17dbbb8aa2c00dcca1f1b74398649bae58b95132a7de55b37ae3128 test/results/test0100-armv7l-binary
80d49242c8eec979b576c3455a57d46efa75014cf607fc777b59dc1943259a6e test/results/test0100-knight-posix-binary
1fa52023ea0f9e18bc6fab2a62fc8383ff1a9d97a6f0e3da9698268bf7565b99 test/results/test0100-x86-binary
a5bbd78dfb6325ce1f89d0cdfc7fb5f7feb51682af6fccaa0df0f61d3bcfea14 test/results/test0101-aarch64-binary
8b3fc360938fe30c6b1a8c1fd368cd990761c35d8d0a3b5499cdca23127f36cf test/results/test0101-amd64-binary
ef1c7437223311d13429b43f59aafe5b9cd3c01939b59a935aa1dd55f417ebcf test/results/test0101-armv7l-binary
387ae179f593ad27a1ae96f9f20b7cf69bf201a74d2a69fc9b60faeeec9fa811 test/results/test0101-knight-posix-binary
46f4645cf23a415fe96f73826595a2dc29661fd2365978f387c256e0469bf51c test/results/test0101-x86-binary
758092d7ad9d18fc72cc4291c786f0fffd42f18e0987f6d5cdb18ff1506d8dac test/results/test0102-aarch64-binary
13a8033841a8805b13621e305755d0885154615fe1d126a3db4969854cfb8b40 test/results/test0102-amd64-binary
9ef467b01c5af7f5c966671c5249ff8cb88f62e6c48fcd824254e0616d8d915c test/results/test0102-armv7l-binary
897a5bc96a007a6eaf4337b630fb05d576fd42d35682c96a1f3c319f85f2b1ba test/results/test0102-knight-posix-binary
f53e041af9ec8bc34f6b7accedafe0c3bc40e09edfee3ad18144e7bb04e274e6 test/results/test0102-x86-binary
e0fdfb0ca2fe269514e3d8e2f8eb35c35430d4231674fea9d42a3cfa613c3af1 test/results/test0103-aarch64-binary
ed1eb588d8b14a370729d1426f8c1b1cc9cbfeaffe80012558ab74dadd82fbf8 test/results/test0103-amd64-binary
91f8415a8358a26aa99706d990a35761cd5e4f313a32ef45ab5bc49a47435249 test/results/test0103-armv7l-binary
e12c61c7825c2731bd91e05f6974779d2a38475a49e3d8c33b7a2e7b673abcaa test/results/test0100-x86-binary
2740860d7d3b22556bfd7c798e4403e3c89fff4f8f5d7d42a69bd44409381bf7 test/results/test0101-aarch64-binary
f012cc062f45d053b18fbb2a4440d42e429df076e88054657fa34049ea0fcff7 test/results/test0101-amd64-binary
c55de2f2a58dff5a26b10eba0dfff841360b53130cc3d3fd1131e8b3f5075402 test/results/test0101-armv7l-binary
914795f6064ea383efe0757ed02efb933d270749f3e5bb897d4af40293328d8d test/results/test0101-knight-posix-binary
e5be4e89dea9bf6ca1f04ce5225fc8803998b40b6eac7830ab809a04dca3ceb6 test/results/test0101-x86-binary
f541971117dc5b1e1163538beb790c7fe23c93e27471186a0a62296f84ef0a20 test/results/test0102-aarch64-binary
aa26350a62a783893dcdb1fb85cb9f8752f7e74f220a8de7d0c5394dc97244a4 test/results/test0102-amd64-binary
83ef14199fdedd1ba344f3fde94d2e2188418686ee86022e81917a07499763c8 test/results/test0102-armv7l-binary
f7f7d02d795fd8c04dd8daebc8114c6842c9f95bbd078e83d4f0585991878626 test/results/test0102-knight-posix-binary
14bb35cf5ea48b0ac5cd44aefcc10d668dfb3627a465e38e0425e21c89e57006 test/results/test0102-x86-binary
ed53b7a856b0fb8fecdc4fb6f4726712c8ecd624195439977062134935d074e5 test/results/test0103-aarch64-binary
385165eda7e034303a6ad5c1bdc374e773f6ab4cf9946bdb05ea307b42a840b6 test/results/test0103-amd64-binary
dcba555de7d87c30dbd56f6c28f786bb506f87ca0f7257cf78528e202273213f test/results/test0103-armv7l-binary
44b37b8d45d8c0a6e983168e5646ef652deab2fcd327cb255bc2a71289f471ff test/results/test0103-knight-posix-binary
29216c9761435396912cb03a414ac74cde165a522cf19a7cccac212b06d3a597 test/results/test0103-x86-binary
69a48cdae667be5324ceca8548b8de065ddc09cad3d294e3f81131646da3754e test/results/test0104-aarch64-binary
0506117d8b028c1e5e23ecd0493116278e94ec32a55ff314dee1a2f4e2b243a5 test/results/test0104-amd64-binary
8af23bb361cce0d7031d78a3f1f88a51d6786df4cc2f5dc0bf09ff67947d30ea test/results/test0104-armv7l-binary
e1fca774a067de5edb7eb1165619573993d2a5e5647c05568a68f3a53a7990cd test/results/test0104-x86-binary
eb24eb355bde5356672db4358a6aa37fdfeff0ddf9da5a676ee8aab00423ce56 test/results/test0105-aarch64-binary
60206125928d77a758cd73ec8e85f8592423ce678570ebbe7876b71dc38aaeaf test/results/test0105-amd64-binary
649349e01a90ce93ba72ba1b9bb81a9bd9d79b580ddff366173c98835c10b976 test/results/test0105-armv7l-binary
576511f1f6699e7798bcab2f36bf8eb86825fd13748770b17f46c3a691200b01 test/results/test0105-x86-binary
2e7b4678de276e883552a66bff72a2c449b3a9e322fab152723c5fe28975dab9 test/results/test0103-x86-binary
63d5146dffa78fd80038c15e3a41880203aa4526f8ba94970df9a6169fcc518b test/results/test0104-aarch64-binary
cc98d9e01ea478503cee1a56f953969ada22bdb80dbab1755363550d375292d6 test/results/test0104-amd64-binary
beaf7a6a1f9440d3cdcdc88de58a5bb95d14b3027c7adef67decdef94739a268 test/results/test0104-armv7l-binary
a746b54b6030e8270dde8b07f56ff46a137702c2d1273c60322cccab87688c25 test/results/test0104-x86-binary
e1102366d141637dabee1f4683985affe57ecc0d0416702820c438c7cc567bc7 test/results/test0105-aarch64-binary
76c1b24e0f31e61e3e133fb8dfe7b1a4a39462402a18a53102e3518b44174ff6 test/results/test0105-amd64-binary
c2fb1f16027dc0f0cfea06221e98d08d3b4f3e1b2a70288ebeb869148fd0ad88 test/results/test0105-armv7l-binary
6ce582ca2fe5328baa13e3126590136852b7d27076677aa41f24cba892bf946f test/results/test0105-x86-binary
c287f7c662cd29bdeb7258300de83c6b0895e002a18c9f46dac31ecd5476b69c test/results/test0106-aarch64-binary
717c42e1a1a91ef5b67ce298bc92a148418a5dec6761a358a52b22a01f16c928 test/results/test0106-amd64-binary
4e759b212b087824f7b0f14c5147272c9984c4a4d00074b2fd771c3d004c9aec test/results/test0106-armv7l-binary
45116095f72aa1a4bf09aeff9f9ddc11e0c7ca3b0c380be930ad8db762088770 test/results/test0106-knight-native-binary
13c270bacaee1748dad55532fc0adfa713904ba1cafbd69f77a9d361bdc4acd7 test/results/test0106-knight-posix-binary
e970ab9e2e85cd01c0f9c14f0af1954e3628a44c988ca8175a983037457522f9 test/results/test0106-x86-binary
0e91b69e168d74f2c8378aed9d776a0d8d44cc865b70588b87e4b8591522d303 test/results/test1000-aarch64-binary
0b609603bd48afa670b5997a295aa12c2d545c44b902322ce1e92a908963c5f3 test/results/test1000-amd64-binary
c5e746e26de28c734d06406e50ac362fed3b34adba260b91ca857db1a071a9e9 test/results/test1000-armv7l-binary
aa0fade4804235b9279831a32542f38846928548e710cb7e5990925ccd5d92e2 test/results/test1000-knight-posix-binary
71876f59e0bd01d29b70ff6f81ecb9c4d27ff457230cf04c5c19da8d8ec25678 test/results/test1000-x86-binary
57591a69b33de89a8fe3e266d05dbfbf7a18153f608d2e80ea39c886f6108f7b test/results/test1000-aarch64-binary
fd0cac1af91905be4585f68d91084214da30cdcbef5035648f9376906e976510 test/results/test1000-amd64-binary
da5e97d33b0341d4d6f295837077eae687ef156f8440689cf0a207a867739797 test/results/test1000-armv7l-binary
a575429748b7f291f4d847e48ba0123b3bbf4b00a01451ffede4b7fd87170eda test/results/test1000-knight-posix-binary
fd30806346afe340f3a7aa5e86d3ebc3a41c5475e735fd56eb14f1b9c230386f test/results/test1000-x86-binary

19
test/test0022/.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
## 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/>.
# Ignore the files created by script
*.M1
*.hex2
proof

20
test/test0022/cleanup.sh Executable file
View File

@ -0,0 +1,20 @@
#! /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/>.
rm -f test/test0022/continue.M1
rm -f test/test0022/continue-footer.M1
rm -f test/test0022/continue.hex2
exit 0

108
test/test0022/continue.c Normal file
View File

@ -0,0 +1,108 @@
/* 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/>.
*/
#include<stdio.h>
#include <stdlib.h>
char* numerate_number(int a);
void file_print(char* s, FILE* f);
int main()
{
int i;
int j;
for(i = 0; i < 10; i = i + 1)
{
file_print(numerate_number(i), stdout);
if(i != 1) continue;
fputc(' ', stdout);
}
fputc('\n', stdout);
for(i = 0; i < 10; i = i + 1)
{
for(j = 0; j < 10; j = j + 1)
{
if(j == 2) continue;
file_print(numerate_number(i), stdout);
file_print(numerate_number(j), stdout);
fputc(' ', stdout);
}
}
fputc('\n', stdout);
i = -1;
while(i < 9)
{
i = i + 1;
file_print(numerate_number(i), stdout);
if(i != 3) continue;
fputc(' ', stdout);
}
fputc('\n', stdout);
i = -1;
while(i < 9)
{
i = i + 1;
j = -1;
while(j < 9)
{
j = j + 1;
if(j == 4) continue;
file_print(numerate_number(i), stdout);
file_print(numerate_number(j), stdout);
fputc(' ', stdout);
}
}
fputc('\n', stdout);
i = -1;
do
{
i = i + 1;
file_print(numerate_number(i), stdout);
if(i != 5) continue;
fputc(' ', stdout);
}while(i < 9);
fputc('\n', stdout);
i = -1;
do
{
i = i + 1;
j = -1;
do
{
j = j + 1;
if(j == 6) continue;
file_print(numerate_number(i), stdout);
file_print(numerate_number(j), stdout);
fputc(' ', stdout);
}while(j < 9);
}while(i < 9);
fputc('\n', stdout);
/* All tests passed */
return 0;
}

64
test/test0022/hello-aarch64.sh Executable file
View File

@ -0,0 +1,64 @@
#! /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 aarch64 \
-f test/common_aarch64/functions/malloc.c \
-f test/common_aarch64/functions/file.c \
-f test/common_aarch64/functions/exit.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
-f functions/calloc.c \
-f functions/file_print.c \
-f test/test0022/continue.c \
--debug \
-o test/test0022/continue.M1 || exit 1
# Build debug footer
blood-elf --64 -f test/test0022/continue.M1 \
-o test/test0022/continue-footer.M1 || exit 2
# 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/test0022/continue.M1 \
-f test/test0022/continue-footer.M1 \
--LittleEndian \
--architecture aarch64 \
-o test/test0022/continue.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_aarch64/ELF-aarch64-debug.hex2 \
-f test/test0022/continue.hex2 \
--LittleEndian \
--architecture aarch64 \
--BaseAddress 0x400000 \
-o test/results/test0022-aarch64-binary \
--exec_enable || exit 4
# 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/test0022-aarch64-binary >| test/test0022/proof
[ 0 = $? ] || exit 5
out=$(sha256_check test/test0022/proof.answer)
[ "$out" = "test/test0022/proof: OK" ] || exit 6
fi
exit 0

64
test/test0022/hello-amd64.sh Executable file
View File

@ -0,0 +1,64 @@
#! /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 amd64 \
-f test/common_amd64/functions/malloc.c \
-f test/common_amd64/functions/file.c \
-f test/common_amd64/functions/exit.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
-f functions/calloc.c \
-f functions/file_print.c \
-f test/test0022/continue.c \
--debug \
-o test/test0022/continue.M1 || exit 1
# Build debug footer
blood-elf --64 -f test/test0022/continue.M1 \
-o test/test0022/continue-footer.M1 || exit 2
# 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/test0022/continue.M1 \
-f test/test0022/continue-footer.M1 \
--LittleEndian \
--architecture amd64 \
-o test/test0022/continue.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_amd64/ELF-amd64-debug.hex2 \
-f test/test0022/continue.hex2 \
--LittleEndian \
--architecture amd64 \
--BaseAddress 0x00600000 \
-o test/results/test0022-amd64-binary \
--exec_enable || exit 4
# 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/test0022-amd64-binary >| test/test0022/proof
[ 0 = $? ] || exit 5
out=$(sha256_check test/test0022/proof.answer)
[ "$out" = "test/test0022/proof: OK" ] || exit 6
fi
exit 0

64
test/test0022/hello-armv7l.sh Executable file
View File

@ -0,0 +1,64 @@
#! /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 armv7l \
-f test/common_armv7l/functions/malloc.c \
-f test/common_armv7l/functions/file.c \
-f test/common_armv7l/functions/exit.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
-f functions/calloc.c \
-f functions/file_print.c \
-f test/test0022/continue.c \
--debug \
-o test/test0022/continue.M1 || exit 1
# Build debug footer
blood-elf -f test/test0022/continue.M1 \
-o test/test0022/continue-footer.M1 || exit 2
# 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/test0022/continue.M1 \
-f test/test0022/continue-footer.M1 \
--LittleEndian \
--architecture armv7l \
-o test/test0022/continue.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_armv7l/ELF-armv7l-debug.hex2 \
-f test/test0022/continue.hex2 \
--LittleEndian \
--architecture armv7l \
--BaseAddress 0x10000 \
-o test/results/test0022-armv7l-binary \
--exec_enable || exit 4
# 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/test0022-armv7l-binary >| test/test0022/proof
[ 0 = $? ] || exit 5
out=$(sha256_check test/test0022/proof.answer)
[ "$out" = "test/test0022/proof: OK" ] || exit 6
fi
exit 0

View File

@ -0,0 +1,58 @@
#! /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/malloc.c \
-f test/common_knight/functions/file.c \
-f test/common_knight/functions/exit.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
-f functions/calloc.c \
-f functions/file_print.c \
-f test/test0022/continue.c \
-o test/test0022/continue.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/test0022/continue.M1 \
--BigEndian \
--architecture knight-posix \
-o test/test0022/continue.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_knight/ELF-knight.hex2 \
-f test/test0022/continue.hex2 \
--BigEndian \
--architecture knight-posix \
--BaseAddress 0x0 \
-o test/results/test0022-knight-posix-binary \
--exec_enable || exit 4
# 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/test0022-knight-posix-binary >| test/test0022/proof
[ 0 = $? ] || exit 5
out=$(sha256_check test/test0022/proof.answer)
[ "$out" = "test/test0022/proof: OK" ] || exit 6
fi
exit 0

64
test/test0022/hello-x86.sh Executable file
View File

@ -0,0 +1,64 @@
#! /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 x86 \
-f test/common_x86/functions/malloc.c \
-f test/common_x86/functions/file.c \
-f test/common_x86/functions/exit.c \
-f functions/in_set.c \
-f functions/numerate_number.c \
-f functions/calloc.c \
-f functions/file_print.c \
-f test/test0022/continue.c \
--debug \
-o test/test0022/continue.M1 || exit 1
# Build debug footer
blood-elf -f test/test0022/continue.M1 \
-o test/test0022/continue-footer.M1 || exit 2
# 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/test0022/continue.M1 \
-f test/test0022/continue-footer.M1 \
--LittleEndian \
--architecture x86 \
-o test/test0022/continue.hex2 || exit 3
# Resolve all linkages
hex2 -f test/common_x86/ELF-i386-debug.hex2 \
-f test/test0022/continue.hex2 \
--LittleEndian \
--architecture x86 \
--BaseAddress 0x8048000 \
-o test/results/test0022-x86-binary \
--exec_enable || exit 4
# 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/test0022-x86-binary >| test/test0022/proof
[ 0 = $? ] || exit 5
out=$(sha256_check test/test0022/proof.answer)
[ "$out" = "test/test0022/proof: OK" ] || exit 6
fi
exit 0

View File

@ -0,0 +1 @@
07e352faa2a6028942317db85f1b03f7e7d197f541efe152700c1d3cb5f2aafe test/test0022/proof

View File

@ -1 +1 @@
8db43aa7c23a6c479c21695d572ce6a20510669d69ba5a9a20557eb6e2e8d161 test/test1000/proof
51abebf04b53e86e805d0adcc9dc02c16e0259937443664ad04fc464cb18db25 test/test1000/proof