Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Added a test for a simple loop
Browse files Browse the repository at this point in the history
  • Loading branch information
mattixtech committed Aug 6, 2018
1 parent 8d4a49e commit daecce8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 53 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ exec/
cmake*/*
.idea/
venv/
lbuild/
lbuild/
/programs.txt
44 changes: 0 additions & 44 deletions PROGRAMS

This file was deleted.

11 changes: 6 additions & 5 deletions blackbox_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def test_program(program_name, expected_output):
if not isinstance(received_output, str):
received_output = received_output.decode("utf-8")

print("testing '" + program_name + "'... ", end="")
print("testing '{}'... ".format(program_name), end="")

if expected_output == received_output:
print("passed")

return 0
else:
print("failed! '" + received_output + "' != '" + expected_output + "'")
print("failed! '{}' != '{}'".format(received_output, expected_output))

return 1

Expand All @@ -49,11 +49,12 @@ def main():
"""

failed_tests = 0
failed_tests += test_program("hello_world", "hello world! \n")
failed_tests += test_program("hello_world", "hello world!\n")
failed_tests += test_program("loop", "*")
# TODO: Add more test cases here...

if failed_tests:
print("Errors: Failed '" + str(failed_tests) + "' tests!")
print("Errors: Failed '{}' tests!".format(str(failed_tests)))
else:
print("All tests passed!")

Expand All @@ -77,7 +78,7 @@ def main():
mbvm_exec = mbvm_unix_exec

if not mbvm_exec:
sys.stderr.write("ERROR: Could not find the mbvm executable.")
sys.stderr.write("ERROR: Could not find the mbvm executable")
sys.exit(1)

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions src/instructions/instructions.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ void instr_jmp(struct instruction ic)
// TODO: add the other jump modes
mem_addr = get_dword(ram, incr_pc());

// TODO: I don't think this will always be true
if ((mem_addr % INSTRUCTION_SIZE) == 0)
{
switch (ic.mode)
Expand Down
6 changes: 3 additions & 3 deletions src/mbvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int parse_args(int argc, const char *argv[])
int main(int argc, const char *argv[])
{
if (parse_args(argc, argv) != 0)
return 1;
return EXIT_FAILURE;

// Create the virtual machine in RAM
// TODO: Take VM init values as command line arguments
Expand All @@ -69,13 +69,13 @@ int main(int argc, const char *argv[])
if (0 != load_file(file_name))
{
printf("ERROR: Failed to open file '%s'.", file_name);
return 1;
return EXIT_FAILURE;
}

// Pass the program to the virtual machine and begin executing
exec_program();
// Free all the memory we allocated
deallocate_vm();

return 0;
return EXIT_SUCCESS;
}
Binary file added test_programs/loop
Binary file not shown.

0 comments on commit daecce8

Please sign in to comment.