Conversation
jdupak
left a comment
There was a problem hiding this comment.
Amazing work so far. I only have some organizational comments.
| // QCOMPARE(Instruction(0x4432146), Instruction(1, 2, 3, 4, 5, 6)); | ||
| // QCOMPARE(Instruction(0x4430004), Instruction(1, 2, 3, 4)); | ||
| // QCOMPARE(Instruction(0x4000002), Instruction(1, 2_addr)); | ||
| QCOMPARE(Instruction(0x0), Instruction(Instruction(0x0))); |
There was a problem hiding this comment.
I am confused by Instruction(Instruction(...)). What is it supposed to mean?
There was a problem hiding this comment.
just for this constructor
Instruction::Instruction(const Instruction &i) {
this->dt = i.data();
}indeed seems useless, I'll delete it.
| , line(line) {} | ||
|
|
||
|
|
||
| void gen_instruction_code_and_expected_str(QTextStream& outfile, const InstructionMap* im, uint32_t code, int count, int offset, int subclass_i, int depth) { |
There was a problem hiding this comment.
This should be in the instruction.test.cpp file. It has no use during normal operation of the simulator. Also I would prefer the name "generate_code_and_string_data" and a little docstring explaining the usage.
|
|
||
| QString test_code = QString::asprintf("QCOMPARE(Instruction(0x%x).to_str(), \"%s\");", code, qPrintable(res)); | ||
| outfile << test_code; | ||
| if (Instruction(code).to_str() != res) { |
There was a problem hiding this comment.
I am not sure why this is here. I would expect the test generation and execution to be separate.
There was a problem hiding this comment.
Should it be in a separate file as an executable? (for generating test cases)
| #include <iostream> | ||
| #include <fstream> | ||
| #include <qfile.h> | ||
| void gen() { |
There was a problem hiding this comment.
Could you make the name more descriptive? Also, there should be an empty line after the includes.
There was a problem hiding this comment.
Also move it to the test file.
|
I will address the other questions shortly. |
I don't think we need to dig into the instructions here. We need to test the loading functionality. I think it would be nice to come up with one executable with various sections and then "randomly" check the contents of the memory. |
I like your approach. Since you have the pairs already generated, I would love to add also the other direction ( After that, there are many commented-out MIPS tests in the |
|
We will be able to close #7 once all QSKIP calls are gone. |
e77d427 to
1e6e49f
Compare
|
Good work so far. Some notes.
|
e72c604 to
a248b5c
Compare
|
Completely refactored Now instruction.test.gendata.cpp iterates through all the instructions on instruction_map, tries to generate 100 (code and string_data)pair for each, then checks The current generation logic relies on arg_desc's min and max. This is an executable file, the output looks like this: Since it can't generate a fixed test case every time you run this script, the file name shouldn't be gendata anymore. I tried to move the code from main to instruction.test.cpp, but fails. Because there are too many structures used here that instruction.cpp doesn't expose (e.g. ArgumentDesc, C_inst_map, fill_argdesbycode ...), So I include @jdupak could you give me some advise? |
Related to #7
This demo currently adds some test cases for instruction_to_str(), and also includes a demo function to generate test cases
@jdupak