tests: introduce unit testing
As a sample, this commit also includes a test suite for
ndn::ping::client::StatisticsCollector class.
refs #2795
Change-Id: Ia0c7522ae26bee1cc9d172c7379ab62f84325ed7
diff --git a/tools/ping/client/statistics-collector.hpp b/tools/ping/client/statistics-collector.hpp
index 685ff1f..76278db 100644
--- a/tools/ping/client/statistics-collector.hpp
+++ b/tools/ping/client/statistics-collector.hpp
@@ -64,6 +64,13 @@
StatisticsCollector(Ping& ping, const Options& options);
/**
+ * Returns ping statistics as structure
+ */
+ Statistics
+ computeStatistics();
+
+PUBLIC_WITH_TESTS_ELSE_PRIVATE:
+ /**
* Called on ping response received
* @param rtt round trip time
*/
@@ -76,12 +83,6 @@
void
recordTimeout();
- /**
- * Returns ping statistics as structure
- */
- Statistics
- computeStatistics();
-
private:
Ping& m_ping;
const Options& m_options;
diff --git a/tools/ping/wscript b/tools/ping/wscript
index 575e395..3e6755d 100644
--- a/tools/ping/wscript
+++ b/tools/ping/wscript
@@ -2,16 +2,28 @@
top = '../..'
def build(bld):
- bld.program(
- features='cxx',
- target='../../bin/ndnping',
- source=bld.path.ant_glob('client/*.cpp'),
- use='core-objects',
- )
- bld.program(
- features='cxx',
+ bld(features='cxx',
+ name='ping-client-objects',
+ source=bld.path.ant_glob('client/*.cpp', excl='client/ndn-ping.cpp'),
+ use='core-objects')
+
+ bld(features='cxx cxxprogram',
+ target='../../bin/ndnping',
+ source='client/ndn-ping.cpp',
+ use='ping-client-objects')
+
+ bld(features='cxx',
+ name='ping-server-objects',
+ source=bld.path.ant_glob('server/*.cpp', excl='server/ndn-ping-server.cpp'),
+ use='core-objects')
+
+ bld(features='cxx cxxprogram',
target='../../bin/ndnpingserver',
- source=bld.path.ant_glob('server/*.cpp'),
- use='core-objects',
- )
+ source='server/ndn-ping-server.cpp',
+ use='ping-server-objects')
+
+ ## (for unit tests)
+
+ bld(name='ping-objects',
+ use='ping-client-objects ping-server-objects')