From 58ff5a7f55ea13a76668c9a71098a122581f358d Mon Sep 17 00:00:00 2001 From: Clo91eaf Date: Tue, 10 Dec 2024 10:10:45 +0800 Subject: [PATCH] [tests] add coverage hierarchy file in the output of test target --- t1/src/T1.scala | 2 +- tests/builder.nix | 2 +- tests/coverage/mlir/hello.hier | 1 - tests/default.nix | 1 + tests/mlir/default.nix | 8 ++++++++ tests/mlir/hello/hello.json | 15 +++++++++++++++ 6 files changed, 26 insertions(+), 3 deletions(-) delete mode 100644 tests/coverage/mlir/hello.hier create mode 100644 tests/mlir/hello/hello.json diff --git a/t1/src/T1.scala b/t1/src/T1.scala index e4202125a..fbb8653e4 100644 --- a/t1/src/T1.scala +++ b/t1/src/T1.scala @@ -1036,7 +1036,7 @@ class T1(val parameter: T1Parameter) val coverMatch = BoolSequence( requestReg.valid && requestReg.bits.issue.instruction === BitPat("b" + instruction.encoding.toString) ) - CoverProperty(coverMatch, label = Some(s"1_${instruction.name}")) + CoverProperty(coverMatch, label = Some(s"${instruction.name}")) } // // coverage for two instructions diff --git a/tests/builder.nix b/tests/builder.nix index 20c052d8e..8ab89053d 100644 --- a/tests/builder.nix +++ b/tests/builder.nix @@ -51,10 +51,10 @@ let mkdir -p $out/bin cp ${pname}.elf $out/bin + cp ${pname}.cover $out ${jqBin} --null-input \ --arg name ${pname} \ - --arg type ${casePrefix} \ --arg elfPath "$out/bin/${pname}.elf" \ '{ "name": $name, "elf": { "path": $elfPath } }' \ > $out/${pname}.json diff --git a/tests/coverage/mlir/hello.hier b/tests/coverage/mlir/hello.hier deleted file mode 100644 index 11dff3595..000000000 --- a/tests/coverage/mlir/hello.hier +++ /dev/null @@ -1 +0,0 @@ -+assert _1_vmv_v_i \ No newline at end of file diff --git a/tests/default.nix b/tests/default.nix index dd5392576..ceb5e6500 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -113,6 +113,7 @@ let mkdir -p $out/cases/${caseDrv.pname} cp ${caseDrv}/bin/${caseDrv.pname}.elf $out/cases/${caseDrv.pname}/ cp ${caseDrv}/${caseDrv.pname}.json $out/configs/ + cp ${caseDrv}/${caseDrv.pname}.cover $out/configs/ '') allCases); in diff --git a/tests/mlir/default.nix b/tests/mlir/default.nix index 486506932..0ce7161aa 100644 --- a/tests/mlir/default.nix +++ b/tests/mlir/default.nix @@ -4,6 +4,7 @@ , findAndBuild , getTestRequiredFeatures , t1main +, jq }: let @@ -54,6 +55,13 @@ let ${caseName}.c $pname.S ${t1main} \ -o $pname.elf + if [ ! -f ${sourcePath}/${caseName}.json ]; then + echo "Error: ${sourcePath}/${caseName}.json not found" >&2 + else + ${jq}/bin/jq -r '[.assert[] | "+assert " + .name] + [.tree[] | "+tree " + .name] + [.module[] | "+module " + .name] | .[]' \ + ${sourcePath}/${caseName}.json > $pname.cover + fi + runHook postBuild ''; diff --git a/tests/mlir/hello/hello.json b/tests/mlir/hello/hello.json new file mode 100644 index 000000000..e6076582b --- /dev/null +++ b/tests/mlir/hello/hello.json @@ -0,0 +1,15 @@ +{ + "case": "mlir.hello", + "assert": [ + { + "description": "vmv.v.i instruction covered", + "name": "vmv_v_i" + }, + { + "description": "vmv.v.x instruction covered", + "name": "vmv_v_x" + } + ], + "tree": [], + "module": [] +} \ No newline at end of file