From 0cb681fbbceb92e02452bc18bb460817bdb91a3d Mon Sep 17 00:00:00 2001 From: Avimitin Date: Mon, 14 Oct 2024 15:01:59 +0800 Subject: [PATCH] [script] add new "--top" option to all sub targets Signed-off-by: Avimitin --- script/ci/src/Main.scala | 43 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/script/ci/src/Main.scala b/script/ci/src/Main.scala index b73de2a6c..0fec31725 100644 --- a/script/ci/src/Main.scala +++ b/script/ci/src/Main.scala @@ -126,10 +126,11 @@ object Main: def generateCiMatrix( runnersAmount: Int, caseDir: String = "designs", - testPlanFile: String = "default.json" + top: String ) = { val testPlans = - os.walk(os.pwd / ".github" / caseDir).filter(_.last == testPlanFile) + os.walk(os.pwd / ".github" / caseDir) + .filter(_.last == s"${top}.json") println(toMatrixJson(scheduleTasks(testPlans, runnersAmount))) } @@ -144,9 +145,9 @@ object Main: // @param: dontBail don't throw exception when test fail. Useful for postpr. @main def runTests( - jobs: String, - testIp: String, - testType: String + jobs: String, + top: String, + emuLib: String ): Unit = if jobs == "" then Logger.info("No test found, exiting") @@ -161,17 +162,17 @@ object Main: s"${BOLD}[${index + 1}/${allJobs.length}]${RESET} Simulating test case $caseName with config $config" ) - val testAttr = testType.toLowerCase() match + val testAttr = emuLib.toLowerCase() match case "verilator" => - s".#t1.$config.$testIp.run.$caseName.verilator-emu" - case "vcs" => s".#t1.$config.$testIp.run.$caseName.vcs-emu" - case _ => Logger.fatal(s"Invalid test type ${testType}") + s".#t1.$config.$top.run.$caseName.verilator-emu" + case "vcs" => s".#t1.$config.$top.run.$caseName.vcs-emu" + case _ => Logger.fatal(s"Invalid test type ${emuLib}") val testResultPath = try os.Path( nixResolvePath( testAttr, - if testType == "vcs" then Seq("--impure") else Seq() + if emuLib == "vcs" then Seq("--impure") else Seq() ) ) catch @@ -179,7 +180,7 @@ object Main: Logger.error( s"Online driver for config $config, case $caseName fail, please check manually on local machine" ) - Logger.error(s"nix build $testAttr" ++ (if testType == "vcs" then " --impure" else "")) + Logger.error(s"nix build $testAttr" ++ (if emuLib == "vcs" then " --impure" else "")) Logger.fatal("Online Drive run fail, exiting CI") Logger.info("Checking RTL event from event log") @@ -220,9 +221,13 @@ object Main: doc = "specify the urg report markdown file output path" ) urgReportFilePath: Option[String], @arg( - name = "emu-type", - doc = "Specify emulation type" - ) emuType: String = "verilator", + name = "emu-lib", + doc = "Specify emulator library type, verilator or vcs" + ) emuLib: String = "vcs", + @arg( + name = "top", + doc = "Specify emulator ip top, Eg. t1rocketemu/t1emu..." + ) top: String, @arg( name = "case-dir", doc = "Specify case directory" @@ -247,8 +252,8 @@ object Main: Logger.info("Fetching CI results") val emuResultPath = os.Path( nixResolvePath( - s".#t1.$config.ip.run._${emuType}EmuResult", - if emuType.toLowerCase() == "vcs" then Seq("--impure") + s".#t1.$config.${top}.run._${emuLib}EmuResult", + if emuLib.toLowerCase() == "vcs" then Seq("--impure") else Seq() ) ) @@ -261,7 +266,7 @@ object Main: val caseName = path.segments.toSeq.reverse.drop(1).head os.write.append( failedTestsFile, - s"* ${config} - ${caseName}: `nix build .#t1.$config.ip.$caseName.$emuType-emu -L --impure`\n" + s"* ${config} - ${caseName}: `nix build .#t1.$config.${top}.$caseName.$emuLib-emu -L --impure`\n" ) }) @@ -309,10 +314,10 @@ object Main: end postCI @main - def generateTestPlan() = + def generateTestPlan(top: String) = val testPlans = os .walk(os.pwd / ".github" / "designs") - .filter(_.last == "default.json") + .filter(_.last == s"${top}.json") .map(path => path.segments.toSeq.reverse.drop(1).head) println(ujson.write(Map("config" -> testPlans)))