torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BitstreamUnitTest.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 Bitstream class.
18 
19 #include <boost/test/unit_test.hpp>
23 #include <fstream>
24 #include <iostream>
25 
26 namespace torc {
27 namespace bitstream {
28 
29 BOOST_AUTO_TEST_SUITE(bitstream)
30 
31 
32 /// \brief Unit test for the Bitstream class.
33 BOOST_AUTO_TEST_CASE(BitstreamUnitTest) {
34 
35  // build the file paths
37  boost::filesystem::path generatedPath =
38  executablePath / "regression" / "BitstreamUnitTest.generated.bit";
39  boost::filesystem::path referencePath =
40  executablePath / "torc" / "bitstream" / "Virtex5UnitTest.reference.bit";
41 
42  // read the bitstream
43  std::fstream fileStream(referencePath.string().c_str(), std::ios::binary | std::ios::in);
44  BOOST_REQUIRE(fileStream.good());
45  Bitstream bitstream;
46  bitstream.readHeader(fileStream);
47  bitstream.cleanDateAndTime();
48 
49  // write the bitstream header to the console
50  std::cout << bitstream << std::endl;
51  std::string deviceName = bitstream.getDeviceName();
52  torc::common::DeviceDesignator deviceDesignator(deviceName);
53  std::cout << "family is " << deviceDesignator.getFamily() << std::endl;
54 
55 }
56 
57 BOOST_AUTO_TEST_SUITE_END()
58 
59 } // namespace bitstream
60 } // namespace torc
static bool readHeader(std::istream &inStream, string &outDesignName, string &outDeviceName, string &outDesignDate, string &outDesignTime, uint32_t &outBitstreamLength, uint32_t &outHeaderLength)
Read a bitstream header, and return its fields.
Encapsulation of a device designator and its constituent elements.
const EFamily & getFamily(void) const
Returns the device family.
Header for the DirectoryTree class.
Header for the DeviceDesignator class.
std::string string
Xilinx bitstream base class.
Header for the Bitstream class.
boost::filesystem::path path
BOOST_AUTO_TEST_CASE(hexCharacterToDec)
static const boost::filesystem::path & getExecutablePath(void)
Returns the absolute path to the executable directory.