A Discrete-Event Network Simulator
API
pcap-test.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@cutebugs.net>
19  */
20 
21 #ifndef PCAP_TEST_H
22 #define PCAP_TEST_H
23 
24 #include <sstream>
25 #include <string>
26 #include <stdint.h>
27 #include "pcap-file.h"
28 #include "ns3/test.h"
29 
38 #define NS_PCAP_TEST_EXPECT_EQ(filename) \
39  do { \
40  std::ostringstream oss; \
41  oss << filename; \
42  std::string expected = CreateDataDirFilename (oss.str()); \
43  std::string got = CreateTempDirFilename (oss.str()); \
44  uint32_t sec(0), usec(0), packets(0); \
45  \
46  bool diff = PcapFile::Diff (got, expected, sec, usec, packets); \
47  NS_TEST_EXPECT_MSG_EQ (diff, false, \
48  "PCAP traces " \
49  << got << " and " << expected \
50  << " differ starting from packet " \
51  << packets << " at " << sec << " s " \
52  << usec << " us"); \
53  } while (false)
54 
55 
56 #endif /* PCAP_TEST_H */