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