Skip to content

[Sim, Tests] Improve sim. Add sim tests.#16

Open
egorshamshura wants to merge 8 commits intoProteusLab:masterfrom
egorshamshura:add-tests-and-improve-sim
Open

[Sim, Tests] Improve sim. Add sim tests.#16
egorshamshura wants to merge 8 commits intoProteusLab:masterfrom
egorshamshura:add-tests-and-improve-sim

Conversation

@egorshamshura
Copy link
Copy Markdown
Contributor

No description provided.

@egorshamshura egorshamshura force-pushed the add-tests-and-improve-sim branch 3 times, most recently from 778da7a to b10499c Compare March 1, 2026 17:55
@egorshamshura egorshamshura force-pushed the add-tests-and-improve-sim branch 5 times, most recently from 769dcfe to 5fdfd4f Compare March 12, 2026 07:41
@@ -0,0 +1,167 @@
---
Copy link
Copy Markdown
Member

@derzhavin3016 derzhavin3016 Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to clang format should be discussed, this change is not related to this PR. Consider using either minimal default clang format (e.g. LLVM), or remove this file completely

Copy link
Copy Markdown
Contributor Author

@egorshamshura egorshamshura Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Started to use LLVM format

@derzhavin3016
Copy link
Copy Markdown
Member

Pls separate formatting commits

name: Test
runs-on: ubuntu-22.04
container:
image: ghcr.io/egorshamshura/protea-build:latest
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the image contain? Add more info

@@ -0,0 +1,3 @@
if (NOT DEFINED QEMU_PATH)
set(QEMU_PATH "qemu")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add message

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added status message

emitter.emit_line("void do#{instruction[:name].to_s.upcase}(CPU &cpu, const Instruction &insn) {")
emitter.increase_indent

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove redundant tabulations and spaces

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@egorshamshura egorshamshura force-pushed the add-tests-and-improve-sim branch from 29b2c66 to f00a942 Compare March 17, 2026 11:45

has_error = False

for filename in os.listdir(directory):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is possible to use ctest facilities to run all tests in parallel?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added ctest

@@ -0,0 +1,179 @@
// See LICENSE for license details.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file (LICENSE) should be put near benchmark sources

Comment on lines +6 to +7
program = sys.argv[1]
directory = sys.argv[2]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls use argparse

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this file

has_error = True
continue

match = re.search(r"Exiting with code (\d+)", result.stdout)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would be simpler to propagate exit() code as simulator exit code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this file

next if attrs.include?(:zero) || attrs.include?(:pc)
size = reg[:size] || 32
max = (1 << size) - 1
values[reg[:name]] = rand(0..max)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How this works random works? Does it have seed value? If no, tests are unpredictable, if yes, consider passing it via cmdline

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added seed

Comment on lines +54 to +57
if ARGV.size < 3 || ARGV.size > 4
puts "Usage: #{$0} <ir_yaml_file> <snippets_directory> <output_directory> [num_tests]"
exit 1
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls use built in Ruby CLI facilities

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added OptionParser

Comment on lines +74 to +76
num_tests.times do |i|
output_file = File.join(output_directory, "#{base}_#{i}.init.")
generator.generate(formatter, snippet_content, output_file)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be run in parallel?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now it is possible to specify number of threads via cmdline option

@egorshamshura egorshamshura force-pushed the add-tests-and-improve-sim branch from 9986ac2 to d6f4b6b Compare March 23, 2026 11:22
@egorshamshura egorshamshura force-pushed the add-tests-and-improve-sim branch from e15114d to 8eed710 Compare March 23, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants