torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
physical/XdlImporterUnitTest.cpp
Go to the documentation of this file.
1 // Torc - Copyright 2011-2013 University of Southern California. All Rights Reserved.
2 // $HeadURL$
3 // $Id$
4 
5 // This program is free software: you can redistribute it and/or modify it under the terms of the
6 // GNU General Public License as published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11 // the GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License along with this program. If
14 // not, see <http://www.gnu.org/licenses/>.
15 
16 /// \file
17 /// \brief Unit test for the XdlImporter class.
18 
19 #include <boost/test/unit_test.hpp>
22 #include "torc/physical/Design.hpp"
23 #include <fstream>
24 
25 namespace torc {
26 namespace physical {
27 
28 BOOST_AUTO_TEST_SUITE(physical)
29 
30 /// \brief Unit test for the XdlImporter class.
31 /// \todo Finish testing XdlImporter functionality.
32 BOOST_AUTO_TEST_CASE(XdlImporterUnitTest) {
33  // members not tested:
34  // bool mTraceScanning;
35  // bool mTraceParsing;
36  // string mStreamName;
37  // functions not tested:
38  // virtual ~XdlImporter(void);
39  // class torc::XdlScanner* lexer;
40  // DEPRECATED bool import(istream& in, const string& name = "stream input")
41  // DEPRECATED bool import(const string& input, const string& name = "string stream")
42  // bool operator()(const string& input, const string& name = "string stream");
43  // DEPRECATED bool import(const boost::filesystem::path& filename);
44  // bool operator()(const boost::filesystem::path& filename);
45  // void error(const location& l, const string& m);
46  // void error(const string& m);
47  // void failure(void);
48  // functions not tested (because they are null virtual functions):
49  // virtual void initializeDatabase(void);
50  // virtual void bind(torc::physical::InstancePinSharedPtr&);
51  // virtual void bind(torc::physical::Pip&, EPipType);
52 
53  // create the appropriate file paths
55  / "torc" / "physical" / "DesignUnitTest.reference.xdl";
56 
57  // functions tested:
58  // XdlImporter(void);
59  // bool operator()(istream& in, const string& name = "stream input");
60  // import the XDL design
61  std::fstream fileStream(referencePath.string().c_str());
62  BOOST_REQUIRE(fileStream.good());
63  XdlImporter importer;
64  importer(fileStream, referencePath.string());
65  BOOST_CHECK_EQUAL(referencePath.string(), importer.mStreamName);
66 
67  // functions tested:
68  // DesignSharedPtr getDesignPtr(void);
69  DesignSharedPtr designPtr = importer.getDesignPtr();
70  BOOST_REQUIRE(designPtr.get() != 0);
71  BOOST_CHECK_EQUAL(designPtr->getName(), "blinker");
72  BOOST_CHECK_EQUAL(designPtr->getDevice(), "xc5vlx30");
73  BOOST_CHECK_EQUAL(designPtr->getPackage(), "ff324");
74  BOOST_CHECK_EQUAL(designPtr->getSpeedGrade(), "-1");
75  BOOST_CHECK_EQUAL(designPtr->getModuleCount(), 0u);
76  BOOST_CHECK_EQUAL(designPtr->getInstanceCount(), 8u);
77  BOOST_CHECK_EQUAL(designPtr->getNetCount(), 7u);
78 }
79 
80 BOOST_AUTO_TEST_SUITE_END()
81 
82 } // namespace physical
83 } // namespace torc
DesignSharedPtr getDesignPtr(void)
Returns a shared pointer for the design.
Header for the DirectoryTree class.
BOOST_AUTO_TEST_CASE(XdlUnpackUnitTest)
Unit test for the XdlUnpack class.
Header for the XdlImporter class.
Header for the Design class.
boost::filesystem::path path
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
Importer from XDL format into a physical design.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.