A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
network-status-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 University of Padova
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Davide Magrin <magrinda@dei.unipd.it>
7 */
8
9/*
10 * This file includes testing for the following components:
11 * - EndDeviceStatus
12 * - GatewayStatus
13 * - NetworkStatus
14 */
15
16// Include headers of classes to test
17#include "utilities.h"
18
19#include "ns3/end-device-status.h"
20#include "ns3/log.h"
21#include "ns3/network-status.h"
22
23// An essential include is test.h
24#include "ns3/test.h"
25
26using namespace ns3;
27using namespace lorawan;
28
29NS_LOG_COMPONENT_DEFINE("NetworkStatusTestSuite");
30
31/**
32 * \ingroup lorawan
33 *
34 * It tests the constructor of the EndDeviceStatus class
35 */
37{
38 public:
39 EndDeviceStatusTest(); //!< Default constructor
40 ~EndDeviceStatusTest() override; //!< Destructor
41
42 private:
43 void DoRun() override;
44};
45
46// Add some help text to this case to describe what it is intended to test
48 : TestCase("Verify correct behavior of the EndDeviceStatus object")
49{
50}
51
52// Reminder that the test case should clean up after itself
56
57// This method is the pure virtual method from class TestCase that every
58// TestCase must implement
59void
61{
62 NS_LOG_DEBUG("EndDeviceStatusTest");
63
64 // Create an EndDeviceStatus object
66}
67
68/**
69 * \ingroup lorawan
70 *
71 * It tests the function NetworkStatus::AddNode
72 */
74{
75 public:
76 NetworkStatusTest(); //!< Default constructor
77 ~NetworkStatusTest() override; //!< Destructor
78
79 private:
80 void DoRun() override;
81};
82
83// Add some help text to this case to describe what it is intended to test
85 : TestCase("Verify correct behavior of the NetworkStatus object")
86{
87}
88
89// Reminder that the test case should clean up after itself
93
94// This method is the pure virtual method from class TestCase that every
95// TestCase must implement
96void
98{
99 NS_LOG_DEBUG("NetworkStatusTest");
100
101 // Create a NetworkStatus object
103
104 // Create a bunch of actual devices
105 NetworkComponents components = InitializeNetwork(1, 1);
106
107 Ptr<LoraChannel> channel = components.channel;
108 NodeContainer endDevices = components.endDevices;
109 NodeContainer gateways = components.gateways;
110
111 ns.AddNode(GetMacLayerFromNode<ClassAEndDeviceLorawanMac>(endDevices.Get(0)));
112}
113
114/**
115 * \ingroup lorawan
116 *
117 * The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the
118 * TestCases to be run. Typically, only the constructor for this class must be defined
119 */
121{
122 public:
123 NetworkStatusTestSuite(); //!< Default constructor
124};
125
127 : TestSuite("network-status", Type::UNIT)
128{
129 LogComponentEnable("NetworkStatusTestSuite", LOG_LEVEL_DEBUG);
130 // TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
133}
134
135// Do not forget to allocate an instance of this TestSuite
It tests the constructor of the EndDeviceStatus class.
EndDeviceStatusTest()
Default constructor.
~EndDeviceStatusTest() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
It tests the function NetworkStatus::AddNode.
NetworkStatusTest()
Default constructor.
~NetworkStatusTest() override
Destructor.
void DoRun() override
Implementation to actually run this TestCase.
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
NetworkStatusTestSuite()
Default constructor.
keep track of a set of node pointers.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Smart pointer class similar to boost::intrusive_ptr.
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
This class represents the network server's knowledge about an end device in the LoRaWAN network it is...
This class represents the knowledge about the state of the network that is available at the network s...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
NetworkComponents InitializeNetwork(int nDevices, int nGateways)
Definition utilities.cc:117
Ptr< T > GetMacLayerFromNode(Ptr< Node > n)
Definition utilities.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition log.cc:291
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
Definition log.h:102
static NetworkStatusTestSuite lorawanTestSuite
Stores the main elements of a simulated LoRaWAN network.
Definition utilities.h:29
Ptr< LoraChannel > channel
A pointer to the LoraChannel object.
Definition utilities.h:30
NodeContainer endDevices
Container of the end device nodes.
Definition utilities.h:31
NodeContainer gateways
Container of the gateway nodes.
Definition utilities.h:32