torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XdlExporterUnitTest.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 XdlExporter class.
18 /// \see DesignRegressionTest.cpp and SampleCodeUnitTest.cpp.
19 
20 /// \file
21 /// \brief Unit test for the XdlExporter class.
22 
23 #include <boost/test/unit_test.hpp>
28 #include <fstream>
29 
30 namespace torc {
31 namespace physical {
32 
33 BOOST_AUTO_TEST_SUITE(physical)
34 
35 /// \brief Unit test for the XdlExporter class.
36 BOOST_AUTO_TEST_CASE(XdlExporterUnitTest) {
37  // create the appropriate file paths
39  / "regression" / "XdlExporterUnitTest.generated.xdl";
41  / "torc" / "physical" / "ModuleTransformerUnitTest.Scenario.02.Flatten.xdl";
42 
43  // import the XDL design
44  std::fstream fileStream(referencePath.string().c_str());
45  BOOST_REQUIRE(fileStream.good());
46  XdlImporter importer;
47  importer(fileStream, referencePath.string());
48 
49  // look up the design
50  DesignSharedPtr designPtr = importer.getDesignPtr();
51  BOOST_REQUIRE(designPtr.get() != 0);
52 
53  // members tested:
54  // std::ostream& mStream;
55  // int mIndentCount;
56  // std::string mIndentString;
57  // functions tested:
58  // XdlExporter(std::ostream& inStream, const std::string& inIndentString = "\t");
59  // void operator() (const DesignSharedPtr& inDesignPtr);
60  // void indent(void) const;
61  // void write(const Circuit& circuit);
62  // void write(const Design& design);
63  // void write(const Module& module);
64  // void write(const Port& port);
65  // void write(const Instance& instance);
66  // void write(const Net& net);
67  // void write(const InstancePin& instancePin, EPinDirection pinDirection, bool comma);
68  // void write(const Pip& pip, bool comma);
69  // void write(const Routethrough& routethrough);
70  // void write(const ConfigMap& configMap);
71  // export the XDL design
72  std::fstream xdlExport(generatedPath.string().c_str(), std::ios_base::out);
73  XdlExporter fileExporter(xdlExport);
74  fileExporter(designPtr);
75  BOOST_CHECK(torc::common::fileContentsAreEqual(generatedPath, referencePath));
76 }
77 
78 BOOST_AUTO_TEST_SUITE_END()
79 
80 } // namespace physical
81 } // 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 Boost.Test helper functions.
Header for the XdlImporter class.
Header for the XdlExport class.
boost::filesystem::path path
boost::shared_ptr< Design > DesignSharedPtr
Shared pointer encapsulation of a Design.
Importer from XDL format into a physical design.
bool fileContentsAreEqual(const boost::filesystem::path &inA, const boost::filesystem::path &inB)
Compare the raw contents of two files to determine whether they are identical.
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.
Physical design exporter for XDL.
Definition: XdlExporter.hpp:31