akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 2 | /** |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame^] | 3 | * Copyright (c) 2014 University of Memphis, |
| 4 | * Regents of the University of California |
| 5 | * |
| 6 | * This file is part of NLSR (Named-data Link State Routing). |
| 7 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 8 | * |
| 9 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 10 | * of the GNU General Public License as published by the Free Software Foundation, |
| 11 | * either version 3 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 14 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | * \author Ashlesh Gawande <agawande@memphis.edu> |
| 21 | * |
| 22 | **/ |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 23 | #include <fstream> |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 24 | #include "conf-file-processor.hpp" |
| 25 | #include "nlsr.hpp" |
| 26 | #include <boost/test/unit_test.hpp> |
| 27 | |
| 28 | namespace nlsr { |
| 29 | |
| 30 | namespace test { |
| 31 | |
| 32 | BOOST_AUTO_TEST_SUITE(TestConfFileProcessor) |
| 33 | |
| 34 | BOOST_AUTO_TEST_CASE(ConfFileProcessorSample) |
| 35 | { |
| 36 | Nlsr nlsr1; |
| 37 | |
| 38 | const std::string CONFIG = |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 39 | "general\n" |
| 40 | "{\n" |
| 41 | " network /ndn/\n" |
| 42 | " site /memphis.edu/\n" |
| 43 | " router /cs/pollux/\n" |
| 44 | " lsa-refresh-time 1800\n" |
| 45 | " log-level INFO\n" |
| 46 | "}\n\n" |
| 47 | "neighbors\n" |
| 48 | "{\n" |
| 49 | " hello-retries 3\n" |
| 50 | " hello-time-out 1\n" |
| 51 | " hello-interval 60\n\n" |
| 52 | " neighbor\n" |
| 53 | " {\n" |
| 54 | " name /ndn/memphis.edu/cs/castor\n" |
| 55 | " face-id 15\n" |
| 56 | " link-cost 20\n" |
| 57 | " }\n\n" |
| 58 | " neighbor\n" |
| 59 | " {\n" |
| 60 | " name /ndn/memphis.edu/cs/mira\n" |
| 61 | " face-id 17\n" |
| 62 | " link-cost 30\n" |
| 63 | " }\n" |
| 64 | "}\n\n" |
| 65 | "hyperbolic\n" |
| 66 | "{\n" |
| 67 | "state off\n" |
| 68 | "radius 123.456\n" |
| 69 | "angle 1.45\n" |
| 70 | "}\n\n" |
| 71 | "fib\n" |
| 72 | "{\n" |
| 73 | " max-faces-per-prefix 3\n" |
| 74 | "}\n\n" |
| 75 | "advertising\n" |
| 76 | "{\n" |
| 77 | "prefix /ndn/edu/memphis/cs/netlab\n" |
| 78 | "prefix /ndn/edu/memphis/sports/basketball\n" |
| 79 | "}\n"; |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 80 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 81 | std::ofstream config; |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 82 | config.open("unit-test-nlsr.conf"); |
| 83 | config << CONFIG; |
| 84 | config.close(); |
| 85 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 86 | const std::string CONFIG_FILE = "unit-test-nlsr.conf"; |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 87 | |
| 88 | ConfFileProcessor cfp1(nlsr1, CONFIG_FILE); |
| 89 | |
| 90 | cfp1.processConfFile(); |
| 91 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 92 | BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/mira")); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 93 | BOOST_CHECK_EQUAL( |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 94 | nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getName(), |
| 95 | "/ndn/memphis.edu/cs/mira"); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 96 | BOOST_CHECK_EQUAL( |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 97 | nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getLinkCost(), |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 98 | 30); |
| 99 | |
| 100 | BOOST_CHECK_EQUAL(nlsr1.getNamePrefixList().getSize(), 2); |
| 101 | |
| 102 | remove("unit-test-nlsr.conf"); |
| 103 | } |
| 104 | |
| 105 | BOOST_AUTO_TEST_SUITE_END() |
| 106 | |
| 107 | } //namespace test |
| 108 | } //namespace nlsr |