00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/physical/XdlImporterUnitTest.cpp $ 00003 // $Id: XdlImporterUnitTest.cpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Unit test for the XdlImporter class. 00018 00019 #include <boost/test/unit_test.hpp> 00020 #include "torc/physical/XdlImporter.hpp" 00021 #include "torc/common/DirectoryTree.hpp" 00022 #include "torc/physical/Design.hpp" 00023 #include <fstream> 00024 00025 namespace torc { 00026 namespace physical { 00027 00028 BOOST_AUTO_TEST_SUITE(physical) 00029 00030 /// \brief Unit test for the XdlImporter class. 00031 /// \todo Finish testing XdlImporter functionality. 00032 BOOST_AUTO_TEST_CASE(XdlImporterUnitTest) { 00033 // members not tested: 00034 // bool mTraceScanning; 00035 // bool mTraceParsing; 00036 // string mStreamName; 00037 // functions not tested: 00038 // virtual ~XdlImporter(void); 00039 // class torc::XdlScanner* lexer; 00040 // DEPRECATED bool import(istream& in, const string& name = "stream input") 00041 // DEPRECATED bool import(const string& input, const string& name = "string stream") 00042 // bool operator()(const string& input, const string& name = "string stream"); 00043 // DEPRECATED bool import(const boost::filesystem::path& filename); 00044 // bool operator()(const boost::filesystem::path& filename); 00045 // void error(const location& l, const string& m); 00046 // void error(const string& m); 00047 // void failure(void); 00048 // functions not tested (because they are null virtual functions): 00049 // virtual void initializeDatabase(void); 00050 // virtual void bind(torc::physical::InstancePinSharedPtr&); 00051 // virtual void bind(torc::physical::Pip&, EPipType); 00052 00053 // create the appropriate file paths 00054 boost::filesystem::path regressionPath = 00055 torc::common::DirectoryTree::getExecutablePath() / "regression"; 00056 boost::filesystem::path referencePath = regressionPath / "DesignUnitTest.reference.xdl"; 00057 00058 // functions tested: 00059 // XdlImporter(void); 00060 // bool operator()(istream& in, const string& name = "stream input"); 00061 // import the XDL design 00062 std::fstream fileStream(referencePath.string().c_str()); 00063 BOOST_REQUIRE(fileStream.good()); 00064 XdlImporter importer; 00065 importer(fileStream, referencePath.string()); 00066 BOOST_CHECK_EQUAL(referencePath.string(), importer.mStreamName); 00067 00068 // functions tested: 00069 // DesignSharedPtr getDesignPtr(void); 00070 DesignSharedPtr designPtr = importer.getDesignPtr(); 00071 BOOST_REQUIRE(designPtr.get() != 0); 00072 BOOST_CHECK_EQUAL(designPtr->getName(), "blinker"); 00073 BOOST_CHECK_EQUAL(designPtr->getDevice(), "xc5vlx30"); 00074 BOOST_CHECK_EQUAL(designPtr->getPackage(), "ff324"); 00075 BOOST_CHECK_EQUAL(designPtr->getSpeedGrade(), "-1"); 00076 BOOST_CHECK_EQUAL(designPtr->getModuleCount(), 0u); 00077 BOOST_CHECK_EQUAL(designPtr->getInstanceCount(), 8u); 00078 BOOST_CHECK_EQUAL(designPtr->getNetCount(), 7u); 00079 } 00080 00081 BOOST_AUTO_TEST_SUITE_END() 00082 00083 } // namespace physical 00084 } // namespace torc