Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: DSLX: Create a tool to generate proc tests automatically #1284

Open
mczyz-antmicro opened this issue Jan 29, 2024 · 1 comment

Comments

@mczyz-antmicro
Copy link
Contributor

The process of creating proc unit tests is repetitive and requires rewriting boilerplate code. Take a look at:

The steps to create a proc test are:

  • Create new proc (config, init, next function)
  • Declare the same channels as in Proc Under Test (PUT), but in reversed direction
  • Add terminator channel
  • In config function, create consumer/producer channel endpoints and attach them to PUT and test proc (this can be figured out based on the channel direction of the PUT)

Resulting code is predictable and could be done automatically with a tool, which parses the config function of the PUT. Ideally, the tool would be implemented in such a way, that it could be reused by code editors plugins, e.g. VSCode Plugin. Another solution would be to figure out how to change DSLX syntax to reduce the boilerplate.

@meheff
Copy link
Collaborator

meheff commented Jul 17, 2024

FWIW we're kicking around an idea which would simplify the proc syntax. We hope to prioritize this in the coming months and will post more publicly. Here's an example test proc (syntax not at all finalized):

// Test proc using token-less sends and receives.
#[test_proc]
proc proc_test() {
  input: chan<u32>;
  result: chan<u32>;

  // Instantiation of proc under test.
  dut: instantiate my_proc(input.in, result.out);

  run {
    // Tokens are threaded implicitly. sends/recvs are serialized.
    send(input.out, u32:123);
    send(input.out, u32:42);

    assert_eq!(recv(result.in), u32:11);
    assert_eq!(recv(result.in), u32:12);

    // New builtin for terminating the test. This replaces the terminator channel.
    finish!();
  }
}

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

No branches or pull requests

2 participants