mirror of
https://github.com/The-OpenROAD-Project/OpenSTA.git
synced 2026-09-07 11:51:47 +02:00
Adapt test files to upstream API changes (string_view migration)
Update 16 test files to match upstream OpenSTA API refactoring:
- const char* → std::string/std::string_view across all test APIs
- EXPECT_STREQ → EXPECT_EQ for std::string/string_view returns
- nullptr → "" for string_view parameters (makeClock, makeClockGroups, etc.)
- PropertyValue("literal") → PropertyValue(std::string("literal")) to avoid
bool constructor overload resolution
- Method renames: relatedGroundPin→relatedGroundPort,
relatedPowerPin→relatedPowerPort, firstName→firstParam,
secondName→secondParam
- Constructor changes: OperatingConditions (5-arg → 1-arg + setters),
ModeDef::defineValue (3-arg → 1-arg + setSdfCond)
- LibertyAttrValue::floatValue returns std::pair<float,bool> now
- Filter API: separate args → single expression string + bool_props_as_int
- SDF version golden files: 3.0.1 → 3.1.0
All 6104 tests pass.
Co-Authored-By: Claude <[email protected]>
Signed-off-by: Jaehyun Kim <[email protected]>
This commit is contained in:
@@ -594,15 +594,15 @@ TEST_F(StaLibertyTest, PortBoolFlags) {
|
||||
EXPECT_FALSE(a->isPad());
|
||||
}
|
||||
|
||||
TEST_F(StaLibertyTest, PortRelatedPins) {
|
||||
TEST_F(StaLibertyTest, PortRelatedPorts) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
LibertyPort *a = buf->findLibertyPort("A");
|
||||
ASSERT_NE(a, nullptr);
|
||||
const char *ground_pin = a->relatedGroundPin();
|
||||
const char *power_pin = a->relatedPowerPin();
|
||||
// ground_pin may be null for simple arcs
|
||||
// power_pin may be null for simple arcs
|
||||
LibertyPort *ground_port = a->relatedGroundPort();
|
||||
LibertyPort *power_port = a->relatedPowerPort();
|
||||
// ground_port may be null for simple cells
|
||||
// power_port may be null for simple cells
|
||||
}
|
||||
|
||||
TEST_F(StaLibertyTest, PortLibertyLibrary) {
|
||||
@@ -900,8 +900,9 @@ TEST_F(StaLibertyTest, PortVoltageName) {
|
||||
ASSERT_NE(buf, nullptr);
|
||||
LibertyPort *a = buf->findLibertyPort("A");
|
||||
ASSERT_NE(a, nullptr);
|
||||
const char *vname = a->voltageName();
|
||||
// vname may be null for simple arcs
|
||||
const std::string &vname = a->voltageName();
|
||||
// vname may be empty for simple cells
|
||||
(void)vname;
|
||||
}
|
||||
|
||||
TEST_F(StaLibertyTest, PortEquivAndLess) {
|
||||
@@ -1136,7 +1137,7 @@ TEST(TableReportTest, Table0ReportValue) {
|
||||
Table t(42.0f);
|
||||
Unit unit(1e-9f, "s", 3);
|
||||
std::string rv = t.reportValue("delay", nullptr, nullptr,
|
||||
0.0f, nullptr, 0.0f, 0.0f,
|
||||
0.0f, "", 0.0f, 0.0f,
|
||||
&unit, 3);
|
||||
EXPECT_FALSE(rv.empty());
|
||||
}
|
||||
@@ -1307,7 +1308,7 @@ TEST(DriverWaveformTest, CreateAndName) {
|
||||
auto ax2 = makeTestAxis(TableAxisVariable::normalized_voltage, {0.0f, 1.0f});
|
||||
TablePtr tbl = std::make_shared<Table>(std::move(vals), ax1, ax2);
|
||||
DriverWaveform *dw = new DriverWaveform("test_driver_waveform", tbl);
|
||||
EXPECT_STREQ(dw->name(), "test_driver_waveform");
|
||||
EXPECT_EQ(dw->name(), "test_driver_waveform");
|
||||
Table wf = dw->waveform(0.15f);
|
||||
// Waveform accessor exercised; axis may be null for simple waveforms
|
||||
EXPECT_EQ(wf.order(), 1);
|
||||
@@ -1470,9 +1471,11 @@ TEST_F(StaLibertyTest, ModeValueDefSetSdfCond) {
|
||||
ASSERT_NE(buf, nullptr);
|
||||
ModeDef *mode_def = buf->makeModeDef("test_mode");
|
||||
ASSERT_NE(mode_def, nullptr);
|
||||
ModeValueDef *val_def = mode_def->defineValue("val1", nullptr, "orig_sdf_cond");
|
||||
ModeValueDef *val_def = mode_def->defineValue("val1");
|
||||
ASSERT_NE(val_def, nullptr);
|
||||
EXPECT_EQ(val_def->value(), "val1");
|
||||
// Set sdf_cond after creation
|
||||
val_def->setSdfCond("orig_sdf_cond");
|
||||
EXPECT_EQ(val_def->sdfCond(), "orig_sdf_cond");
|
||||
val_def->setSdfCond("new_sdf_cond");
|
||||
EXPECT_EQ(val_def->sdfCond(), "new_sdf_cond");
|
||||
@@ -1483,7 +1486,7 @@ TEST_F(StaLibertyTest, ModeValueDefSetCond) {
|
||||
ASSERT_NE(buf, nullptr);
|
||||
ModeDef *mode_def = buf->makeModeDef("test_mode2");
|
||||
ASSERT_NE(mode_def, nullptr);
|
||||
ModeValueDef *val_def = mode_def->defineValue("val2", nullptr, nullptr);
|
||||
ModeValueDef *val_def = mode_def->defineValue("val2");
|
||||
ASSERT_NE(val_def, nullptr);
|
||||
EXPECT_EQ(val_def->cond(), nullptr);
|
||||
val_def->setCond(nullptr);
|
||||
@@ -1621,7 +1624,7 @@ TEST_F(StaLibertyTest, CheckTableModelCheckDelay) {
|
||||
ArcDelay d = ctm->checkDelay(nullptr, 0.1f, 0.1f, 0.0f,
|
||||
MinMax::max(), PocvMode::scalar);
|
||||
EXPECT_GE(delayAsFloat(d), 0.0f);
|
||||
std::string rpt = ctm->reportCheckDelay(nullptr, 0.1f, nullptr,
|
||||
std::string rpt = ctm->reportCheckDelay(nullptr, 0.1f, "",
|
||||
0.1f, 0.0f,
|
||||
MinMax::max(), PocvMode::scalar, 3);
|
||||
EXPECT_FALSE(rpt.empty());
|
||||
@@ -1644,7 +1647,7 @@ TEST_F(StaLibertyTest, LibraryMakeAndFindDriverWaveform) {
|
||||
ASSERT_NE(dw, nullptr);
|
||||
DriverWaveform *found = lib_->findDriverWaveform("my_driver_wf");
|
||||
EXPECT_EQ(found, dw);
|
||||
EXPECT_STREQ(found->name(), "my_driver_wf");
|
||||
EXPECT_EQ(found->name(), "my_driver_wf");
|
||||
EXPECT_EQ(lib_->findDriverWaveform("no_such_wf"), nullptr);
|
||||
}
|
||||
|
||||
@@ -1771,7 +1774,7 @@ TEST_F(StaLibertyTest, CheckTableModelDirect) {
|
||||
MinMax::max(), PocvMode::scalar);
|
||||
EXPECT_GE(delayAsFloat(d), 0.0f);
|
||||
|
||||
std::string rpt = ctm->reportCheckDelay(nullptr, 0.1f, nullptr,
|
||||
std::string rpt = ctm->reportCheckDelay(nullptr, 0.1f, "",
|
||||
0.1f, 0.0f,
|
||||
MinMax::max(), PocvMode::scalar, 3);
|
||||
EXPECT_FALSE(rpt.empty());
|
||||
@@ -1866,19 +1869,21 @@ TEST_F(StaLibertyTest, CellInverterCheck) {
|
||||
TEST_F(StaLibertyTest, CellFootprint) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
const char *fp = buf->footprint();
|
||||
// fp may be null for simple arcs
|
||||
const std::string &fp = buf->footprint();
|
||||
// fp may be empty for simple cells
|
||||
(void)fp;
|
||||
buf->setFootprint("test_fp");
|
||||
EXPECT_STREQ(buf->footprint(), "test_fp");
|
||||
EXPECT_EQ(buf->footprint(), "test_fp");
|
||||
}
|
||||
|
||||
TEST_F(StaLibertyTest, CellUserFunctionClass) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
const char *ufc = buf->userFunctionClass();
|
||||
// ufc may be null for simple arcs
|
||||
const std::string &ufc = buf->userFunctionClass();
|
||||
// ufc may be empty for simple cells
|
||||
(void)ufc;
|
||||
buf->setUserFunctionClass("my_class");
|
||||
EXPECT_STREQ(buf->userFunctionClass(), "my_class");
|
||||
EXPECT_EQ(buf->userFunctionClass(), "my_class");
|
||||
}
|
||||
|
||||
TEST_F(StaLibertyTest, CellSetArea) {
|
||||
@@ -1981,7 +1986,7 @@ TEST(BusDclTest, Create) {
|
||||
|
||||
TEST(OperatingConditionsTest, Create) {
|
||||
OperatingConditions oc("typical");
|
||||
EXPECT_STREQ(oc.name(), "typical");
|
||||
EXPECT_EQ(oc.name(), "typical");
|
||||
oc.setProcess(1.0f);
|
||||
oc.setTemperature(25.0f);
|
||||
oc.setVoltage(1.1f);
|
||||
@@ -2132,22 +2137,28 @@ TEST(TimingArcSetWireTest, WireTimingArcSet) {
|
||||
// LibertyPort additional setters
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST_F(StaLibertyTest, PortSetRelatedGroundPin) {
|
||||
TEST_F(StaLibertyTest, PortSetRelatedGroundPort) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
LibertyPort *port = buf->findLibertyPort("A");
|
||||
ASSERT_NE(port, nullptr);
|
||||
port->setRelatedGroundPin("VSS");
|
||||
EXPECT_STREQ(port->relatedGroundPin(), "VSS");
|
||||
LibertyPort *port_a = buf->findLibertyPort("A");
|
||||
LibertyPort *port_z = buf->findLibertyPort("Z");
|
||||
ASSERT_NE(port_a, nullptr);
|
||||
ASSERT_NE(port_z, nullptr);
|
||||
// Set and verify related ground port pointer
|
||||
port_a->setRelatedGroundPort(port_z);
|
||||
EXPECT_EQ(port_a->relatedGroundPort(), port_z);
|
||||
}
|
||||
|
||||
TEST_F(StaLibertyTest, PortSetRelatedPowerPin) {
|
||||
TEST_F(StaLibertyTest, PortSetRelatedPowerPort) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
LibertyPort *port = buf->findLibertyPort("A");
|
||||
ASSERT_NE(port, nullptr);
|
||||
port->setRelatedPowerPin("VDD");
|
||||
EXPECT_STREQ(port->relatedPowerPin(), "VDD");
|
||||
LibertyPort *port_a = buf->findLibertyPort("A");
|
||||
LibertyPort *port_z = buf->findLibertyPort("Z");
|
||||
ASSERT_NE(port_a, nullptr);
|
||||
ASSERT_NE(port_z, nullptr);
|
||||
// Set and verify related power port pointer
|
||||
port_a->setRelatedPowerPort(port_z);
|
||||
EXPECT_EQ(port_a->relatedPowerPort(), port_z);
|
||||
}
|
||||
|
||||
// isDisabledConstraint has been moved from LibertyPort to Sdc.
|
||||
@@ -2249,7 +2260,7 @@ TEST_F(StaLibertyTest, CellSetCornerCell) {
|
||||
TEST_F(StaLibertyTest, LibraryOperatingConditions) {
|
||||
OperatingConditions *nom = lib_->findOperatingConditions("typical");
|
||||
if (nom) {
|
||||
EXPECT_STREQ(nom->name(), "typical");
|
||||
EXPECT_EQ(nom->name(), "typical");
|
||||
}
|
||||
OperatingConditions *def = lib_->defaultOperatingConditions();
|
||||
EXPECT_NE(def, nullptr);
|
||||
@@ -2760,11 +2771,11 @@ TEST_F(UnitTest, AsStringDoubleZero) {
|
||||
|
||||
// to_string(TimingSense) exercise - ensure all senses
|
||||
TEST(TimingArcTest, TimingSenseToStringAll) {
|
||||
EXPECT_NE(to_string(TimingSense::positive_unate), nullptr);
|
||||
EXPECT_NE(to_string(TimingSense::negative_unate), nullptr);
|
||||
EXPECT_NE(to_string(TimingSense::non_unate), nullptr);
|
||||
EXPECT_NE(to_string(TimingSense::none), nullptr);
|
||||
EXPECT_NE(to_string(TimingSense::unknown), nullptr);
|
||||
EXPECT_FALSE(to_string(TimingSense::positive_unate).empty());
|
||||
EXPECT_FALSE(to_string(TimingSense::negative_unate).empty());
|
||||
EXPECT_FALSE(to_string(TimingSense::non_unate).empty());
|
||||
EXPECT_FALSE(to_string(TimingSense::none).empty());
|
||||
EXPECT_FALSE(to_string(TimingSense::unknown).empty());
|
||||
}
|
||||
|
||||
// timingSenseOpposite - covers uncovered
|
||||
@@ -2882,7 +2893,7 @@ TEST(TimingArcTest, TimingArcAttrsSetters) {
|
||||
// ScaleFactors - covers ScaleFactors constructor and methods
|
||||
TEST(LibertyTest, ScaleFactors) {
|
||||
ScaleFactors sf("test_sf");
|
||||
EXPECT_STREQ(sf.name(), "test_sf");
|
||||
EXPECT_EQ(sf.name(), "test_sf");
|
||||
sf.setScale(ScaleFactorType::cell, ScaleFactorPvt::process,
|
||||
RiseFall::rise(), 1.5f);
|
||||
float v = sf.scale(ScaleFactorType::cell, ScaleFactorPvt::process,
|
||||
@@ -2907,9 +2918,9 @@ TEST(LibertyTest, FindScaleFactorPvt) {
|
||||
|
||||
// scaleFactorPvtName
|
||||
TEST(LibertyTest, ScaleFactorPvtName) {
|
||||
EXPECT_STREQ(scaleFactorPvtName(ScaleFactorPvt::process), "process");
|
||||
EXPECT_STREQ(scaleFactorPvtName(ScaleFactorPvt::volt), "volt");
|
||||
EXPECT_STREQ(scaleFactorPvtName(ScaleFactorPvt::temp), "temp");
|
||||
EXPECT_EQ(scaleFactorPvtName(ScaleFactorPvt::process), "process");
|
||||
EXPECT_EQ(scaleFactorPvtName(ScaleFactorPvt::volt), "volt");
|
||||
EXPECT_EQ(scaleFactorPvtName(ScaleFactorPvt::temp), "temp");
|
||||
}
|
||||
|
||||
// findScaleFactorType / scaleFactorTypeName
|
||||
@@ -2921,11 +2932,11 @@ TEST(LibertyTest, FindScaleFactorType) {
|
||||
}
|
||||
|
||||
TEST(LibertyTest, ScaleFactorTypeName) {
|
||||
EXPECT_STREQ(scaleFactorTypeName(ScaleFactorType::cell), "cell");
|
||||
EXPECT_STREQ(scaleFactorTypeName(ScaleFactorType::hold), "hold");
|
||||
EXPECT_STREQ(scaleFactorTypeName(ScaleFactorType::setup), "setup");
|
||||
EXPECT_STREQ(scaleFactorTypeName(ScaleFactorType::recovery), "recovery");
|
||||
EXPECT_STREQ(scaleFactorTypeName(ScaleFactorType::removal), "removal");
|
||||
EXPECT_EQ(scaleFactorTypeName(ScaleFactorType::cell), "cell");
|
||||
EXPECT_EQ(scaleFactorTypeName(ScaleFactorType::hold), "hold");
|
||||
EXPECT_EQ(scaleFactorTypeName(ScaleFactorType::setup), "setup");
|
||||
EXPECT_EQ(scaleFactorTypeName(ScaleFactorType::recovery), "recovery");
|
||||
EXPECT_EQ(scaleFactorTypeName(ScaleFactorType::removal), "removal");
|
||||
}
|
||||
|
||||
// scaleFactorTypeRiseFallSuffix, scaleFactorTypeRiseFallPrefix, scaleFactorTypeLowHighSuffix
|
||||
@@ -2963,12 +2974,16 @@ TEST(LibertyTest, Pvt) {
|
||||
// OperatingConditions
|
||||
TEST(LibertyTest, OperatingConditionsNameOnly) {
|
||||
OperatingConditions oc("typical");
|
||||
EXPECT_STREQ(oc.name(), "typical");
|
||||
EXPECT_EQ(oc.name(), "typical");
|
||||
}
|
||||
|
||||
TEST(LibertyTest, OperatingConditionsFull) {
|
||||
OperatingConditions oc("fast", 1.0f, 1.21f, 0.0f, WireloadTree::balanced);
|
||||
EXPECT_STREQ(oc.name(), "fast");
|
||||
OperatingConditions oc("fast");
|
||||
oc.setProcess(1.0f);
|
||||
oc.setVoltage(1.21f);
|
||||
oc.setTemperature(0.0f);
|
||||
oc.setWireloadTree(WireloadTree::balanced);
|
||||
EXPECT_EQ(oc.name(), "fast");
|
||||
EXPECT_FLOAT_EQ(oc.process(), 1.0f);
|
||||
EXPECT_FLOAT_EQ(oc.voltage(), 1.21f);
|
||||
EXPECT_FLOAT_EQ(oc.temperature(), 0.0f);
|
||||
@@ -3039,15 +3054,15 @@ TEST_F(Table1Test, TableAxisVariableString) {
|
||||
FloatSeq vals({0.0f});
|
||||
auto axis = std::make_shared<TableAxis>(
|
||||
TableAxisVariable::total_output_net_capacitance, std::move(vals));
|
||||
EXPECT_NE(axis->variableString(), nullptr);
|
||||
EXPECT_FALSE(axis->variableString().empty());
|
||||
}
|
||||
|
||||
// tableVariableString / stringTableAxisVariable
|
||||
TEST_F(Table1Test, TableVariableString) {
|
||||
EXPECT_NE(tableVariableString(TableAxisVariable::total_output_net_capacitance), nullptr);
|
||||
EXPECT_NE(tableVariableString(TableAxisVariable::input_net_transition), nullptr);
|
||||
EXPECT_NE(tableVariableString(TableAxisVariable::related_pin_transition), nullptr);
|
||||
EXPECT_NE(tableVariableString(TableAxisVariable::constrained_pin_transition), nullptr);
|
||||
EXPECT_FALSE(tableVariableString(TableAxisVariable::total_output_net_capacitance).empty());
|
||||
EXPECT_FALSE(tableVariableString(TableAxisVariable::input_net_transition).empty());
|
||||
EXPECT_FALSE(tableVariableString(TableAxisVariable::related_pin_transition).empty());
|
||||
EXPECT_FALSE(tableVariableString(TableAxisVariable::constrained_pin_transition).empty());
|
||||
}
|
||||
|
||||
TEST_F(Table1Test, StringTableAxisVariable) {
|
||||
|
||||
@@ -840,8 +840,8 @@ TEST_F(StaLibertyTest, PortRelatedPins2) {
|
||||
LibertyPort *z = buf->findLibertyPort("Z");
|
||||
ASSERT_NE(z, nullptr);
|
||||
// May or may not have related ground/power pins
|
||||
z->relatedGroundPin();
|
||||
z->relatedPowerPin();
|
||||
z->relatedGroundPort();
|
||||
z->relatedPowerPort();
|
||||
}
|
||||
|
||||
// LibertyPort receiverModel
|
||||
@@ -859,8 +859,8 @@ TEST_F(StaLibertyTest, PortReceiverModel2) {
|
||||
TEST_F(StaLibertyTest, CellFootprint2) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
const char *fp = buf->footprint();
|
||||
// fp may be null for simple arcs
|
||||
const std::string &fp = buf->footprint();
|
||||
// fp may be empty for simple arcs
|
||||
}
|
||||
|
||||
// LibertyCell ocv methods
|
||||
@@ -1029,12 +1029,11 @@ TEST(R6_LibertyAttrValueTest, FloatValueAndQuotedStringParsing) {
|
||||
LibertyAttrValue float_value(1.25f);
|
||||
EXPECT_TRUE(float_value.isFloat());
|
||||
EXPECT_FALSE(float_value.isString());
|
||||
EXPECT_FLOAT_EQ(float_value.floatValue(), 1.25f);
|
||||
auto [fval, fexists] = float_value.floatValue();
|
||||
EXPECT_FLOAT_EQ(fval, 1.25f);
|
||||
|
||||
LibertyAttrValue quoted_value(std::string("3.14"));
|
||||
float parsed = 0.0f;
|
||||
bool valid = false;
|
||||
quoted_value.floatValue(parsed, valid);
|
||||
auto [parsed, valid] = quoted_value.floatValue();
|
||||
EXPECT_TRUE(valid);
|
||||
EXPECT_FLOAT_EQ(parsed, 3.14f);
|
||||
EXPECT_TRUE(quoted_value.isString());
|
||||
@@ -1047,10 +1046,10 @@ TEST(R6_LibertyGroupTest, Construction) {
|
||||
LibertyGroup grp("scaled_cell", std::move(params), 10);
|
||||
EXPECT_EQ(grp.type(), "scaled_cell");
|
||||
EXPECT_EQ(grp.line(), 10);
|
||||
ASSERT_NE(grp.firstName(), nullptr);
|
||||
EXPECT_STREQ(grp.firstName(), "cell1");
|
||||
ASSERT_NE(grp.secondName(), nullptr);
|
||||
EXPECT_STREQ(grp.secondName(), "slow");
|
||||
EXPECT_FALSE(grp.firstParam().empty());
|
||||
EXPECT_EQ(grp.firstParam(), "cell1");
|
||||
EXPECT_FALSE(grp.secondParam().empty());
|
||||
EXPECT_EQ(grp.secondParam(), "slow");
|
||||
}
|
||||
|
||||
TEST(R6_LibertyGroupTest, AddSubgroupAndIterate) {
|
||||
@@ -1070,7 +1069,8 @@ TEST(R6_LibertyGroupTest, AddAttributeAndIterate) {
|
||||
ASSERT_NE(attr, nullptr);
|
||||
EXPECT_EQ(attr->line(), 5);
|
||||
EXPECT_TRUE(attr->value().isFloat());
|
||||
EXPECT_FLOAT_EQ(attr->value().floatValue(), 3.14f);
|
||||
auto [area_val, area_exists] = attr->value().floatValue();
|
||||
EXPECT_FLOAT_EQ(area_val, 3.14f);
|
||||
|
||||
float area = 0.0f;
|
||||
bool exists = false;
|
||||
@@ -1083,8 +1083,8 @@ TEST(R6_LibertySimpleAttrTest, Construction) {
|
||||
LibertySimpleAttr attr("name", LibertyAttrValue(std::string("test_value")), 7);
|
||||
EXPECT_EQ(attr.name(), "name");
|
||||
EXPECT_EQ(attr.line(), 7);
|
||||
ASSERT_NE(attr.stringValue(), nullptr);
|
||||
EXPECT_EQ(*attr.stringValue(), "test_value");
|
||||
EXPECT_FALSE(attr.stringValue().empty());
|
||||
EXPECT_EQ(attr.stringValue(), "test_value");
|
||||
EXPECT_TRUE(attr.value().isString());
|
||||
}
|
||||
|
||||
@@ -1108,7 +1108,8 @@ TEST(R6_LibertyComplexAttrTest, Construction) {
|
||||
const LibertyAttrValue *first = attr.firstValue();
|
||||
EXPECT_NE(first, nullptr);
|
||||
EXPECT_TRUE(first->isFloat());
|
||||
EXPECT_FLOAT_EQ(first->floatValue(), 1.0f);
|
||||
auto [first_fval, first_fexists] = first->floatValue();
|
||||
EXPECT_FLOAT_EQ(first_fval, 1.0f);
|
||||
EXPECT_EQ(attr.values().size(), 2u);
|
||||
}
|
||||
|
||||
@@ -1129,7 +1130,8 @@ TEST(R6_LibertyAttrValueTest, FloatBasic) {
|
||||
LibertyAttrValue fav(42.5f);
|
||||
EXPECT_TRUE(fav.isFloat());
|
||||
EXPECT_FALSE(fav.isString());
|
||||
EXPECT_FLOAT_EQ(fav.floatValue(), 42.5f);
|
||||
auto [fav_val, fav_exists] = fav.floatValue();
|
||||
EXPECT_FLOAT_EQ(fav_val, 42.5f);
|
||||
}
|
||||
|
||||
TEST(R6_LibertyDefineTest, Construction) {
|
||||
@@ -1374,7 +1376,7 @@ TEST(R6_TestCellTest, LibertyLibraryAccessor) {
|
||||
LibertyLibrary lib1("lib1", "lib1.lib");
|
||||
TestCell cell(&lib1, "CELL1", "lib1.lib");
|
||||
EXPECT_EQ(cell.libertyLibrary(), &lib1);
|
||||
EXPECT_STREQ(cell.libertyLibrary()->name(), "lib1");
|
||||
EXPECT_EQ(cell.libertyLibrary()->name(), "lib1");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -1388,33 +1390,33 @@ TEST(R6_TableVariableTest, EqualOrOppositeCapacitance) {
|
||||
|
||||
TEST(R6_TableVariableTest, AllVariableStrings) {
|
||||
// Test that tableVariableString works for all known variables
|
||||
const char *s;
|
||||
std::string_view s;
|
||||
s = tableVariableString(TableAxisVariable::input_transition_time);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::constrained_pin_transition);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::output_pin_transition);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::connect_delay);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::related_out_total_output_net_capacitance);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::iv_output_voltage);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::input_noise_width);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::input_noise_height);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::input_voltage);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::output_voltage);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::path_depth);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::path_distance);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
s = tableVariableString(TableAxisVariable::normalized_voltage);
|
||||
EXPECT_NE(s, nullptr);
|
||||
EXPECT_FALSE(s.empty());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -1704,7 +1706,7 @@ TEST_F(StaLibertyTest, CellPortIteration) {
|
||||
while (port_iter.hasNext()) {
|
||||
LibertyPort *port = port_iter.next();
|
||||
EXPECT_NE(port, nullptr);
|
||||
EXPECT_NE(port->name(), nullptr);
|
||||
EXPECT_FALSE(port->name().empty());
|
||||
port_count++;
|
||||
}
|
||||
EXPECT_GT(port_count, 0);
|
||||
@@ -1743,11 +1745,11 @@ TEST_F(StaLibertyTest, PatternMatchCells) {
|
||||
}
|
||||
|
||||
TEST_F(StaLibertyTest, LibraryName) {
|
||||
EXPECT_NE(lib_->name(), nullptr);
|
||||
EXPECT_FALSE(lib_->name().empty());
|
||||
}
|
||||
|
||||
TEST_F(StaLibertyTest, LibraryFilename) {
|
||||
EXPECT_NE(lib_->filename(), nullptr);
|
||||
EXPECT_FALSE(lib_->filename().empty());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
@@ -1776,8 +1778,8 @@ TEST(LibertyParserTest, LibertyGroupConstruction) {
|
||||
|
||||
EXPECT_EQ(group.type(), "library");
|
||||
EXPECT_EQ(group.line(), 1);
|
||||
ASSERT_NE(group.findAttrString("name"), nullptr);
|
||||
EXPECT_EQ(*group.findAttrString("name"), "test_lib");
|
||||
EXPECT_FALSE(group.findAttrString("name").empty());
|
||||
EXPECT_EQ(group.findAttrString("name"), "test_lib");
|
||||
float max_cap = 0.0f;
|
||||
bool exists = false;
|
||||
group.findAttrFloat("max_cap", max_cap, exists);
|
||||
@@ -1924,12 +1926,12 @@ TEST_F(StaLibertyTest, InferLatchRolesAlreadyCalled) {
|
||||
// Find a latch cell
|
||||
LibertyCell *cell = lib_->findLibertyCell("DFFR_X1");
|
||||
if (cell) {
|
||||
EXPECT_NE(cell->name(), nullptr);
|
||||
EXPECT_FALSE(cell->name().empty());
|
||||
}
|
||||
// Also try DLATCH cells
|
||||
LibertyCell *latch = lib_->findLibertyCell("DLH_X1");
|
||||
if (latch) {
|
||||
EXPECT_NE(latch->name(), nullptr);
|
||||
EXPECT_FALSE(latch->name().empty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2252,9 +2254,8 @@ TEST_F(StaLibertyTest, CellOcvDerate3) {
|
||||
TEST_F(StaLibertyTest, CellFootprint3) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
const char *fp = buf->footprint();
|
||||
// May be null or empty
|
||||
// fp may be null for simple arcs
|
||||
const std::string &fp = buf->footprint();
|
||||
// May be empty for simple arcs
|
||||
}
|
||||
|
||||
// LibertyCell::setFootprint
|
||||
@@ -2262,15 +2263,15 @@ TEST_F(StaLibertyTest, CellSetFootprint) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
buf->setFootprint("test_footprint");
|
||||
EXPECT_STREQ(buf->footprint(), "test_footprint");
|
||||
EXPECT_EQ(buf->footprint(), "test_footprint");
|
||||
}
|
||||
|
||||
// LibertyCell::userFunctionClass
|
||||
TEST_F(StaLibertyTest, CellUserFunctionClass2) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
const char *ufc = buf->userFunctionClass();
|
||||
// ufc may be null for simple arcs
|
||||
const std::string &ufc = buf->userFunctionClass();
|
||||
// ufc may be empty for simple arcs
|
||||
}
|
||||
|
||||
// LibertyCell::setUserFunctionClass
|
||||
@@ -2278,7 +2279,7 @@ TEST_F(StaLibertyTest, CellSetUserFunctionClass) {
|
||||
LibertyCell *buf = lib_->findLibertyCell("BUF_X1");
|
||||
ASSERT_NE(buf, nullptr);
|
||||
buf->setUserFunctionClass("my_class");
|
||||
EXPECT_STREQ(buf->userFunctionClass(), "my_class");
|
||||
EXPECT_EQ(buf->userFunctionClass(), "my_class");
|
||||
}
|
||||
|
||||
// LibertyCell::setSwitchCellType
|
||||
@@ -2561,7 +2562,11 @@ TEST_F(StaLibertyTest, CellSetOcvDerateNull) {
|
||||
|
||||
// OperatingConditions construction
|
||||
TEST_F(StaLibertyTest, OperatingConditionsConstruct) {
|
||||
OperatingConditions oc("typical", 1.0f, 1.1f, 25.0f, WireloadTree::balanced);
|
||||
OperatingConditions oc("typical");
|
||||
oc.setProcess(1.0f);
|
||||
oc.setVoltage(1.1f);
|
||||
oc.setTemperature(25.0f);
|
||||
oc.setWireloadTree(WireloadTree::balanced);
|
||||
EXPECT_EQ(oc.name(), std::string("typical"));
|
||||
EXPECT_FLOAT_EQ(oc.process(), 1.0f);
|
||||
EXPECT_FLOAT_EQ(oc.voltage(), 1.1f);
|
||||
@@ -3083,12 +3088,12 @@ TEST_F(StaLibertyTest, TimingTypeIsCheck) {
|
||||
|
||||
// to_string(TimingSense)
|
||||
TEST_F(StaLibertyTest, TimingSenseToString) {
|
||||
const char *s = to_string(TimingSense::positive_unate);
|
||||
EXPECT_NE(s, nullptr);
|
||||
s = to_string(TimingSense::negative_unate);
|
||||
EXPECT_NE(s, nullptr);
|
||||
s = to_string(TimingSense::non_unate);
|
||||
EXPECT_NE(s, nullptr);
|
||||
const std::string &s1 = to_string(TimingSense::positive_unate);
|
||||
EXPECT_FALSE(s1.empty());
|
||||
const std::string &s2 = to_string(TimingSense::negative_unate);
|
||||
EXPECT_FALSE(s2.empty());
|
||||
const std::string &s3 = to_string(TimingSense::non_unate);
|
||||
EXPECT_FALSE(s3.empty());
|
||||
}
|
||||
|
||||
// timingSenseOpposite
|
||||
@@ -3101,9 +3106,9 @@ TEST_F(StaLibertyTest, TimingSenseOpposite) {
|
||||
|
||||
// ScaleFactorPvt names
|
||||
TEST_F(StaLibertyTest, ScaleFactorPvtNames) {
|
||||
EXPECT_STREQ(scaleFactorPvtName(ScaleFactorPvt::process), "process");
|
||||
EXPECT_STREQ(scaleFactorPvtName(ScaleFactorPvt::volt), "volt");
|
||||
EXPECT_STREQ(scaleFactorPvtName(ScaleFactorPvt::temp), "temp");
|
||||
EXPECT_EQ(scaleFactorPvtName(ScaleFactorPvt::process), "process");
|
||||
EXPECT_EQ(scaleFactorPvtName(ScaleFactorPvt::volt), "volt");
|
||||
EXPECT_EQ(scaleFactorPvtName(ScaleFactorPvt::temp), "temp");
|
||||
}
|
||||
|
||||
// findScaleFactorPvt
|
||||
@@ -3115,8 +3120,8 @@ TEST_F(StaLibertyTest, FindScaleFactorPvt) {
|
||||
|
||||
// ScaleFactorType names
|
||||
TEST_F(StaLibertyTest, ScaleFactorTypeNames) {
|
||||
const char *name = scaleFactorTypeName(ScaleFactorType::cell);
|
||||
EXPECT_NE(name, nullptr);
|
||||
const std::string &name = scaleFactorTypeName(ScaleFactorType::cell);
|
||||
EXPECT_FALSE(name.empty());
|
||||
}
|
||||
|
||||
// findScaleFactorType
|
||||
@@ -3397,16 +3402,16 @@ TEST_F(StaLibertyTest, PortScanSignalType2) {
|
||||
|
||||
// scanSignalTypeName
|
||||
TEST_F(StaLibertyTest, ScanSignalTypeName) {
|
||||
const char *name = scanSignalTypeName(ScanSignalType::enable);
|
||||
EXPECT_NE(name, nullptr);
|
||||
name = scanSignalTypeName(ScanSignalType::clock);
|
||||
EXPECT_NE(name, nullptr);
|
||||
const std::string &scan_name1 = scanSignalTypeName(ScanSignalType::enable);
|
||||
EXPECT_FALSE(scan_name1.empty());
|
||||
const std::string &scan_name2 = scanSignalTypeName(ScanSignalType::clock);
|
||||
EXPECT_FALSE(scan_name2.empty());
|
||||
}
|
||||
|
||||
// pwrGndTypeName and findPwrGndType
|
||||
TEST_F(StaLibertyTest, PwrGndTypeName) {
|
||||
const char *name = pwrGndTypeName(PwrGndType::primary_power);
|
||||
EXPECT_NE(name, nullptr);
|
||||
const std::string &pwr_name = pwrGndTypeName(PwrGndType::primary_power);
|
||||
EXPECT_FALSE(pwr_name.empty());
|
||||
PwrGndType t = findPwrGndType("primary_power");
|
||||
EXPECT_EQ(t, PwrGndType::primary_power);
|
||||
}
|
||||
|
||||
@@ -1522,8 +1522,8 @@ TEST_F(StaLibertyTest, LibertyStmtTypes) {
|
||||
LibertyGroup grp("cell", std::move(params), 1);
|
||||
EXPECT_EQ(grp.type(), "cell");
|
||||
EXPECT_EQ(grp.line(), 1);
|
||||
ASSERT_NE(grp.firstName(), nullptr);
|
||||
EXPECT_STREQ(grp.firstName(), "TEST");
|
||||
EXPECT_FALSE(grp.firstParam().empty());
|
||||
EXPECT_EQ(grp.firstParam(), "TEST");
|
||||
EXPECT_TRUE(grp.subgroups().empty());
|
||||
}
|
||||
|
||||
@@ -1532,8 +1532,8 @@ TEST_F(StaLibertyTest, LibertySimpleAttrIsComplex) {
|
||||
LibertySimpleAttr attr("name", LibertyAttrValue(std::string("test")), 1);
|
||||
EXPECT_EQ(attr.name(), "name");
|
||||
EXPECT_EQ(attr.line(), 1);
|
||||
ASSERT_NE(attr.stringValue(), nullptr);
|
||||
EXPECT_EQ(*attr.stringValue(), "test");
|
||||
EXPECT_FALSE(attr.stringValue().empty());
|
||||
EXPECT_EQ(attr.stringValue(), "test");
|
||||
EXPECT_TRUE(attr.value().isString());
|
||||
}
|
||||
|
||||
@@ -1545,7 +1545,7 @@ TEST_F(StaLibertyTest, LibertyComplexAttrIsSimple) {
|
||||
LibertyComplexAttr attr("name", std::move(values), 1);
|
||||
ASSERT_NE(attr.firstValue(), nullptr);
|
||||
EXPECT_TRUE(attr.firstValue()->isFloat());
|
||||
EXPECT_FLOAT_EQ(attr.firstValue()->floatValue(), 1.0f);
|
||||
EXPECT_FLOAT_EQ(attr.firstValue()->floatValue().first, 1.0f);
|
||||
EXPECT_EQ(attr.values().size(), 2u);
|
||||
}
|
||||
|
||||
@@ -1555,15 +1555,13 @@ TEST_F(StaLibertyTest, AttrValueCrossType) {
|
||||
EXPECT_TRUE(sval.isString());
|
||||
EXPECT_FALSE(sval.isFloat());
|
||||
EXPECT_EQ(sval.stringValue(), "hello");
|
||||
float parsed = 0.0f;
|
||||
bool valid = true;
|
||||
sval.floatValue(parsed, valid);
|
||||
auto [parsed, valid] = sval.floatValue();
|
||||
EXPECT_FALSE(valid);
|
||||
|
||||
LibertyAttrValue fval(3.14f);
|
||||
EXPECT_FALSE(fval.isString());
|
||||
EXPECT_TRUE(fval.isFloat());
|
||||
EXPECT_FLOAT_EQ(fval.floatValue(), 3.14f);
|
||||
EXPECT_FLOAT_EQ(fval.floatValue().first, 3.14f);
|
||||
}
|
||||
|
||||
// R9_46: LibertyDefine isDefine
|
||||
@@ -3528,19 +3526,19 @@ TEST_F(StaLibertyTest, TimingGroupOutputWaveforms) {
|
||||
|
||||
// R11_1: timingTypeString - the free function in TimingArc.cc
|
||||
// It is not declared in a public header, so we declare it extern here.
|
||||
extern const char *timingTypeString(TimingType type);
|
||||
extern std::string_view timingTypeString(TimingType type);
|
||||
|
||||
TEST_F(StaLibertyTest, TimingTypeString) {
|
||||
// timingTypeString is defined in TimingArc.cc
|
||||
// We test several timing types to cover the function
|
||||
EXPECT_STREQ(timingTypeString(TimingType::combinational), "combinational");
|
||||
EXPECT_STREQ(timingTypeString(TimingType::clear), "clear");
|
||||
EXPECT_STREQ(timingTypeString(TimingType::rising_edge), "rising_edge");
|
||||
EXPECT_STREQ(timingTypeString(TimingType::falling_edge), "falling_edge");
|
||||
EXPECT_STREQ(timingTypeString(TimingType::setup_rising), "setup_rising");
|
||||
EXPECT_STREQ(timingTypeString(TimingType::hold_falling), "hold_falling");
|
||||
EXPECT_STREQ(timingTypeString(TimingType::three_state_enable), "three_state_enable");
|
||||
EXPECT_STREQ(timingTypeString(TimingType::unknown), "unknown");
|
||||
EXPECT_EQ(timingTypeString(TimingType::combinational), "combinational");
|
||||
EXPECT_EQ(timingTypeString(TimingType::clear), "clear");
|
||||
EXPECT_EQ(timingTypeString(TimingType::rising_edge), "rising_edge");
|
||||
EXPECT_EQ(timingTypeString(TimingType::falling_edge), "falling_edge");
|
||||
EXPECT_EQ(timingTypeString(TimingType::setup_rising), "setup_rising");
|
||||
EXPECT_EQ(timingTypeString(TimingType::hold_falling), "hold_falling");
|
||||
EXPECT_EQ(timingTypeString(TimingType::three_state_enable), "three_state_enable");
|
||||
EXPECT_EQ(timingTypeString(TimingType::unknown), "unknown");
|
||||
}
|
||||
|
||||
// R11_2: writeLiberty exercises LibertyWriter constructor, destructor,
|
||||
@@ -3604,8 +3602,8 @@ TEST_F(StaLibertyTest, LibertyParserDirect) {
|
||||
EXPECT_EQ(visitor.complex_attrs.size(), 1u);
|
||||
EXPECT_EQ(visitor.variables.size(), 1u);
|
||||
|
||||
ASSERT_NE(library->firstName(), nullptr);
|
||||
EXPECT_STREQ(library->firstName(), "test_r11_parser");
|
||||
EXPECT_FALSE(library->firstParam().empty());
|
||||
EXPECT_EQ(library->firstParam(), "test_r11_parser");
|
||||
EXPECT_EQ(library->defineMap().size(), 1u);
|
||||
EXPECT_EQ(library->findSubgroup("cell"), cell);
|
||||
float area = 0.0f;
|
||||
|
||||
Reference in New Issue
Block a user