From fc7ac6c16cb9f390904c9736846a4310e12e02b9 Mon Sep 17 00:00:00 2001 From: dsengupta0628 Date: Sun, 5 Apr 2026 00:18:45 +0000 Subject: [PATCH 1/2] test/cpp changes Signed-off-by: dsengupta0628 --- dcalc/test/cpp/TestDcalc.cc | 5 +++ liberty/test/cpp/TestLibertyStaBasics.cc | 29 ++++++++++++++-- liberty/test/cpp/TestLibertyStaBasicsB.cc | 38 ++++++++++++++------- liberty/test/cpp/TestLibertyStaCallbacks.cc | 6 ++-- network/test/cpp/TestNetworkB.cc | 2 ++ sdc/test/cpp/TestSdcStaDesign.cc | 4 +++ sdc/test/cpp/TestSdcStaInit.cc | 34 ++++-------------- 7 files changed, 73 insertions(+), 45 deletions(-) diff --git a/dcalc/test/cpp/TestDcalc.cc b/dcalc/test/cpp/TestDcalc.cc index d7082f0d..e7ea6466 100644 --- a/dcalc/test/cpp/TestDcalc.cc +++ b/dcalc/test/cpp/TestDcalc.cc @@ -4263,6 +4263,7 @@ TEST_F(NangateDcalcTest, DmpExtremeLoads) { ASSERT_NE(out_port, nullptr); Scene *corner = sta_->cmdScene(); + (void)corner; float loads[] = {0.00001f, 0.1f, 1.0f, 5.0f, 10.0f}; Slack prev_slack = 0.0f; bool first = true; @@ -4315,6 +4316,7 @@ TEST_F(NangateDcalcTest, DmpCombinedExtremes) { ASSERT_NE(in_port, nullptr); Scene *corner = sta_->cmdScene(); + (void)corner; // Large load + fast slew sta_->setPortExtPinCap(out_port, RiseFallBoth::riseFall(), @@ -4348,6 +4350,7 @@ TEST_F(NangateDcalcTest, TwoPoleExtremeLoads) { ASSERT_NE(out_port, nullptr); Scene *corner = sta_->cmdScene(); + (void)corner; float loads[] = {0.00001f, 0.1f, 1.0f, 5.0f, 10.0f}; for (float load : loads) { sta_->setPortExtPinCap(out_port, RiseFallBoth::riseFall(), @@ -4532,6 +4535,7 @@ TEST_F(MultiDriverDcalcTest, DmpCeffLoadSweep) { ASSERT_NE(out_port, nullptr); Scene *corner = sta_->cmdScene(); + (void)corner; float loads[] = {0.001f, 0.005f, 0.01f, 0.05f, 0.1f}; Slack prev_slack = 1e30f; // Start with large positive value for (float load : loads) { @@ -4593,6 +4597,7 @@ TEST_F(MultiDriverDcalcTest, IncrementalLoadChanges) { Instance *top = network->topInstance(); Cell *top_cell = network->cell(top); Scene *corner = sta_->cmdScene(); + (void)corner; const char *output_ports[] = {"out1", "out2", "out3"}; for (const char *pname : output_ports) { diff --git a/liberty/test/cpp/TestLibertyStaBasics.cc b/liberty/test/cpp/TestLibertyStaBasics.cc index e0886203..e1dbe9ac 100644 --- a/liberty/test/cpp/TestLibertyStaBasics.cc +++ b/liberty/test/cpp/TestLibertyStaBasics.cc @@ -40,8 +40,9 @@ static void expectStaLibertyCoreState(Sta *sta, LibertyLibrary *lib) EXPECT_NE(sta->cmdSdc(), nullptr); EXPECT_NE(sta->report(), nullptr); EXPECT_FALSE(sta->scenes().empty()); - if (!sta->scenes().empty()) + if (!sta->scenes().empty()) { EXPECT_GE(sta->scenes().size(), 1); + } EXPECT_NE(sta->cmdScene(), nullptr); EXPECT_NE(lib, nullptr); } @@ -303,6 +304,7 @@ TEST_F(StaLibertyTest, TimingArcSetCondDefault) { TimingArcSet *arcset = arcsets[0]; // Just call the getter for coverage bool is_default = arcset->isCondDefault(); + (void)is_default; // is_default value depends on cell type } @@ -314,10 +316,15 @@ TEST_F(StaLibertyTest, TimingArcSetSdfCond) { TimingArcSet *arcset = arcsets[0]; // SDF condition getters - may be empty for simple arcs const std::string &sdf_cond = arcset->sdfCond(); + (void)sdf_cond; const std::string &sdf_start = arcset->sdfCondStart(); + (void)sdf_start; const std::string &sdf_end = arcset->sdfCondEnd(); + (void)sdf_end; const std::string &mode_name = arcset->modeName(); + (void)mode_name; const std::string &mode_value = arcset->modeValue(); + (void)mode_value; // sdf_cond may be empty for simple arcs // sdf_start may be empty for simple arcs // sdf_end may be empty for simple arcs @@ -353,6 +360,7 @@ TEST_F(StaLibertyTest, TimingArcProperties) { // Test model TimingModel *model = arc->model(); + (void)model; // model may be null depending on cell type } @@ -431,6 +439,7 @@ TEST_F(StaLibertyTest, LibraryPortProperties) { // Test capacitanceIsOneValue bool one_val = a->capacitanceIsOneValue(); + (void)one_val; // one_val value depends on cell type // Test driveResistance @@ -467,8 +476,11 @@ TEST_F(StaLibertyTest, PortClockFlags) { LibertyPort *ck = dff->findLibertyPort("CK"); if (ck) { bool is_clk = ck->isClock(); + (void)is_clk; bool is_reg_clk = ck->isRegClk(); + (void)is_reg_clk; bool is_check_clk = ck->isCheckClk(); + (void)is_check_clk; // is_clk tested implicitly (bool accessor exercised) // is_reg_clk tested implicitly (bool accessor exercised) // is_check_clk tested implicitly (bool accessor exercised) @@ -476,6 +488,7 @@ TEST_F(StaLibertyTest, PortClockFlags) { LibertyPort *q = dff->findLibertyPort("Q"); if (q) { bool is_reg_out = q->isRegOutput(); + (void)is_reg_out; // is_reg_out tested implicitly (bool accessor exercised) } } @@ -600,7 +613,9 @@ TEST_F(StaLibertyTest, PortRelatedPorts) { LibertyPort *a = buf->findLibertyPort("A"); ASSERT_NE(a, nullptr); LibertyPort *ground_port = a->relatedGroundPort(); + (void)ground_port; LibertyPort *power_port = a->relatedPowerPort(); + (void)power_port; // ground_port may be null for simple cells // power_port may be null for simple cells } @@ -638,6 +653,7 @@ TEST_F(StaLibertyTest, PortReceiverModel) { LibertyPort *a = buf->findLibertyPort("A"); ASSERT_NE(a, nullptr); const ReceiverModel *rm = a->receiverModel(); + (void)rm; // rm may be null depending on cell type } @@ -659,6 +675,7 @@ TEST_F(StaLibertyTest, CellInternalPowers) { } // relatedPgPin may be nullptr LibertyPort *pgpin = pwr.relatedPgPin(); + (void)pgpin; // pgpin may be null for simple arcs EXPECT_EQ(pwr.libertyCell(), buf); } @@ -679,6 +696,7 @@ TEST_F(StaLibertyTest, CellDontUse) { LibertyCell *buf = lib_->findLibertyCell("BUF_X1"); ASSERT_NE(buf, nullptr); bool dont_use = buf->dontUse(); + (void)dont_use; // dont_use value depends on cell type } @@ -1031,6 +1049,7 @@ TEST_F(StaLibertyTest, CellScaleFactors) { LibertyCell *buf = lib_->findLibertyCell("BUF_X1"); ASSERT_NE(buf, nullptr); ScaleFactors *sf = buf->scaleFactors(); + (void)sf; // sf may be null depending on cell type } @@ -1045,6 +1064,7 @@ TEST_F(StaLibertyTest, CellOcvDerate) { LibertyCell *buf = lib_->findLibertyCell("BUF_X1"); ASSERT_NE(buf, nullptr); OcvDerate *derate = buf->ocvDerate(); + (void)derate; // derate may be null depending on cell type } @@ -2170,10 +2190,12 @@ TEST_F(StaLibertyTest, PortRegClkAndOutput) { LibertyPort *clk = dff->findLibertyPort("CK"); ASSERT_NE(clk, nullptr); bool is_reg_clk = clk->isRegClk(); + (void)is_reg_clk; // is_reg_clk value depends on cell type LibertyPort *q = dff->findLibertyPort("Q"); ASSERT_NE(q, nullptr); bool is_reg_out = q->isRegOutput(); + (void)is_reg_out; // is_reg_out value depends on cell type } @@ -2183,6 +2205,7 @@ TEST_F(StaLibertyTest, PortLatchData) { LibertyPort *d = dlh->findLibertyPort("D"); ASSERT_NE(d, nullptr); bool is_latch_data = d->isLatchData(); + (void)is_latch_data; // is_latch_data value depends on cell type } @@ -2281,6 +2304,7 @@ TEST_F(StaLibertyTest, CellHasInternalPorts) { LibertyCell *buf = lib_->findLibertyCell("BUF_X1"); ASSERT_NE(buf, nullptr); bool hip = buf->hasInternalPorts(); + (void)hip; // hip value depends on cell type } @@ -3252,8 +3276,9 @@ TEST_F(StaLibertyTest, CellHasSequentials2) { ASSERT_NE(buf, nullptr); EXPECT_FALSE(buf->hasSequentials()); LibertyCell *dff = lib_->findLibertyCell("DFF_X1"); - if (dff) + if (dff) { EXPECT_TRUE(dff->hasSequentials()); + } } TEST_F(StaLibertyTest, CellTimingArcSets2) { diff --git a/liberty/test/cpp/TestLibertyStaBasicsB.cc b/liberty/test/cpp/TestLibertyStaBasicsB.cc index c74696f9..2601fcab 100644 --- a/liberty/test/cpp/TestLibertyStaBasicsB.cc +++ b/liberty/test/cpp/TestLibertyStaBasicsB.cc @@ -40,8 +40,9 @@ static void expectStaLibertyCoreState(Sta *sta, LibertyLibrary *lib) EXPECT_NE(sta->cmdSdc(), nullptr); EXPECT_NE(sta->report(), nullptr); EXPECT_FALSE(sta->scenes().empty()); - if (!sta->scenes().empty()) + if (!sta->scenes().empty()) { EXPECT_GE(sta->scenes().size(), 1); + } EXPECT_NE(sta->cmdScene(), nullptr); EXPECT_NE(lib, nullptr); } @@ -860,6 +861,7 @@ TEST_F(StaLibertyTest, CellFootprint2) { LibertyCell *buf = lib_->findLibertyCell("BUF_X1"); ASSERT_NE(buf, nullptr); const std::string &fp = buf->footprint(); + (void)fp; // fp may be empty for simple arcs } @@ -1433,6 +1435,7 @@ TEST(R6_FuncExprTest, PortExprCheckSizeOne) { // Port with size 1 should return true for checkSize(1) // (depends on port->size()) bool result = port_expr->checkSize(1); + (void)result; // Just exercise the code path // result tested implicitly (bool accessor exercised) delete port_expr; @@ -1462,7 +1465,7 @@ TEST(R6_FuncExprTest, HasPortMatching) { FuncExpr *expr_a = FuncExpr::makePort(port_a); EXPECT_TRUE(expr_a->hasPort(port_a)); EXPECT_FALSE(expr_a->hasPort(port_b)); - expr_a; // deleteSubexprs removed + (void)expr_a; // deleteSubexprs removed } TEST(R6_FuncExprTest, LessPortExprs) { @@ -1478,8 +1481,8 @@ TEST(R6_FuncExprTest, LessPortExprs) { bool r1 = FuncExpr::less(expr_a, expr_b); bool r2 = FuncExpr::less(expr_b, expr_a); EXPECT_NE(r1, r2); - expr_a; // deleteSubexprs removed - expr_b; // deleteSubexprs removed + (void)expr_a; // deleteSubexprs removed + (void)expr_b; // deleteSubexprs removed } TEST(R6_FuncExprTest, EquivPortExprs) { @@ -1490,8 +1493,8 @@ TEST(R6_FuncExprTest, EquivPortExprs) { FuncExpr *expr1 = FuncExpr::makePort(port_a); FuncExpr *expr2 = FuncExpr::makePort(port_a); EXPECT_TRUE(FuncExpr::equiv(expr1, expr2)); - expr1; // deleteSubexprs removed - expr2; // deleteSubexprs removed + (void)expr1; // deleteSubexprs removed + (void)expr2; // deleteSubexprs removed } //////////////////////////////////////////////////////////////// @@ -2255,6 +2258,7 @@ TEST_F(StaLibertyTest, CellFootprint3) { LibertyCell *buf = lib_->findLibertyCell("BUF_X1"); ASSERT_NE(buf, nullptr); const std::string &fp = buf->footprint(); + (void)fp; // May be empty for simple arcs } @@ -2271,6 +2275,7 @@ TEST_F(StaLibertyTest, CellUserFunctionClass2) { LibertyCell *buf = lib_->findLibertyCell("BUF_X1"); ASSERT_NE(buf, nullptr); const std::string &ufc = buf->userFunctionClass(); + (void)ufc; // ufc may be empty for simple arcs } @@ -2690,7 +2695,7 @@ TEST_F(StaLibertyTest, FuncExprMakeNot) { EXPECT_EQ(not_expr->left(), port_expr); std::string s = not_expr->to_string(); EXPECT_FALSE(s.empty()); - not_expr; // deleteSubexprs removed + (void)not_expr; // deleteSubexprs removed } // FuncExpr::makeAnd @@ -2707,7 +2712,7 @@ TEST_F(StaLibertyTest, FuncExprMakeAnd) { EXPECT_EQ(and_expr->op(), FuncExpr::Op::and_); std::string s = and_expr->to_string(); EXPECT_FALSE(s.empty()); - and_expr; // deleteSubexprs removed + (void)and_expr; // deleteSubexprs removed } // FuncExpr::makeOr @@ -2722,7 +2727,7 @@ TEST_F(StaLibertyTest, FuncExprMakeOr) { FuncExpr *right = FuncExpr::makePort(a2); FuncExpr *or_expr = FuncExpr::makeOr(left, right); EXPECT_EQ(or_expr->op(), FuncExpr::Op::or_); - or_expr; // deleteSubexprs removed + (void)or_expr; // deleteSubexprs removed } // FuncExpr::makeXor @@ -2735,7 +2740,7 @@ TEST_F(StaLibertyTest, FuncExprMakeXor) { FuncExpr *right = FuncExpr::makePort(a); FuncExpr *xor_expr = FuncExpr::makeXor(left, right); EXPECT_EQ(xor_expr->op(), FuncExpr::Op::xor_); - xor_expr; // deleteSubexprs removed + (void)xor_expr; // deleteSubexprs removed } // FuncExpr::makeZero and makeOne @@ -2772,8 +2777,9 @@ TEST_F(StaLibertyTest, FuncExprHasPort) { ASSERT_NE(a, nullptr); FuncExpr *expr = FuncExpr::makePort(a); EXPECT_TRUE(expr->hasPort(a)); - if (zn) + if (zn) { EXPECT_FALSE(expr->hasPort(zn)); + } delete expr; } @@ -2786,7 +2792,7 @@ TEST_F(StaLibertyTest, FuncExprPortTimingSense) { FuncExpr *not_expr = FuncExpr::makeNot(FuncExpr::makePort(a)); TimingSense sense = not_expr->portTimingSense(a); EXPECT_EQ(sense, TimingSense::negative_unate); - not_expr; // deleteSubexprs removed + (void)not_expr; // deleteSubexprs removed } // FuncExpr::copy @@ -2905,8 +2911,9 @@ TEST_F(StaLibertyTest, PortIsClock2) { ASSERT_NE(ck, nullptr); EXPECT_TRUE(ck->isClock()); LibertyPort *d = dff->findLibertyPort("D"); - if (d) + if (d) { EXPECT_FALSE(d->isClock()); + } } // LibertyPort::setIsClock @@ -3047,6 +3054,7 @@ TEST_F(StaLibertyTest, TimingArcSetIsCondDefault) { ASSERT_GT(arcsets.size(), 0u); // Default should be false or true depending on library bool cd = arcsets[0]->isCondDefault(); + (void)cd; // cd value depends on cell type } @@ -3326,6 +3334,7 @@ TEST_F(StaLibertyTest, PortCapacitanceIsOneValue2) { LibertyPort *a = buf->findLibertyPort("A"); ASSERT_NE(a, nullptr); bool one_val = a->capacitanceIsOneValue(); + (void)one_val; // one_val value depends on cell type } @@ -3384,6 +3393,9 @@ TEST_F(StaLibertyTest, ScaleFactorTypeRiseFallSuffix) { bool rfs = scaleFactorTypeRiseFallSuffix(ScaleFactorType::cell); bool rfp = scaleFactorTypeRiseFallPrefix(ScaleFactorType::cell); bool lhs = scaleFactorTypeLowHighSuffix(ScaleFactorType::cell); + (void)rfs; + (void)rfp; + (void)lhs; // rfs tested implicitly (bool accessor exercised) // rfp tested implicitly (bool accessor exercised) // lhs tested implicitly (bool accessor exercised) diff --git a/liberty/test/cpp/TestLibertyStaCallbacks.cc b/liberty/test/cpp/TestLibertyStaCallbacks.cc index dc696358..70f3502f 100644 --- a/liberty/test/cpp/TestLibertyStaCallbacks.cc +++ b/liberty/test/cpp/TestLibertyStaCallbacks.cc @@ -42,8 +42,9 @@ static void expectStaLibertyCoreState(Sta *sta, LibertyLibrary *lib) EXPECT_NE(sta->cmdSdc(), nullptr); EXPECT_NE(sta->report(), nullptr); EXPECT_FALSE(sta->scenes().empty()); - if (!sta->scenes().empty()) + if (!sta->scenes().empty()) { EXPECT_GE(sta->scenes().size(), 1); + } EXPECT_NE(sta->cmdScene(), nullptr); EXPECT_NE(lib, nullptr); } @@ -3847,8 +3848,9 @@ library(test_r11_bus) { if (bus_port) { // findLibertyMember on bus port LibertyPort *member = bus_port->findLibertyMember(0); - if (member) + if (member) { EXPECT_NE(member, nullptr); + } } } } diff --git a/network/test/cpp/TestNetworkB.cc b/network/test/cpp/TestNetworkB.cc index 7a1203ce..d9aeddc9 100644 --- a/network/test/cpp/TestNetworkB.cc +++ b/network/test/cpp/TestNetworkB.cc @@ -1536,6 +1536,7 @@ TEST_F(ConcreteNetworkLinkedTest, MakeTermAndTermName) { // Exercises ConcreteTerm::name() // Exercise Term accessors Net *tnet_check = network_.net(term); + (void)tnet_check; // Exercises NetworkNameAdapter::id(Term) ObjectId tid = network_.id(term); EXPECT_GE(tid, 0u); @@ -1711,6 +1712,7 @@ TEST_F(NetworkAdapterTest, AdapterMakeNet2) { TEST_F(NetworkAdapterTest, AdapterConnect2) { Instance *top = sdc_net_->topInstance(); Net *net = sdc_net_->makeNet("r7_adapter_conn_net", top); + (void)net; // makeInstance requires LibertyCell, get it from the network LibertyCell *lib_cell = sdc_net_->findLibertyCell("INV_X1"); if (lib_cell) { diff --git a/sdc/test/cpp/TestSdcStaDesign.cc b/sdc/test/cpp/TestSdcStaDesign.cc index 64603201..e7744b5b 100644 --- a/sdc/test/cpp/TestSdcStaDesign.cc +++ b/sdc/test/cpp/TestSdcStaDesign.cc @@ -184,6 +184,7 @@ TEST_F(SdcDesignTest, CycleAcctingSourceTargetCycle) { TEST_F(SdcInitTest, ExceptionThruAsString) { ASSERT_NO_THROW(( [&](){ Sdc *sdc = sta_->cmdSdc(); + (void)sdc; Network *network = sta_->cmdNetwork(); // Create ExceptionThru with no objects ExceptionThru *thru = new ExceptionThru(nullptr, nullptr, nullptr, @@ -230,6 +231,7 @@ TEST_F(SdcInitTest, ExceptionFromHash) { TEST_F(SdcInitTest, ExceptionPathMergeable) { Sdc *sdc = sta_->cmdSdc(); + (void)sdc; FalsePath *fp1 = new FalsePath(nullptr, nullptr, nullptr, MinMaxAll::all(), true, ""); FalsePath *fp2 = new FalsePath(nullptr, nullptr, nullptr, @@ -507,6 +509,7 @@ TEST_F(SdcDesignTest, WriteSdcWithDerating) { TEST_F(SdcDesignTest, WriteSdcWithDisable) { Graph *graph = sta_->graph(); Network *network = sta_->cmdNetwork(); + (void)network; Pin *pin = findPin("r1/D"); if (pin && graph) { Vertex *v = graph->pinLoadVertex(pin); @@ -608,6 +611,7 @@ TEST_F(SdcDesignTest, SdcClockLatencyEdge) { Sdc *sdc = sta_->cmdSdc(); Graph *graph = sta_->graph(); Network *network = sta_->cmdNetwork(); + (void)network; Pin *pin = findPin("r1/CK"); if (pin && graph) { Vertex *v = graph->pinLoadVertex(pin); diff --git a/sdc/test/cpp/TestSdcStaInit.cc b/sdc/test/cpp/TestSdcStaInit.cc index 41ad4e3d..23c065cc 100644 --- a/sdc/test/cpp/TestSdcStaInit.cc +++ b/sdc/test/cpp/TestSdcStaInit.cc @@ -35,31 +35,6 @@ namespace sta { -static std::string -readTextFile(const char *filename) -{ - std::ifstream in(filename); - if (!in.is_open()) - return ""; - return std::string((std::istreambuf_iterator(in)), - std::istreambuf_iterator()); -} - -static size_t -countSubstring(const std::string &text, - const std::string &needle) -{ - if (needle.empty()) - return 0; - size_t count = 0; - size_t pos = 0; - while ((pos = text.find(needle, pos)) != std::string::npos) { - ++count; - pos += needle.size(); - } - return count; -} - //////////////////////////////////////////////////////////////// // SDC tests that require full Sta initialization //////////////////////////////////////////////////////////////// @@ -1904,8 +1879,9 @@ TEST_F(SdcInitTest, DeratingFactorsIsOneValue2) { bool is_one_value; float value; df.isOneValue(EarlyLate::early(), is_one_value, value); - if (is_one_value) + if (is_one_value) { EXPECT_FLOAT_EQ(value, 0.9f); + } } // DeratingFactors isOneValue per clk_data @@ -1917,8 +1893,9 @@ TEST_F(SdcInitTest, DeratingFactorsIsOneValueClkData2) { float value; df.isOneValue(PathClkOrData::clk, EarlyLate::early(), is_one_value, value); - if (is_one_value) + if (is_one_value) { EXPECT_FLOAT_EQ(value, 0.95f); + } } // DeratingFactorsGlobal @@ -2034,8 +2011,9 @@ TEST_F(SdcInitTest, DeratingFactorsCellIsOneValue2) { bool is_one; float val; dfc.isOneValue(EarlyLate::early(), is_one, val); - if (is_one) + if (is_one) { EXPECT_FLOAT_EQ(val, 0.95f); + } } // DeratingFactorsNet From 43177bba8f5f88dfb7dc35795242080a4fe2e986 Mon Sep 17 00:00:00 2001 From: dsengupta0628 Date: Sun, 5 Apr 2026 00:38:29 +0000 Subject: [PATCH 2/2] more to fix Signed-off-by: dsengupta0628 --- search/test/cpp/TestSearchIncremental.cc | 3 + search/test/cpp/TestSearchStaDesign.cc | 80 +++++++++++------------- search/test/cpp/TestSearchStaDesignB.cc | 21 ++++++- search/test/cpp/TestSearchStaInit.cc | 9 ++- search/test/cpp/TestSearchStaInitB.cc | 12 +++- 5 files changed, 78 insertions(+), 47 deletions(-) diff --git a/search/test/cpp/TestSearchIncremental.cc b/search/test/cpp/TestSearchIncremental.cc index f1d70900..8d4d0f37 100644 --- a/search/test/cpp/TestSearchIncremental.cc +++ b/search/test/cpp/TestSearchIncremental.cc @@ -143,6 +143,7 @@ TEST_F(IncrementalTimingTest, ReplaceCellDownsize) { // Get initial worst slack Slack initial_slack = sta_->worstSlack(MinMax::max()); + (void)initial_slack; // Find buf1 and upsize it first so we have room to downsize Instance *buf1 = network->findChild(top, "buf1"); @@ -423,6 +424,7 @@ TEST_F(IncrementalTimingTest, ClockConstraintAfterEdit) { Instance *top = network->topInstance(); Slack initial_slack = sta_->worstSlack(MinMax::max()); + (void)initial_slack; // Edit: Replace buf1 with BUF_X4 Instance *buf1 = network->findChild(top, "buf1"); @@ -1289,6 +1291,7 @@ TEST_F(IncrementalTimingTest, OutputDelayChangeUpdatesTiming) { TEST_F(IncrementalTimingTest, ClockLatencyAffectsTiming) { Network *network = sta_->cmdNetwork(); Instance *top = network->topInstance(); + (void)top; Slack initial_slack = sta_->worstSlack(MinMax::max()); diff --git a/search/test/cpp/TestSearchStaDesign.cc b/search/test/cpp/TestSearchStaDesign.cc index e8a36ff9..6dc3d20e 100644 --- a/search/test/cpp/TestSearchStaDesign.cc +++ b/search/test/cpp/TestSearchStaDesign.cc @@ -68,37 +68,6 @@ static void expectCallablePointerUsable(FnPtr fn) { EXPECT_EQ(fn_copy, fn); } -static std::string makeUniqueSdcPath(const char *tag) -{ - static std::atomic counter{0}; - char buf[256]; - snprintf(buf, sizeof(buf), "%s_%d_%d.sdc", - tag, static_cast(getpid()), counter.fetch_add(1)); - return std::string(buf); -} - -static void expectSdcFileReadable(const std::string &filename) -{ - FILE *f = fopen(filename.c_str(), "r"); - ASSERT_NE(f, nullptr); - - std::string content; - char chunk[512]; - size_t read_count = 0; - while ((read_count = fread(chunk, 1, sizeof(chunk), f)) > 0) - content.append(chunk, read_count); - fclose(f); - - EXPECT_FALSE(content.empty()); - EXPECT_GT(content.size(), 10u); - EXPECT_NE(content.find('\n'), std::string::npos); - EXPECT_EQ(content.find('\0'), std::string::npos); - const bool has_set_cmd = content.find("set_") != std::string::npos; - const bool has_create_clock = content.find("create_clock") != std::string::npos; - EXPECT_TRUE(has_set_cmd || has_create_clock); - EXPECT_EQ(remove(filename.c_str()), 0); -} - static void expectStaDesignCoreState(Sta *sta, bool design_loaded) { ASSERT_NE(sta, nullptr); @@ -107,12 +76,14 @@ static void expectStaDesignCoreState(Sta *sta, bool design_loaded) EXPECT_NE(sta->search(), nullptr); EXPECT_NE(sta->cmdSdc(), nullptr); EXPECT_FALSE(sta->scenes().empty()); - if (!sta->scenes().empty()) + if (!sta->scenes().empty()) { EXPECT_GE(sta->scenes().size(), 1); + } EXPECT_NE(sta->cmdScene(), nullptr); EXPECT_TRUE(design_loaded); - if (sta->network()) + if (sta->network()) { EXPECT_NE(sta->network()->topInstance(), nullptr); + } } // ============================================================ @@ -232,6 +203,7 @@ TEST_F(StaDesignTest, VertexArrivalRfPathAP) { ASSERT_NE(v, nullptr); Scene *corner = sta_->cmdScene(); const size_t path_idx = corner->pathIndex(MinMax::max()); + (void)path_idx; sta_->arrival(v, RiseFallBoth::rise(), sta_->scenes(), MinMax::max()); } @@ -254,6 +226,7 @@ TEST_F(StaDesignTest, VertexRequiredRfPathAP) { ASSERT_NE(v, nullptr); Scene *corner = sta_->cmdScene(); const size_t path_idx = corner->pathIndex(MinMax::max()); + (void)path_idx; sta_->required(v, RiseFallBoth::rise(), sta_->scenes(), MinMax::max()); } @@ -270,6 +243,7 @@ TEST_F(StaDesignTest, VertexSlackRfPathAP) { ASSERT_NE(v, nullptr); Scene *corner = sta_->cmdScene(); const size_t path_idx = corner->pathIndex(MinMax::max()); + (void)path_idx; sta_->slack(v, RiseFallBoth::rise(), sta_->scenes(), MinMax::max()); } @@ -288,6 +262,7 @@ TEST_F(StaDesignTest, VertexSlewRfCornerMinMax) { Vertex *v = findVertex("u1/Z"); ASSERT_NE(v, nullptr); Scene *corner = sta_->cmdScene(); + (void)corner; sta_->slew(v, RiseFallBoth::rise(), sta_->scenes(), MinMax::max()); } @@ -296,6 +271,7 @@ TEST_F(StaDesignTest, VertexSlewRfDcalcAP) { ASSERT_NE(v, nullptr); Scene *corner = sta_->cmdScene(); const DcalcAPIndex dcalc_idx = corner->dcalcAnalysisPtIndex(MinMax::max()); + (void)dcalc_idx; sta_->slew(v, RiseFallBoth::rise(), sta_->scenes(), MinMax::max()); } @@ -639,6 +615,7 @@ TEST_F(StaDesignTest, PvtGetSet) { sta_->setPvt(top, MinMaxAll::all(), 1.0f, 1.1f, 25.0f, sta_->cmdSdc()); p = sta_->pvt(top, MinMax::max(), sta_->cmdSdc()); + (void)p; }() )); @@ -803,6 +780,7 @@ TEST_F(StaDesignTest, SearchCopyState) { TEST_F(StaDesignTest, SearchFindPathGroupByName) { ASSERT_NO_THROW(( [&](){ Search *search = sta_->search(); + (void)search; // First ensure path groups exist sta_->findPathEnds( nullptr, nullptr, nullptr, @@ -855,10 +833,11 @@ TEST_F(StaDesignTest, SearchDeletePathGroups) { TEST_F(StaDesignTest, SearchVisitEndpoints) { ASSERT_NO_THROW(( [&](){ Search *search = sta_->search(); + (void)search; Network *network = sta_->cmdNetwork(); PinSet pins(network); VertexPinCollector collector(pins); - true /* Search::visitEndpoints removed */; + (void)true /* Search::visitEndpoints removed */; }() )); } @@ -868,10 +847,11 @@ TEST_F(StaDesignTest, SearchVisitEndpoints) { TEST_F(StaDesignTest, SearchVisitStartpoints) { ASSERT_NO_THROW(( [&](){ Search *search = sta_->search(); + (void)search; Network *network = sta_->cmdNetwork(); PinSet pins(network); VertexPinCollector collector(pins); - true /* Search::visitStartpoints removed */; + (void)true /* Search::visitStartpoints removed */; }() )); } @@ -903,9 +883,10 @@ TEST_F(StaDesignTest, SearchClockDomainsVertex) { TEST_F(StaDesignTest, SearchIsGenClkSrc) { ASSERT_NO_THROW(( [&](){ Search *search = sta_->search(); + (void)search; Vertex *v = findVertex("r1/Q"); if (v) { - true /* Search::isGenClkSrc removed */; + (void)true /* Search::isGenClkSrc removed */; } }() )); @@ -922,7 +903,8 @@ TEST_F(StaDesignTest, SearchPathGroups) { true, false, false, false, false, false); if (!ends.empty()) { Search *search = sta_->search(); - true /* Search::pathGroups removed */; + (void)search; + (void)true /* Search::pathGroups removed */; } }() )); @@ -1118,6 +1100,7 @@ TEST_F(StaDesignTest, SetArcDelayAnnotated) { if (!arcs.empty()) { Scene *corner = sta_->cmdScene(); DcalcAPIndex dcalc_idx = corner->dcalcAnalysisPtIndex(MinMax::max()); + (void)dcalc_idx; sta_->setArcDelayAnnotated(edge, arcs[0], corner, MinMax::max(), true); sta_->setArcDelayAnnotated(edge, arcs[0], corner, MinMax::max(), false); } @@ -1175,6 +1158,7 @@ TEST_F(StaDesignTest, TotalNegativeSlackCorner) { TEST_F(StaDesignTest, Endpoints) { VertexSet &eps = sta_->endpoints(); + (void)eps; // endpoints() returns reference, always valid } @@ -1362,6 +1346,7 @@ TEST_F(StaDesignTest, PathExpanded) { TEST_F(StaDesignTest, SearchEndpoints) { Search *search = sta_->search(); VertexSet &eps = search->endpoints(); + (void)eps; // endpoints() returns reference, always valid } @@ -1636,6 +1621,7 @@ TEST_F(StaDesignTest, ReadLibertyFile) { Scene *corner = sta_->cmdScene(); LibertyLibrary *lib = sta_->readLiberty( "test/nangate45/Nangate45_slow.lib", corner, MinMaxAll::min(), false); + (void)lib; // May or may not succeed depending on file existence; just check no crash }() )); } @@ -2241,7 +2227,7 @@ TEST_F(StaDesignTest, SearchIsClockVertex) { Search *search = sta_->search(); Vertex *v = findVertex("r1/CK"); ASSERT_NE(v, nullptr); - (search->clocks(v, sta_->cmdMode()).size() > 0); + (void)(search->clocks(v, sta_->cmdMode()).size() > 0); } // --- Search: clkPathArrival --- @@ -2370,6 +2356,7 @@ TEST_F(StaDesignTest, ArcDelayAnnotated) { if (arc_set && !arc_set->arcs().empty()) { Scene *corner = sta_->cmdScene(); DcalcAPIndex dcalc_idx = corner->dcalcAnalysisPtIndex(MinMax::max()); + (void)dcalc_idx; sta_->arcDelayAnnotated(edge, arc_set->arcs()[0], corner, MinMax::max()); } } @@ -2406,9 +2393,10 @@ TEST_F(StaDesignTest, SearchRequiredInvalid) { TEST_F(StaDesignTest, SearchIsSegmentStart) { Search *search = sta_->search(); + (void)search; Pin *pin = findPin("in1"); ASSERT_NE(pin, nullptr); - true /* Search::isSegmentStart removed */; + (void)true /* Search::isSegmentStart removed */; } // --- Search: isInputArrivalSrchStart --- @@ -2661,6 +2649,7 @@ TEST_F(StaDesignTest, RemoveConstraints) { TEST_F(StaDesignTest, SearchFilter) { Search *search = sta_->search(); + (void)search; FilterPath *filter = nullptr /* Search::filter() removed */; // filter should be null since we haven't set one EXPECT_EQ(filter, nullptr); @@ -2787,7 +2776,11 @@ TEST_F(StaDesignTest, MaxFanoutCheck) { ASSERT_NO_THROW(( [&](){ sta_->checkFanoutPreamble(); const Pin *pin = nullptr; + (void)pin; float fanout, slack, limit; + (void)fanout; + (void)slack; + (void)limit; // maxFanoutCheck removed (renamed to maxFanoutMinSlackPin); }() )); @@ -4038,7 +4031,7 @@ TEST_F(StaDesignTest, SearchIsClock) { Search *search = sta_->search(); Vertex *v = findVertex("r1/CK"); if (v) { - (search->clocks(v, sta_->cmdMode()).size() > 0); + (void)(search->clocks(v, sta_->cmdMode()).size() > 0); } }() )); @@ -4046,9 +4039,10 @@ TEST_F(StaDesignTest, SearchIsClock) { TEST_F(StaDesignTest, SearchIsGenClkSrc2) { Search *search = sta_->search(); + (void)search; Vertex *v = findVertex("r1/Q"); ASSERT_NE(v, nullptr); - true /* Search::isGenClkSrc removed */; + (void)true /* Search::isGenClkSrc removed */; } TEST_F(StaDesignTest, SearchClocks) { @@ -4107,12 +4101,14 @@ TEST_F(StaDesignTest, SearchIsEndpoint2) { TEST_F(StaDesignTest, SearchHavePathGroups) { ASSERT_NO_THROW(( [&](){ Search *search = sta_->search(); - true /* Search::havePathGroups removed */; + (void)search; + (void)true /* Search::havePathGroups removed */; }() )); } TEST_F(StaDesignTest, SearchFindPathGroup) { Search *search = sta_->search(); + (void)search; Clock *clk = sta_->cmdSdc()->findClock("clk"); ASSERT_NE(clk, nullptr); // Search::findPathGroup removed diff --git a/search/test/cpp/TestSearchStaDesignB.cc b/search/test/cpp/TestSearchStaDesignB.cc index 79fb8582..f8cbdc61 100644 --- a/search/test/cpp/TestSearchStaDesignB.cc +++ b/search/test/cpp/TestSearchStaDesignB.cc @@ -109,12 +109,14 @@ static void expectStaDesignCoreState(Sta *sta, bool design_loaded) EXPECT_NE(sta->search(), nullptr); EXPECT_NE(sta->cmdSdc(), nullptr); EXPECT_FALSE(sta->scenes().empty()); - if (!sta->scenes().empty()) + if (!sta->scenes().empty()) { EXPECT_GE(sta->scenes().size(), 1); + } EXPECT_NE(sta->cmdScene(), nullptr); EXPECT_TRUE(design_loaded); - if (sta->network()) + if (sta->network()) { EXPECT_NE(sta->network()->topInstance(), nullptr); + } } // ============================================================ @@ -275,6 +277,7 @@ TEST_F(StaDesignTest, SearchDeratedDelay) { ASSERT_NE(v, nullptr); Scene *corner = sta_->cmdScene(); const size_t path_idx = corner->pathIndex(MinMax::max()); + (void)path_idx; VertexInEdgeIterator edge_iter(v, sta_->graph()); if (edge_iter.hasNext()) { Edge *edge = edge_iter.next(); @@ -523,6 +526,7 @@ TEST_F(StaDesignTest, StaVertexSlewRfCorner) { Vertex *v = findVertex("u1/Z"); ASSERT_NE(v, nullptr); Scene *corner = sta_->cmdScene(); + (void)corner; Slew slew = sta_->slew(v, RiseFallBoth::rise(), sta_->scenes(), MinMax::max()); EXPECT_FALSE(std::isinf(slew)); } @@ -539,6 +543,7 @@ TEST_F(StaDesignTest, StaVertexRequiredRfPathAP) { ASSERT_NE(v, nullptr); Scene *corner = sta_->cmdScene(); const size_t path_idx = corner->pathIndex(MinMax::max()); + (void)path_idx; Required req = sta_->required(v, RiseFallBoth::rise(), sta_->scenes(), MinMax::max()); EXPECT_FALSE(std::isinf(req)); } @@ -1049,6 +1054,7 @@ TEST_F(StaDesignTest, MakeParasiticNetwork) { Net *net = network->net(pin); if (net) { Scene *corner = sta_->cmdScene(); + (void)corner; // ParasiticAnalysisPt and findParasiticAnalysisPt removed from API // makeParasiticNetwork API changed } @@ -1183,6 +1189,7 @@ TEST_F(StaDesignTest, SearchVisitStartpoints2) { TEST_F(StaDesignTest, PathGroupFindByName) { ASSERT_NO_THROW(( [&](){ Search *search = sta_->search(); + (void)search; // After findPathEnds, path groups should exist PathEndSeq ends = sta_->findPathEnds( nullptr, nullptr, nullptr, @@ -1364,6 +1371,7 @@ TEST_F(StaDesignTest, IsInputArrivalSrchStart) { TEST_F(StaDesignTest, IsSegmentStart) { ASSERT_NO_THROW(( [&](){ Search *search = sta_->search(); + (void)search; Pin *pin = findPin("in1"); if (pin) { // Search::isSegmentStart removed from API @@ -1384,6 +1392,7 @@ TEST_F(StaDesignTest, ClockInsertion) { if (pin) { Scene *corner = sta_->cmdScene(); const size_t path_idx = corner->pathIndex(MinMax::max()); + (void)path_idx; Arrival ins = search->clockInsertion(clk, pin, RiseFall::rise(), MinMax::max(), EarlyLate::late(), sta_->cmdMode()); EXPECT_FALSE(std::isinf(ins)); @@ -1817,6 +1826,7 @@ TEST_F(StaDesignTest, PathEndUnconstrainedMethods) { ASSERT_NO_THROW(( [&](){ const SceneSeq &corners = sta_->scenes(); Scene *corner = corners[0]; + (void)corner; PathEndSeq ends = sta_->findPathEnds( nullptr, nullptr, nullptr, true, corners, MinMaxAll::max(), 5, 5, true, false, -INF, INF, false, group_names, @@ -2019,6 +2029,7 @@ TEST_F(StaDesignTest, ClkSkewPreamble) { clks.push_back(clk); const SceneSeq &corners = sta_->scenes(); Scene *corner = corners[0]; + (void)corner; sta_->reportClkSkew(clks, sta_->scenes(), MinMax::max(), false, 3); } @@ -2073,6 +2084,7 @@ TEST_F(StaDesignTest, ClkSkewInternalLatency) { clks.push_back(clk); const SceneSeq &corners = sta_->scenes(); Scene *corner = corners[0]; + (void)corner; sta_->reportClkSkew(clks, sta_->scenes(), MinMax::max(), true, 3); } @@ -3216,6 +3228,7 @@ TEST_F(StaDesignTest, ReportClkSkew2) { ConstClockSeq clks; clks.push_back(clk); Scene *corner = sta_->cmdScene(); + (void)corner; sta_->reportClkSkew(clks, sta_->scenes(), MinMax::max(), false, 3); sta_->reportClkSkew(clks, sta_->scenes(), MinMax::min(), false, 3); } @@ -3242,6 +3255,7 @@ TEST_F(StaDesignTest, ReportClkLatency3) { ConstClockSeq clks; clks.push_back(clk); Scene *corner = sta_->cmdScene(); + (void)corner; sta_->reportClkLatency(clks, sta_->scenes(), false, 3); } @@ -3650,6 +3664,7 @@ TEST_F(StaDesignTest, ReportClkSkew3) { ConstClockSeq clks; clks.push_back(clk); Scene *corner = sta_->cmdScene(); + (void)corner; sta_->reportClkSkew(clks, sta_->scenes(), MinMax::max(), false, 4); sta_->reportClkSkew(clks, sta_->scenes(), MinMax::min(), false, 4); } @@ -3678,6 +3693,7 @@ TEST_F(StaDesignTest, ReportClkLatency4) { ConstClockSeq clks; clks.push_back(clk); Scene *corner = sta_->cmdScene(); + (void)corner; sta_->reportClkLatency(clks, sta_->scenes(), false, 4); sta_->reportClkLatency(clks, sta_->scenes(), true, 4); } @@ -3944,6 +3960,7 @@ TEST_F(StaDesignTest, WriteSdcComprehensive) { Network *network = sta_->cmdNetwork(); Instance *top = network->topInstance(); Scene *corner = sta_->cmdScene(); + (void)corner; Clock *clk = sta_->cmdSdc()->findClock("clk"); Pin *in1 = network->findPin(top, "in1"); diff --git a/search/test/cpp/TestSearchStaInit.cc b/search/test/cpp/TestSearchStaInit.cc index 37d5f102..0640524e 100644 --- a/search/test/cpp/TestSearchStaInit.cc +++ b/search/test/cpp/TestSearchStaInit.cc @@ -74,8 +74,9 @@ static void expectStaCoreState(Sta *sta) EXPECT_NE(sta->cmdSdc(), nullptr); EXPECT_NE(sta->report(), nullptr); EXPECT_FALSE(sta->scenes().empty()); - if (!sta->scenes().empty()) + if (!sta->scenes().empty()) { EXPECT_GE(sta->scenes().size(), 1); + } EXPECT_NE(sta->cmdScene(), nullptr); } @@ -2176,6 +2177,7 @@ TEST_F(StaInitTest, TagLessConstructor) { TEST_F(StaInitTest, TagIndexLessComparator) { TagIndexLess less; + (void)less; // Just exercise constructor } @@ -2341,6 +2343,7 @@ TEST_F(StaInitTest, StaSetSlewLimitClock) { TEST_F(StaInitTest, StaOperatingConditions) { const OperatingConditions *op = sta_->operatingConditions(MinMax::min(), sta_->cmdSdc()); + (void)op; // May be null without a liberty lib sta_->operatingConditions(MinMax::max(), sta_->cmdSdc()); } @@ -2652,6 +2655,7 @@ TEST_F(StaInitTest, CornersRangeForIteration) { TEST_F(StaInitTest, PathGroupsFindByNameNoGroups) { Mode *mode = sta_->cmdMode(); PathGroups *pgs = mode->pathGroups(); + (void)pgs; // PathGroups may not be initialized yet; just verify mode access works // PathGroup lookup requires path groups to be built first EXPECT_NE(mode, nullptr); @@ -3726,7 +3730,9 @@ TEST_F(StaInitTest, CornersFindByIndex) { TEST_F(StaInitTest, CornersFindByName) { const SceneSeq &corners = sta_->scenes(); + (void)corners; Scene *c = sta_->findScene("default"); + (void)c; // May or may not find it } @@ -3771,6 +3777,7 @@ TEST_F(StaInitTest, StaMakeGroupPath) { // --- Sta.cc: isPathGroupName --- TEST_F(StaInitTest, StaIsPathGroupNameTestGroup) { bool val = sta_->isPathGroupName("test_group", sta_->cmdSdc()); + (void)val; // May or may not find it depending on prior makeGroupPath } diff --git a/search/test/cpp/TestSearchStaInitB.cc b/search/test/cpp/TestSearchStaInitB.cc index e95d382a..5294d599 100644 --- a/search/test/cpp/TestSearchStaInitB.cc +++ b/search/test/cpp/TestSearchStaInitB.cc @@ -1138,6 +1138,7 @@ TEST_F(StaInitTest, ClkInfoEqualCtor) { TEST_F(StaInitTest, ClkInfoHashExists) { ASSERT_NO_THROW(( [&](){ ClkInfoHash hash; + (void)hash; }() )); } @@ -1146,6 +1147,7 @@ TEST_F(StaInitTest, ClkInfoHashExists) { TEST_F(StaInitTest, TagLessCtor) { ASSERT_NO_THROW(( [&](){ TagLess less(sta_); + (void)less; }() )); } @@ -1154,6 +1156,7 @@ TEST_F(StaInitTest, TagLessCtor) { TEST_F(StaInitTest, TagIndexLessExists) { ASSERT_NO_THROW(( [&](){ TagIndexLess less; + (void)less; }() )); } @@ -1240,6 +1243,7 @@ TEST_F(StaInitTest, ClockPinPairLessExists) { ASSERT_NO_THROW(( [&](){ // ClockPinPairLess comparison dereferences Clock*, so just test existence ClockPinPairLess less; + (void)less; expectStaCoreState(sta_); }() )); } @@ -1895,6 +1899,7 @@ TEST_F(StaInitTest, ReportPathFieldSrcAttr) { ASSERT_NO_THROW(( [&](){ ReportPath *rpt = sta_->reportPath(); ReportField *src = rpt->fieldSrcAttr(); + (void)src; // src_attr field may or may not exist expectStaCoreState(sta_); }() )); @@ -2108,6 +2113,7 @@ TEST_F(StaInitTest, CornersIteration) { TEST_F(StaInitTest, CornerFindName) { ASSERT_NO_THROW(( [&](){ const SceneSeq &corners = sta_->scenes(); + (void)corners; Scene *corner = sta_->findScene("default"); EXPECT_NE(corner, nullptr); expectStaCoreState(sta_); @@ -2518,7 +2524,8 @@ TEST_F(StaInitTest, ReportPathReportMpwHeaderShort) { TEST_F(StaInitTest, ReportPathReportPathEndHeader) { ASSERT_NO_THROW(( [&](){ ReportPath *rpt = sta_->reportPath(); - + (void)rpt; + expectStaCoreState(sta_); }() )); } @@ -2528,7 +2535,8 @@ TEST_F(StaInitTest, ReportPathReportPathEndHeader) { TEST_F(StaInitTest, ReportPathReportPathEndFooter) { ASSERT_NO_THROW(( [&](){ ReportPath *rpt = sta_->reportPath(); - + (void)rpt; + expectStaCoreState(sta_); }() )); }