diff --git a/.gitignore b/.gitignore index ee6d40f..f1b8020 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,175 @@ *.out *.app -build/ \ No newline at end of file +build/ + + +env/ +out.bit +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ +processors/ +*.fs +out/ +*.bit +teste.py +temp/ +arquivos.txt \ No newline at end of file diff --git a/test_runner/file.py b/test_runner/file.py index bac3809..8c07a06 100755 --- a/test_runner/file.py +++ b/test_runner/file.py @@ -14,9 +14,28 @@ def read_file(name): def read_files_in_dir(path): try: - file = [read_file(file) for file in glob.glob(f"{path}/*.hex", recursive=True)] - file.append(path) - return file + if path.endswith("/memory"): + path = path[:-7] # Remove the '/memory' suffix + print("path: ", path) + files = [] + + file_test = [] + for entry in os.scandir(f"{path}/memory"): + if entry.is_file() and entry.name.endswith(".hex"): + file_test.append(read_file(entry.path)) + + file_answer = [] + for entry in os.scandir(f"{path}/reference"): + if entry.is_file() and entry.name.endswith(".hex"): + file_answer.append(read_file(entry.path)) + + print("Files in reference directory: ", [entry.path for entry in os.scandir(path) if entry.is_dir()]) + print("teste: ", file_test) + print("resposta: ", file_answer) + files.append(file_test) + files.append(file_answer) + files.append(path) + return files except FileNotFoundError: print(f"Error: The directory '{path}' was not found.") return [] diff --git a/test_runner/testing_testes/hello1/not_memory/005-xor.hex b/test_runner/testing_testes/hello1/not_memory/005-xor.hex deleted file mode 100644 index 460436a..0000000 --- a/test_runner/testing_testes/hello1/not_memory/005-xor.hex +++ /dev/null @@ -1,4 +0,0 @@ -00500593 -00300613 -00c5c6b3 -02d02e23 diff --git a/test_runner/testing_testes/hello1/not_memory/006-sll.hex b/test_runner/testing_testes/hello1/not_memory/006-sll.hex deleted file mode 100644 index f594b60..0000000 --- a/test_runner/testing_testes/hello1/not_memory/006-sll.hex +++ /dev/null @@ -1,4 +0,0 @@ -00400593 -00100613 -00c596b3 -02d02e23 diff --git a/test_runner/testing_testes/hello1/program/000-addi.s b/test_runner/testing_testes/hello1/program/000-addi.s new file mode 100644 index 0000000..f78e490 --- /dev/null +++ b/test_runner/testing_testes/hello1/program/000-addi.s @@ -0,0 +1,9 @@ +.text + +.global _start; + +_start: + addi a1, zero, 5; # a1 = zero + 5 + + sw a1, 60(zero); + \ No newline at end of file diff --git a/test_runner/testing_testes/hello1/program/001-add.s b/test_runner/testing_testes/hello1/program/001-add.s new file mode 100644 index 0000000..a5d6191 --- /dev/null +++ b/test_runner/testing_testes/hello1/program/001-add.s @@ -0,0 +1,10 @@ +.text + +.global _start; + +_start: + addi a1, zero, 5; # a1 = zero + 5 + add a1, a1, a1; + + sw a1, 60(zero); + \ No newline at end of file diff --git a/test_runner/testing_testes/hello1/reference/000.hex b/test_runner/testing_testes/hello1/reference/000.hex new file mode 100644 index 0000000..f807660 --- /dev/null +++ b/test_runner/testing_testes/hello1/reference/000.hex @@ -0,0 +1 @@ +00000005 \ No newline at end of file diff --git a/test_runner/testing_testes/hello1/reference/001.hex b/test_runner/testing_testes/hello1/reference/001.hex new file mode 100644 index 0000000..3f80a93 --- /dev/null +++ b/test_runner/testing_testes/hello1/reference/001.hex @@ -0,0 +1 @@ +0000000A \ No newline at end of file diff --git a/test_runner/testing_testes/hello2/not_memory/007-slt.hex b/test_runner/testing_testes/hello2/not_memory/007-slt.hex deleted file mode 100644 index 5fed603..0000000 --- a/test_runner/testing_testes/hello2/not_memory/007-slt.hex +++ /dev/null @@ -1,4 +0,0 @@ -00400593 -00100613 -00c5a6b3 -02d02e23 diff --git a/test_runner/testing_testes/hello2/not_memory/008-sltu.hex b/test_runner/testing_testes/hello2/not_memory/008-sltu.hex deleted file mode 100644 index 507d597..0000000 --- a/test_runner/testing_testes/hello2/not_memory/008-sltu.hex +++ /dev/null @@ -1,4 +0,0 @@ -00400593 -00100613 -00c5b6b3 -02d02e23 diff --git a/test_runner/testing_testes/hello2/program/002-sub.s b/test_runner/testing_testes/hello2/program/002-sub.s new file mode 100644 index 0000000..74ee75a --- /dev/null +++ b/test_runner/testing_testes/hello2/program/002-sub.s @@ -0,0 +1,13 @@ +.text + +.global _start; + +_start: + addi a1, zero, 15; # a1 = zero + 15 + + addi a2, zero, 5; + + sub a3, a1, a2; + + sw a3, 60(zero); + \ No newline at end of file diff --git a/test_runner/testing_testes/hello2/program/003-and.s b/test_runner/testing_testes/hello2/program/003-and.s new file mode 100644 index 0000000..6ef28ab --- /dev/null +++ b/test_runner/testing_testes/hello2/program/003-and.s @@ -0,0 +1,12 @@ +.text + +.global _start; + +_start: + addi a1, zero, 5; # a1 = zero + 5 + addi a2, zero, 3; # a2 = zero + 3 + + and a3, a1, a2; + + sw a3, 60(zero); + \ No newline at end of file diff --git a/test_runner/testing_testes/hello2/reference/002.hex b/test_runner/testing_testes/hello2/reference/002.hex new file mode 100644 index 0000000..3f80a93 --- /dev/null +++ b/test_runner/testing_testes/hello2/reference/002.hex @@ -0,0 +1 @@ +0000000A \ No newline at end of file diff --git a/test_runner/testing_testes/hello2/reference/003.hex b/test_runner/testing_testes/hello2/reference/003.hex new file mode 100644 index 0000000..b86234f --- /dev/null +++ b/test_runner/testing_testes/hello2/reference/003.hex @@ -0,0 +1 @@ +00000001 \ No newline at end of file diff --git a/test_runner/verificator.py b/test_runner/verificator.py index 8432204..f995948 100755 --- a/test_runner/verificator.py +++ b/test_runner/verificator.py @@ -5,29 +5,47 @@ #test_extensão_tipo_timestamp.xml +# Adiciona o diretório raiz do projeto ao sys.path + + import os +import sys import file as f +import argparse + + +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))) +from processor_ci_communication.core.serial import ProcessorCIInterface + class Verificator: - def __init__(self, path): + def __init__(self, path, port, baudrate, timeout): self.path = path - #self.interface = ProcessorCIInterface() - #self.interface.open() + self.interface = ProcessorCIInterface(port, baudrate, timeout) def run_tests(self): tests = [] paths = f.list_find_paths(self.path) - print(paths) + #print(paths) for path in paths: tests.append(f.read_files_in_dir(path)) - print(tests) + #print(tests) + +#default to test: +#python3 verificator.py -p /dev/ttyACM0 -b 115200 -t 2 def main(): - verifier = Verificator("/eda/processor-ci-tests/test_runner/testing_testes") + parser = argparse.ArgumentParser() + parser.add_argument("--port", "-p", type=str, help="Porta de comunicação", required=True) + parser.add_argument("--baudrate", "-b", type=int, help="Baudrate de comunicação", required=True) + parser.add_argument("--timeout", "-t", type=int, help="Timeout de comunicação", required=True) + args = parser.parse_args() + + verifier = Verificator("/home/victor/processor_ci/processor-ci-tests/test_runner/testing_testes", args.port, args.baudrate, args.timeout) verifier.run_tests() return 0