#!/usr/bin/env bash asm_programs="$(pwd)/test_asm_files/succeed" asm_programs_fail="$(pwd)/test_asm_files/fail" pretty_success="\033[1;32mSUCCESS\033[0m" pretty_failure="\033[1;31mFAILURE\033[0m" [[ -d ${asm_programs} ]] || echo "Could not find ASM test programs!" >&2 [[ -d ${asm_programs} ]] || exit 1 log_error () { echo -e "\033[1;31m[ ERROR ]:\033[0m \033[0;31m$1\033[0m" >&2 } log_info () { echo -e "\033[1;32m[ INFO ]:\033[0m \033[0;32m$1\033[0m" } cargo build test_failure="no" for i in $(ls ${asm_programs}); do echo "Testing Against File: ${i}" extra_flags="" if [[ "${i}" == "from_docs_example_of_instructions.asm" ]]; then extra_flags="--no-hlt" fi if "$(pwd)/target/debug/oglo-cpu-asm" assemble ${extra_flags} -vi "${asm_programs}/${i}" -o a.bin --pretend; then echo -e "${i} -> ${pretty_success}" else echo -e "${i} -> ${pretty_failure}" test_failure="yes" fi echo " " done for i in $(ls ${asm_programs_fail}); do echo "Testing Against File (Fail Mode): ${i}" extra_flags="" if "$(pwd)/target/debug/oglo-cpu-asm" assemble ${extra_flags} -vi "${asm_programs_fail}/${i}" -o a.bin --pretend; then echo -e "${i} -> ${pretty_failure}" test_failure="yes" else echo -e "${i} -> ${pretty_success}" fi echo " " done if [[ "${test_failure}" == "yes" ]]; then log_error "Some tests have failed! Please review the above outputs to see what has failed..." else log_info "All tests have passed! (^-^)" fi