mardi 19 mars 2019

How to generate an [error] instead of an [info] upon seeing a wrong value in expect()

Consider the following code:

import chisel3._
import chisel3.util._
import chisel3.iotesters._

class Inverter extends Module {
  val io = IO(new Bundle {
    val a = Input(UInt(4.W))
    val s = Output(UInt(4.W))
  })
  io.s := ~io.a
}

class InverterTester(c: Inverter) extends PeekPokeTester(c) {
  poke(c.io.a, 8)
  step(1)
  expect(c.io.s, 8) // Should be 7 here
}

object TestMain extends App {
  chisel3.iotesters.Driver.execute(args, () => new Inverter()) {
    c => new InverterTester(c)
  }
}

Now I run sbt 'test:runMain TestMain' and got this line (info is in purple):

[info] [0.002] EXPECT AT 1   io_s got 7 expected 8 FAIL

And the exit value of sbt is zero.

I need that line to be an error (with red color):

[error] [0.002] EXPECT AT 1   io_s got 7 expected 8 FAIL

As well as making the above sbt command exit with a non-zero value.

How can I achieve it with minimal change to existing code?

Aucun commentaire:

Enregistrer un commentaire