Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Cleanup - Move tests into separate files #649

Closed

Conversation

Lichtso
Copy link

@Lichtso Lichtso commented Jan 7, 2025

Rust has two styles for writing tests:

  • Inlined in a cfged module inside the normal source files
  • Separated as files in the tests subdirectory

The first style has the advantage that one can reuse the use import statements and gets direct access to private fields. The second style allows one to use the crates dev-dependencies.

Currently we use both. This PR converts all of the first to the second. This will allow subsequent PRs to move test only code such as syscalls.rs and the TestContextObject into the test_utils crate as a dev-dependency.

* Always sanitize emit_profile_instruction_count() and emit_undo_profile_instruction_count().

* Sanitize emit_validate_instruction_count() as well.
* Updates the README

* Bump to v0.9.0

* Renames the crate.
* All the immediate values can use the same encryption key.
There is no need to generate a new one for each.

* Optimizes memory access instructions.

* Moves second half of emit_sanitized_load_immediate(REGISTER_SCRATCH, vm_addr) into ANCHOR_TRANSLATE_MEMORY_ADDRESS.

* Moves second half of emit_sanitized_load_immediate(stack_slot_of_value_to_store, constant) into ANCHOR_TRANSLATE_MEMORY_ADDRESS.
* Removes dst == FRAME_PTR_REG special case.

* Allows encoding of u8 displacement in SIB mode.

* Splits off X86Instruction::alu_immediate().

* Adds X86Register.
* Swaps `mov32 dst, imm` and `mov64 dst, imm` behavior description.

* Makes cargo clippy happy.
…rams (#11)

* Address offsetting via indirection of the load instruction.

* Groups the instructions of `self.emit_profile_instruction_count(None);`.

* Stores text_section relative offsets in pc_section instead of absolute addresses.

* Stores u32 instead of u64 elements in pc_section.

* Spills to MMX register and uses 64 bit load immediate.
…12)

* Uses the MSB in pc_section to mark invalid call targets.

* Removes the second pass over pc_section in resolve_jumps().

* Removes emit_undo_profile_instruction_count() from ANCHOR_CALL_REG_UNSUPPORTED_INSTRUCTION.
* Moves test_invalid_exit_or_return() to verifier tests.

* Moves test_invalid_call_imm() to verifier.

* Adds test_call_imm_does_not_dispatch_syscalls().

* Moves test_interpreter_and_jit, test_interpreter_and_jit_asm, test_interpreter_and_jit_elf and test_syscall_asm into test_utils crate.

* Removes JIT compilation error check.

* Refactors expected_result in test_interpreter_and_jit!().

* Removes the option to skip the verifier in test_interpreter_and_jit!().

* Run all tests (except for those which expect ExceededMaxInstructions) with and without override_budget.

* Adds a variant of test_interpreter_and_jit!() which does not check the result.

* Uses test_utils macros in exercise_instructions test_ins().

* Report all diverged properties.
@Lichtso Lichtso closed this Jan 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant