1- // /////////////////////////////////////////////////////////////////////////////
2- // BSD 3-Clause License
3- //
4- // Copyright (c) 2023, Google LLC
5- // All rights reserved.
6- //
7- // Redistribution and use in source and binary forms, with or without
8- // modification, are permitted provided that the following conditions are met:
9- //
10- // * Redistributions of source code must retain the above copyright notice, this
11- // list of conditions and the following disclaimer.
12- //
13- // * Redistributions in binary form must reproduce the above copyright notice,
14- // this list of conditions and the following disclaimer in the documentation
15- // and/or other materials provided with the distribution.
16- //
17- // * Neither the name of the copyright holder nor the names of its
18- // contributors may be used to endorse or promote products derived from
19- // this software without specific prior written permission.
20- //
21- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22- // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23- // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24- // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25- // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26- // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27- // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28- // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29- // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30- // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31- // POSSIBILITY OF SUCH DAMAGE.
1+ // SPDX-License-Identifier: BSD-3-Clause
2+ // Copyright (c) 2023-2025, The OpenROAD Authors
323
4+ #include < filesystem>
335#include < fstream>
346#include < ios>
357#include < string>
368#include < type_traits>
379#include < variant>
3810#include < vector>
3911
40- #include " env.h"
41- #include " gmock/gmock.h"
4212#include " gtest/gtest.h"
4313#include " helper.h"
4414#include " odb/db.h"
@@ -69,12 +39,12 @@ std::string GetName(const std::variant<dbBTerm*, dbITerm*>& pin)
6939 pin);
7040}
7141
72- class TestScanChain : public testing ::Test
42+ class TestScanChain : public SimpleDbFixture
7343{
7444 protected:
7545 TestScanChain ()
7646 {
77- db_ = create2LevetDbWithBTerms ();
47+ create2LevetDbWithBTerms ();
7848 block_ = db_->getChip ()->getBlock ();
7949 dft_ = block_->getDft ();
8050
@@ -87,7 +57,8 @@ class TestScanChain : public testing::Test
8757
8858 void SetUpTmpPath (const std::string& name)
8959 {
90- tmp_path_ = testTmpPath (" results" , name);
60+ std::filesystem::create_directory (" results" );
61+ tmp_path_ = " results/" + name;
9162 }
9263
9364 // Writes a temporal DB and then tries to read the contents back to check if
@@ -118,7 +89,6 @@ class TestScanChain : public testing::Test
11889 return db;
11990 }
12091
121- dbDatabase* db_;
12292 dbBlock* block_;
12393 std::string tmp_path_;
12494 dbDft* dft_;
@@ -148,20 +118,20 @@ TEST_F(TestScanChain, CreateScanChain)
148118 dbDft* dft2 = block2->getDft ();
149119
150120 odb::dbSet<dbScanChain> scan_chains2 = dft2->getScanChains ();
151- EXPECT_THAT (scan_chains2.size (), 1 );
121+ EXPECT_EQ (scan_chains2.size (), 1 );
152122
153123 dbScanChain* scan_chain2 = *scan_chains2.begin ();
154124
155125 odb::dbSet<dbScanPartition> scan_partition2
156126 = scan_chain2->getScanPartitions ();
157- EXPECT_THAT (scan_partition2.size (), 1 );
158- EXPECT_THAT (scan_partition2.begin ()->getName (), kPartition1 );
127+ EXPECT_EQ (scan_partition2.size (), 1 );
128+ EXPECT_EQ (scan_partition2.begin ()->getName (), kPartition1 );
159129
160130 odb::dbSet<dbScanList> scan_lists2 = scan_partition2.begin ()->getScanLists ();
161- EXPECT_THAT (scan_lists2.size (), 1 );
131+ EXPECT_EQ (scan_lists2.size (), 1 );
162132
163133 odb::dbSet<dbScanInst> scan_insts2 = scan_lists2.begin ()->getScanInsts ();
164- EXPECT_THAT (scan_insts2.size (), 1 );
134+ EXPECT_EQ (scan_insts2.size (), 1 );
165135}
166136
167137TEST_F (TestScanChain, CreateScanChainWithPartition)
@@ -208,20 +178,20 @@ TEST_F(TestScanChain, CreateScanChainWithPartition)
208178 dbDft* dft2 = block2->getDft ();
209179
210180 dbSet<dbScanChain> scan_chains2 = dft2->getScanChains ();
211- EXPECT_THAT (scan_chains2.size (), 1 );
181+ EXPECT_EQ (scan_chains2.size (), 1 );
212182
213183 dbSet<dbScanPartition> scan_partitions2
214184 = scan_chains2.begin ()->getScanPartitions ();
215- EXPECT_THAT (scan_partitions2.size (), 2 );
185+ EXPECT_EQ (scan_partitions2.size (), 2 );
216186
217187 auto iterator = scan_partitions2.begin ();
218188
219189 dbScanPartition* partition12 = *iterator;
220190 ++iterator;
221191 dbScanPartition* partition22 = *iterator;
222192
223- EXPECT_THAT (partition12->getName (), kPartition1 );
224- EXPECT_THAT (partition22->getName (), kPartition2 );
193+ EXPECT_EQ (partition12->getName (), kPartition1 );
194+ EXPECT_EQ (partition22->getName (), kPartition2 );
225195
226196 // check the created instances
227197
@@ -232,19 +202,19 @@ TEST_F(TestScanChain, CreateScanChainWithPartition)
232202 for (dbScanList* scan_list : scan_lists12) {
233203 for (dbScanInst* scan_inst : scan_list->getScanInsts ()) {
234204 const dbScanInst::AccessPins& access_pins = scan_inst->getAccessPins ();
235- EXPECT_THAT (GetName (access_pins.scan_in ), " a" );
236- EXPECT_THAT (GetName (access_pins.scan_out ), " o" );
237- EXPECT_THAT (instances_[i]->getName (), scan_inst->getInst ()->getName ());
205+ EXPECT_EQ (GetName (access_pins.scan_in ), " a" );
206+ EXPECT_EQ (GetName (access_pins.scan_out ), " o" );
207+ EXPECT_EQ (instances_[i]->getName (), scan_inst->getInst ()->getName ());
238208 ++i;
239209 }
240210 }
241211
242212 for (dbScanList* scan_list : scan_lists22) {
243213 for (dbScanInst* scan_inst : scan_list->getScanInsts ()) {
244214 const dbScanInst::AccessPins& access_pins = scan_inst->getAccessPins ();
245- EXPECT_THAT (GetName (access_pins.scan_in ), " a" );
246- EXPECT_THAT (GetName (access_pins.scan_out ), " o" );
247- EXPECT_THAT (instances_[i]->getName (), scan_inst->getInst ()->getName ());
215+ EXPECT_EQ (GetName (access_pins.scan_in ), " a" );
216+ EXPECT_EQ (GetName (access_pins.scan_out ), " o" );
217+ EXPECT_EQ (instances_[i]->getName (), scan_inst->getInst ()->getName ());
248218 ++i;
249219 }
250220 }
0 commit comments