Skip to content

Commit

Permalink
tests: merge unit-tests-rib into unit-tests-daemon
Browse files Browse the repository at this point in the history
Change-Id: If522cdb43a2686030f4fd4c2d2e25f1b50c54681
  • Loading branch information
Pesa committed Feb 18, 2024
1 parent e0b67df commit caa60cc
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 112 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: Publish Docker image

on:
push:
branches:
- master
paths-ignore:
- '*.md'
- '.jenkins'
- '.jenkins.d/**'
- '.mailmap'
- 'tests/**'
workflow_dispatch:

permissions:
Expand Down
1 change: 0 additions & 1 deletion .jenkins.d/20-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ rm -rf ~/.ndn
# First run all tests as unprivileged user
./build/unit-tests-core $(ut_log_args core)
./build/unit-tests-daemon $(ut_log_args daemon)
./build/unit-tests-rib $(ut_log_args rib)
./build/unit-tests-tools $(ut_log_args tools)

# Then use sudo to run those tests that need superuser powers
Expand Down
92 changes: 51 additions & 41 deletions README-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,26 @@ Contributions to NFD must be licensed under the GPL v3 or a compatible license.
If you choose the GPL v3, please use the following license boilerplate in all `.hpp`
and `.cpp` files:

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) [Year(s)], [Copyright Holder(s)].
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
```cpp
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) [Year(s)], [Copyright Holder(s)].
*
* This file is part of NFD (Named Data Networking Forwarding Daemon).
* See AUTHORS.md for complete list of NFD authors and contributors.
*
* NFD is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
```

If you are affiliated to an NSF-supported NDN project institution, please use the [NDN Team License
Boilerplate](https://redmine.named-data.net/projects/nfd/wiki/NDN_Team_License_Boilerplate_(NFD)).
Expand All @@ -45,50 +47,58 @@ have a configuration file. See `ndn-log(7)` manual page for syntax and examples

To run unit tests, NFD needs to be configured and build with unit test support:

./waf configure --with-tests # --debug is also strongly recommended while developing
./waf
```shell
./waf configure --with-tests # --debug is also strongly recommended while developing
./waf
```

The simplest way to run the tests is to launch the compiled binary without any parameters:

# Run core tests
./build/unit-tests-core
```shell
# Run core tests
./build/unit-tests-core

# Run NFD daemon tests
./build/unit-tests-daemon
# Run NFD daemon tests
./build/unit-tests-daemon

# Run NFD RIB management tests
./build/unit-tests-rib
# Run tools tests (e.g., nfdc)
./build/unit-tests-tools
```

The [Boost.Test framework](https://www.boost.org/doc/libs/1_71_0/libs/test/doc/html/index.html)
is very flexible and allows a number of run-time customization of what tests should be run.
For example, it is possible to choose to run only a specific test suite, only a specific
test case within a suite, or specific test cases within specific test suites:
test case within a suite, specific test cases across multiple test suites, and so on:

# Run only the TCP Face test suite of NFD daemon tests
./build/unit-tests-daemon -t FaceTcp
```shell
# Run only the PIT tests inside the Table test suite of NFD daemon tests
./build/unit-tests-daemon -t Table/TestPit

# Run only test case EndToEnd4 from the same test suite
./build/unit-tests-daemon -t FaceTcp/EndToEnd4
# Run only the test case "Find" from the previous test suite
./build/unit-tests-daemon -t Table/TestPit/Find

# Run Basic test case from all core test suites
./build/unit-tests-core -t */Basic
# Run the "Basic" test case from all NFD RIB test suites
./build/unit-tests-daemon -t Rib/*/Basic
```

By default, Boost.Test framework will produce verbose output only when a test case fails.
If it is desired to see verbose output (result of each test assertion), add `-l all`
option to `./build/unit-tests` command. To see test progress, you can use `-l test_suite`,
or `-p` to show a progress bar:

# Show report all log messages including the passed test notification
./build/unit-tests-daemon -l all
```shell
# Show report all log messages including the passed test notification
./build/unit-tests-daemon -l all

# Show test suite messages
./build/unit-tests-daemon -l test_suite
# Show test suite messages
./build/unit-tests-daemon -l test_suite

# Show nothing
./build/unit-tests-daemon -l nothing
# Show nothing
./build/unit-tests-daemon -l nothing

# Show progress bar
./build/unit-tests-core -p
# Show progress bar
./build/unit-tests-tools -p
```

There are many more command line options available, information about which can be obtained
either from the command line using the `--help` switch, or online on the
Expand Down
6 changes: 3 additions & 3 deletions tests/daemon/rib/fib-updates-erase-face.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
Expand Down Expand Up @@ -30,8 +30,8 @@

namespace nfd::tests {

BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestFibUpdates, FibUpdatesFixture)

BOOST_AUTO_TEST_SUITE(EraseFace)

BOOST_AUTO_TEST_CASE(WithInheritedFace_Root)
Expand Down Expand Up @@ -421,7 +421,7 @@ BOOST_AUTO_TEST_CASE(RemoveNamespaceWithCapture) // Bug #3404
}

BOOST_AUTO_TEST_SUITE_END() // EraseFace

BOOST_AUTO_TEST_SUITE_END() // FibUpdates
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
6 changes: 3 additions & 3 deletions tests/daemon/rib/fib-updates-new-face.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
Expand Down Expand Up @@ -30,8 +30,8 @@

namespace nfd::tests {

BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestFibUpdates, FibUpdatesFixture)

BOOST_AUTO_TEST_SUITE(NewFace)

BOOST_AUTO_TEST_CASE(Basic)
Expand Down Expand Up @@ -262,7 +262,7 @@ BOOST_AUTO_TEST_CASE(CaptureTurnedOnWithChildInherit)
}

BOOST_AUTO_TEST_SUITE_END() // NewFace

BOOST_AUTO_TEST_SUITE_END() // FibUpdates
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
6 changes: 3 additions & 3 deletions tests/daemon/rib/fib-updates-new-namespace.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
Expand Down Expand Up @@ -30,8 +30,8 @@

namespace nfd::tests {

BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestFibUpdates, FibUpdatesFixture)

BOOST_AUTO_TEST_SUITE(NewNamespace)

BOOST_AUTO_TEST_CASE(NoFlags)
Expand Down Expand Up @@ -190,7 +190,7 @@ BOOST_AUTO_TEST_CASE(Capture)
}

BOOST_AUTO_TEST_SUITE_END() // NewNamespace

BOOST_AUTO_TEST_SUITE_END() // FibUpdates
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
6 changes: 3 additions & 3 deletions tests/daemon/rib/fib-updates-update-face.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
Expand Down Expand Up @@ -30,8 +30,8 @@

namespace nfd::tests {

BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestFibUpdates, FibUpdatesFixture)

BOOST_AUTO_TEST_SUITE(UpdateFace)

BOOST_AUTO_TEST_CASE(TurnOffChildInheritLowerCost)
Expand Down Expand Up @@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(TurnOffCapture)
}

BOOST_AUTO_TEST_SUITE_END() // UpdateFace

BOOST_AUTO_TEST_SUITE_END() // FibUpdates
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
Expand Down Expand Up @@ -32,7 +32,7 @@ namespace nfd::tests {

using namespace nfd::rib;

BOOST_AUTO_TEST_SUITE(Readvertise)
BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestClientToNlsrReadvertisePolicy, GlobalIoFixture)

BOOST_AUTO_TEST_CASE(ReadvertiseClientRoute)
Expand Down Expand Up @@ -68,6 +68,6 @@ BOOST_AUTO_TEST_CASE(DontReadvertiseRoute)
}

BOOST_AUTO_TEST_SUITE_END() // TestClientToNlsrReadvertisePolicy
BOOST_AUTO_TEST_SUITE_END() // Readvertise
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
Expand Down Expand Up @@ -54,7 +54,7 @@ class HostToGatewayReadvertisePolicyFixture : public GlobalIoFixture, public Key
}
};

BOOST_AUTO_TEST_SUITE(Readvertise)
BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestHostToGatewayReadvertisePolicy, HostToGatewayReadvertisePolicyFixture)

BOOST_AUTO_TEST_CASE(PrefixToAdvertise)
Expand Down Expand Up @@ -105,6 +105,6 @@ BOOST_AUTO_TEST_CASE(LoadRefreshInterval)
}

BOOST_AUTO_TEST_SUITE_END() // TestHostToGatewayReadvertisePolicy
BOOST_AUTO_TEST_SUITE_END() // Readvertise
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class NfdRibReadvertiseDestinationFixture : public GlobalIoTimeFixture, public K
std::function<void(const std::string&)> failureCallback;
};

BOOST_AUTO_TEST_SUITE(Readvertise)
BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestNfdRibReadvertiseDestination, NfdRibReadvertiseDestinationFixture)

class AdvertiseSuccessScenario
Expand Down Expand Up @@ -249,6 +249,6 @@ BOOST_AUTO_TEST_CASE(DestinationAvailability)
}

BOOST_AUTO_TEST_SUITE_END() // TestNfdRibReadvertiseDestination
BOOST_AUTO_TEST_SUITE_END() // Readvertise
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
6 changes: 3 additions & 3 deletions tests/daemon/rib/readvertise/readvertise.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2023, Regents of the University of California,
* Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
Expand Down Expand Up @@ -161,7 +161,7 @@ class ReadvertiseFixture : public GlobalIoTimeFixture, public KeyChainFixture
Rib m_rib;
};

BOOST_AUTO_TEST_SUITE(Readvertise)
BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestReadvertise, ReadvertiseFixture)

BOOST_AUTO_TEST_CASE(AddRemoveRoute)
Expand Down Expand Up @@ -296,6 +296,6 @@ BOOST_AUTO_TEST_CASE(ChangeDuringRetry)
}

BOOST_AUTO_TEST_SUITE_END() // TestReadvertise
BOOST_AUTO_TEST_SUITE_END() // Readvertise
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
17 changes: 7 additions & 10 deletions tests/daemon/rib/rib-entry.t.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, Regents of the University of California,
* Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
Expand Down Expand Up @@ -33,6 +33,7 @@ namespace nfd::tests {
using rib::RibEntry;
using rib::Route;

BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestRibEntry, GlobalIoFixture)

BOOST_AUTO_TEST_CASE(Basic)
Expand Down Expand Up @@ -78,18 +79,13 @@ BOOST_AUTO_TEST_CASE(Basic)
BOOST_FIXTURE_TEST_SUITE(GetAnnouncement, GlobalIoTimeFixture)

static Route
makeSimpleRoute(uint64_t faceId)
makeSimpleRoute(uint64_t faceId, std::optional<time::nanoseconds> expiration = std::nullopt)
{
Route route;
route.faceId = faceId;
return route;
}

static Route
makeSimpleRoute(uint64_t faceId, time::nanoseconds expiration)
{
Route route = makeSimpleRoute(faceId);
route.expires = time::steady_clock::now() + expiration;
if (expiration) {
route.expires = time::steady_clock::now() + *expiration;
}
return route;
}

Expand Down Expand Up @@ -170,5 +166,6 @@ BOOST_AUTO_TEST_CASE(MakeAnnouncementShortExpiration)
BOOST_AUTO_TEST_SUITE_END() // GetAnnouncement

BOOST_AUTO_TEST_SUITE_END() // TestRibEntry
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
Loading

0 comments on commit caa60cc

Please sign in to comment.