Skip to content

Convert torture tests to unit tests #530

Closed
pavelkryukov opened this issue Jul 29, 2018 · 49 comments
Closed

Convert torture tests to unit tests #530

pavelkryukov opened this issue Jul 29, 2018 · 49 comments
Assignees
Labels
7 New functionality which has to be built from scratch with higher value to the project. S1 — ISA To solve the issue, you need knowledge about MIPS or RISC-V ISA testing Improves testing coverage

Comments

@pavelkryukov
Copy link
Member

pavelkryukov commented Jul 29, 2018

Blocked by #589

To test functionality of instruction, we use SPIM torture tests (TT). That is not very convinient, as we have to build Binutils and traces in addition to unit tests. The idea is to convert the TT test cases into unit test cases.

Example:

	li $2, 1
	li $4, 0
	sllv $3, $2, $4
	bne $3, 1, fail

becomes

TEST_CASE("sllv")
{
    MIPSInstr<MIPS32> instr( "sllv"); // You need #589 to do that
    instr.set_v_src1( 1);
    instr.set_v_src2( 0);
    instr.execute();
    CHECK( instr.get_v_dst(), 1);
}

There are about 120 instructions supported by MIPT-MIPS so far.
Let's assume that adding tests for 17 instructions is a 1 point, so adding tests to 119 instructions is 7 points. You are not obliged to get all the 7 points at once, you may make 1 point and stop, then continue later or pass the task to another project participant.

@pavelkryukov pavelkryukov added testing Improves testing coverage 7 New functionality which has to be built from scratch with higher value to the project. S1 — ISA To solve the issue, you need knowledge about MIPS or RISC-V ISA labels Jul 29, 2018
@pavelkryukov pavelkryukov added this to the Classic MIPS milestone Jul 29, 2018
@pavelkryukov pavelkryukov removed this from the Classic MIPS milestone Oct 10, 2018
@pukhovv pukhovv self-assigned this Oct 27, 2018
pavelkryukov pushed a commit that referenced this issue Oct 28, 2018
Fixes #589 
Additionally:
New utility method in class BaseMIPSInstr:
    MapType::iterator find_entry(MapType isaMap, std::string_view name);
New unit tests:
    TEST_CASE( "sllv") (#530)
    TEST_CASE( "MIPS32_instr: Divmult") ( using new ctor)

Fix types of supporting function.
Add get_v_imm and set_v_imm for unit tests.
Add sllv, mul, addi, teqi tests.
Fix nop bug for ctor, add nop test for new ctor.
@pavelkryukov
Copy link
Member Author

Just to clarify: torture tests are located here: https://github.com/MIPT-ILab/mips-traces/blob/master/tt.core.universal.s

@pavelkryukov
Copy link
Member Author

@pooh64 What's the progress with that?

@pukhovv
Copy link
Contributor

pukhovv commented Nov 15, 2018

@pavelkryukov Now I'm learning mips assembler, I haven't written new tests yet.

pukhovv added a commit to pukhovv/mipt-mips that referenced this issue Nov 20, 2018
pukhovv added a commit to pukhovv/mipt-mips that referenced this issue Nov 20, 2018
pukhovv added a commit to pukhovv/mipt-mips that referenced this issue Nov 21, 2018
pukhovv added a commit to pukhovv/mipt-mips that referenced this issue Nov 22, 2018
	Fixes in jmp cases.
	Fixed movn/movz case.
	Test for 64bit instr in 32bit ctor.
	References for bug-issue (MIPT-ILab#709).
pukhovv added a commit to pukhovv/mipt-mips that referenced this issue Nov 22, 2018
pukhovv added a commit to pukhovv/mipt-mips that referenced this issue Nov 23, 2018
@bova-ev bova-ev self-assigned this Nov 24, 2018
pukhovv added a commit to pukhovv/mipt-mips that referenced this issue Nov 25, 2018
@pukhovv
Copy link
Contributor

pukhovv commented Nov 25, 2018

Implemented, but not tested instructions:

  1. beql
  2. bgez
  3. bgezal
  4. bgezall
  5. bgezl
  6. bgtz
  7. bgtzl
  8. blez
  9. blezl
  10. bltz
  11. bltzal
  12. bltzall
  13. bltzl
  14. bnel

pukhovv added a commit to pukhovv/mipt-mips that referenced this issue Nov 25, 2018
pukhovv added a commit to pukhovv/mipt-mips that referenced this issue Nov 25, 2018
pavelkryukov pushed a commit that referenced this issue Nov 26, 2018
@pavelkryukov pavelkryukov added 4 Features of medium complexity which usually require infrastructure enhancements. and removed 7 New functionality which has to be built from scratch with higher value to the project. labels Nov 26, 2018
@bova-ev
Copy link
Contributor

bova-ev commented Nov 27, 2018

@pavelkryukov Can I write to the HI and LO registers that are used as destination registers in instruction madd (for example)? As I can see I can change only one destination register by using instr.set_v_dst() function.

@bova-ev
Copy link
Contributor

bova-ev commented Mar 8, 2019

Also I see that every load_store instruction is running at both 32 bit and 64 bit systems. Do I need to test them in 64 bit as well?

@pavelkryukov
Copy link
Member Author

There is some discrepancy between the behavior in 32 bit and 64 bit mode.
I do not remember what is the point, but I suspecte it is related to sign extension.
Could you please tell what is different in 32 bit and 64 bit tests?

@bova-ev
Copy link
Contributor

bova-ev commented Mar 8, 2019

I'm not sure if this is significant difference but in 32 bit MIPS sign extended value we get after lb (0xab should be loaded) is 0xffff'ffab and in 64 bit it is 0xffff'ffff'ffff'ffab just because GPR [rt] is 64 bit long.

@pavelkryukov
Copy link
Member Author

Ok, I agree that difference may be ignored in unit tests. The issue was that MIPS code has to use different immediates.

@pavelkryukov pavelkryukov added 2 Small features, tests coverage, simple laboratory works and removed 4 Features of medium complexity which usually require infrastructure enhancements. labels Mar 11, 2019
@pavelkryukov
Copy link
Member Author

Leaving 2 points as 2 points were committed to the score table.

@bova-ev
Copy link
Contributor

bova-ev commented Mar 11, 2019

@pavelkryukov ll instruction provides primitives to implement atomic Read-Modify-Write (RMW) operations for cached memory locations. How can I test this RMW part of this instruction? Or I can do ll tests similar to lh tests?

@pavelkryukov
Copy link
Member Author

We do not have a data cache model so far, therefore it should behave like a simple load of the similar size.

@bova-ev
Copy link
Contributor

bova-ev commented Mar 11, 2019

ldr and ldl instructions returns the same result with same arguments. I think problem is located here:

template<typename I> auto mips_ldl = ALU::load_addr<I>;
template<typename I> auto mips_ldr = ALU::load_addr<I>;

Do I need to fix this or this is ok?

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 11, 2019
@pavelkryukov
Copy link
Member Author

If you are able to write manual on these instructions (#413), then you can implement them. But at the moment, we should just skip them, since they are not implemented.

@bova-ev
Copy link
Contributor

bova-ev commented Mar 12, 2019

How can I read memory created by this function?

static auto get_plain_memory_with_data()
{
auto memory = FuncMemory::create_plain_memory(15);
memory->write<uint32, Endian::little>( 0xABCD'1234, 0x1000);
return memory;
}

@pavelkryukov
Copy link
Member Author

auto m = get_plain_memory_with_data();
auto value = m->read<uint32, Endian::little>( address);

@bova-ev
Copy link
Contributor

bova-ev commented Mar 15, 2019

Can I write templates in unit_test.cpp?

@pavelkryukov
Copy link
Member Author

Yes, but could you please share your intention? I don't feel there is a good idea...

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 15, 2019
bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 15, 2019
@pavelkryukov pavelkryukov added 1 Usually one-liner tasks, but may require some deep into infrastructure. and removed 2 Small features, tests coverage, simple laboratory works labels Mar 15, 2019
bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 15, 2019
@bova-ev
Copy link
Contributor

bova-ev commented Mar 15, 2019

@pavelkryukov Why do I get dst = 0xdeadbeef when I test bgezal -1? Shouldn't I get dst = PC + 8?

@pavelkryukov
Copy link
Member Author

pavelkryukov commented Mar 15, 2019

Looks like a bug — $ra should be updated regardless of branch being taken or not taken.
Could you please fix it?

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 16, 2019
@bova-ev
Copy link
Contributor

bova-ev commented Mar 16, 2019

Does likely branches do the same thing in simulator as basic branches?

@pavelkryukov
Copy link
Member Author

Likely branches are not supported at the moment, so you may write tests but probably they won't pass. The general idea is that likely branches do not execute delay slot instruction.

bova-ev added a commit to bova-ev/mipt-mips that referenced this issue Mar 16, 2019
@pavelkryukov pavelkryukov added 7 New functionality which has to be built from scratch with higher value to the project. and removed 1 Usually one-liner tasks, but may require some deep into infrastructure. labels Mar 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
7 New functionality which has to be built from scratch with higher value to the project. S1 — ISA To solve the issue, you need knowledge about MIPS or RISC-V ISA testing Improves testing coverage
Projects
None yet
Development

No branches or pull requests

3 participants