blob: 3fb7af865d71df0364c3632649f509eeffc93743 [file] [log] [blame]
Davide Pesavento35120ea2015-11-17 21:13:18 +01001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2015, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#ifndef NFD_TESTS_NETWORK_INTERFACE_FIXTURE_HPP
27#define NFD_TESTS_NETWORK_INTERFACE_FIXTURE_HPP
28
29#include "core/network-interface.hpp"
30#include "face/ethernet-transport.hpp"
31
32#include "test-common.hpp"
33
34namespace nfd {
35namespace tests {
36
37class NetworkInterfaceFixture : protected BaseFixture
38{
39protected:
40 NetworkInterfaceFixture()
41 {
42 for (const auto& netif : listNetworkInterfaces()) {
43 if (!netif.isLoopback() && netif.isUp()) {
44 try {
45 face::EthernetTransport transport(netif, ethernet::getBroadcastAddress());
46 m_interfaces.push_back(netif);
47 }
48 catch (const face::EthernetTransport::Error&) {
49 // pass
50 }
51 }
52 }
53 }
54
55protected:
56 std::vector<NetworkInterfaceInfo> m_interfaces;
57};
58
59#define SKIP_IF_NETWORK_INTERFACE_COUNT_LT(n) \
60 do { \
61 if (this->m_interfaces.size() < (n)) { \
62 BOOST_WARN_MESSAGE(false, "skipping assertions that require " \
63 #n " or more network interfaces"); \
64 return; \
65 } \
66 } while (false)
67
68} // namespace tests
69} // namespace nfd
70
71#endif // NFD_TESTS_NETWORK_INTERFACE_FIXTURE_HPP