blob: 4228f79ba690e71ec5de19cc18b9c2d380f866b7 [file] [log] [blame]
Davide Pesavento35120ea2015-11-17 21:13:18 +01001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shi7003c602017-01-10 13:35:28 +00003 * Copyright (c) 2014-2017, Regents of the University of California,
Davide Pesavento35120ea2015-11-17 21:13:18 +01004 * 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
Junxiao Shi7003c602017-01-10 13:35:28 +000026#ifndef NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP
27#define NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP
Davide Pesavento35120ea2015-11-17 21:13:18 +010028
29#include "core/network-interface.hpp"
30#include "face/ethernet-transport.hpp"
31
32#include "test-common.hpp"
33
34namespace nfd {
Eric Newberry8717e872015-11-23 12:41:50 -070035namespace face {
Davide Pesavento35120ea2015-11-17 21:13:18 +010036namespace tests {
37
Junxiao Shi7003c602017-01-10 13:35:28 +000038class EthernetFixture : public virtual nfd::tests::BaseFixture
Davide Pesavento35120ea2015-11-17 21:13:18 +010039{
40protected:
Junxiao Shi7003c602017-01-10 13:35:28 +000041 EthernetFixture()
Davide Pesavento35120ea2015-11-17 21:13:18 +010042 {
43 for (const auto& netif : listNetworkInterfaces()) {
44 if (!netif.isLoopback() && netif.isUp()) {
45 try {
Junxiao Shi7003c602017-01-10 13:35:28 +000046 EthernetTransport transport(netif, ethernet::getBroadcastAddress());
47 netifs.push_back(netif);
Davide Pesavento35120ea2015-11-17 21:13:18 +010048 }
Junxiao Shi7003c602017-01-10 13:35:28 +000049 catch (const EthernetTransport::Error&) {
50 // ignore
Davide Pesavento35120ea2015-11-17 21:13:18 +010051 }
52 }
53 }
54 }
55
56protected:
Junxiao Shi7003c602017-01-10 13:35:28 +000057 /** \brief EthernetTransport-capable network interfaces
58 */
59 std::vector<NetworkInterfaceInfo> netifs;
Davide Pesavento35120ea2015-11-17 21:13:18 +010060};
61
Junxiao Shi7003c602017-01-10 13:35:28 +000062#define SKIP_IF_ETHERNET_NETIF_COUNT_LT(n) \
63 do { \
64 if (this->netifs.size() < (n)) { \
65 BOOST_WARN_MESSAGE(false, "skipping assertions that require " #n \
66 " or more EthernetTransport-capable network interfaces"); \
67 return; \
68 } \
Davide Pesavento35120ea2015-11-17 21:13:18 +010069 } while (false)
70
71} // namespace tests
Eric Newberry8717e872015-11-23 12:41:50 -070072} // namespace face
Davide Pesavento35120ea2015-11-17 21:13:18 +010073} // namespace nfd
74
Junxiao Shi7003c602017-01-10 13:35:28 +000075#endif // NFD_TESTS_DAEMON_FACE_ETHERNET_FIXTURE_HPP