| 46 | class TcpFlowReconstructTest : public ::testing::TestWithParam<const char *> { |
| 47 | protected: |
| 48 | virtual void SetUp() { |
| 49 | // TODO(barath): Due to a problem with some versions of gtest when using the |
| 50 | // TEST_P macro, for the moment we just use a single tracefile |
| 51 | // for now. |
| 52 | std::string tracefile_prefix = "testdata/test-pktcaptures/tcpflow-http-3"; |
| 53 | |
| 54 | char errbuf[PCAP_ERRBUF_SIZE]; |
| 55 | handle_ = pcap_open_offline((tracefile_prefix + ".pcap").c_str(), errbuf); |
| 56 | ASSERT_TRUE(handle_ != nullptr); |
| 57 | |
| 58 | const u_char *pcap_pkt; |
| 59 | struct pcap_pkthdr pcap_hdr; |
| 60 | while ((pcap_pkt = pcap_next(handle_, &pcap_hdr)) != nullptr) { |
| 61 | ASSERT_EQ(pcap_hdr.caplen, pcap_hdr.len) |
| 62 | << "Didn't capture the full packet."; |
| 63 | Packet *p = pool_.Alloc(pcap_hdr.caplen); |
| 64 | bess::utils::Copy(p->head_data(), pcap_pkt, pcap_hdr.caplen); |
| 65 | pkts_.push_back(p); |
| 66 | } |
| 67 | |
| 68 | // Read in file with good reconstruction. |
| 69 | std::ifstream f(tracefile_prefix + ".bytes", std::ios::binary); |
| 70 | ASSERT_FALSE(f.bad()); |
| 71 | |
| 72 | f >> std::noskipws; |
| 73 | std::istream_iterator<char> start(f), end; |
| 74 | std::copy(start, end, std::back_inserter(bytestream_)); |
| 75 | } |
| 76 | |
| 77 | virtual void TearDown() { |
| 78 | for (Packet *p : pkts_) { |