tests: Add unit tests framework

Change-Id: I962cc634aa21cd81265a6c68990049c87b99c2d3
Refs: #2369
diff --git a/tests/boost-test.hpp b/tests/boost-test.hpp
new file mode 100644
index 0000000..e5ecbd5
--- /dev/null
+++ b/tests/boost-test.hpp
@@ -0,0 +1,31 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM 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.
+ *
+ * ndnSIM 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
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#ifndef NDN_TESTS_BOOST_TEST_HPP
+#define NDN_TESTS_BOOST_TEST_HPP
+
+// suppress warnings from Boost.Test
+#pragma GCC system_header
+#pragma clang system_header
+
+#include <boost/test/unit_test.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/test/output_test_stream.hpp>
+
+#endif // NDN_TESTS_BOOST_TEST_HPP
diff --git a/tests/main.cpp b/tests/main.cpp
new file mode 100644
index 0000000..1a2923f
--- /dev/null
+++ b/tests/main.cpp
@@ -0,0 +1,23 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM 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.
+ *
+ * ndnSIM 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
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#define BOOST_TEST_MAIN 1
+#define BOOST_TEST_DYN_LINK 1
+
+#include "boost-test.hpp"
diff --git a/tests/ndn-test.cpp b/tests/other/ndn-test.cpp
similarity index 100%
rename from tests/ndn-test.cpp
rename to tests/other/ndn-test.cpp
diff --git a/tests/ndn-test.sh b/tests/other/ndn-test.sh
similarity index 100%
rename from tests/ndn-test.sh
rename to tests/other/ndn-test.sh
diff --git a/tests/unit-tests/README.md b/tests/unit-tests/README.md
new file mode 100644
index 0000000..da9436a
--- /dev/null
+++ b/tests/unit-tests/README.md
@@ -0,0 +1,22 @@
+ndnSIM unit tests
+=================
+
+ndnSIM uses [Boost Unit Test Framework](http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/index.html)
+for testing features of the implementation.
+
+ndnSIM unit tests should be placed into `ndnSIM/tests/unit-tests/` folder.  All `.cpp` files placed
+in this folder will be automatically compiled together.
+
+Running unit-tests
+------------------
+
+To run unit tests, NS-3 and ndnSIM need to be configured and build with the unit test support.  To
+enable both general NS-3 unit tests and ndnSIM unit tests, add `--enable-tests` during configuration
+phase.  For example, run the following from the NS-3 root folder:
+
+    ./waf configure --enable-tests
+    ./waf build
+
+To run unit tests:
+
+    ./waf --run ndnSIM-unit-tests
diff --git a/tests/wscript b/tests/wscript
index 00a1780..3a565d8 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -1,13 +1,18 @@
 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
 
-from waflib import Utils, Logs
-
 def build(bld):
-    # This may be necessary for visualizer to work
+    # To allow  tests to use features from all enabled modules
     all_modules = [mod[len("ns3-"):] for mod in bld.env['NS3_ENABLED_MODULES']]
 
-    for i in bld.path.ant_glob(['*.cpp']):
+    # Unit tests
+    tests = bld.create_ns3_program('ndnSIM-unit-tests', all_modules)
+    tests.source = bld.path.ant_glob(['main.cpp', 'unit-tests/**/*.cpp'])
+    tests.includes = ['#', '.', '../NFD/', "../NFD/daemon", "../NFD/core", "../helper", "../model", "../apps", "../utils", "../examples"]
+
+    # Other tests
+    for i in bld.path.ant_glob(['other/*.cpp']):
         name = str(i)[:-len(".cpp")]
         obj = bld.create_ns3_program(name, all_modules)
         obj.source = [i] + bld.path.ant_glob(['%s/**/*.cpp' % name])
         obj.install_path = None
+