utils: Doxygen updates for utils directory
This commit is contained in:
@@ -30,11 +30,16 @@
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
/// BenchHeader class
|
||||
template <int N>
|
||||
class BenchHeader : public Header
|
||||
{
|
||||
public:
|
||||
BenchHeader ();
|
||||
/**
|
||||
* Is OK function
|
||||
* \returns true if OK
|
||||
*/
|
||||
bool IsOk (void) const;
|
||||
|
||||
/**
|
||||
@@ -48,8 +53,12 @@ public:
|
||||
virtual void Serialize (Buffer::Iterator start) const;
|
||||
virtual uint32_t Deserialize (Buffer::Iterator start);
|
||||
private:
|
||||
/**
|
||||
* Get type name function
|
||||
* \returns the type name string
|
||||
*/
|
||||
static std::string GetTypeName (void);
|
||||
bool m_ok;
|
||||
bool m_ok; ///< is OK
|
||||
};
|
||||
|
||||
template <int N>
|
||||
@@ -125,10 +134,15 @@ BenchHeader<N>::Deserialize (Buffer::Iterator start)
|
||||
return N;
|
||||
}
|
||||
|
||||
/// BenchTag class
|
||||
template <int N>
|
||||
class BenchTag : public Tag
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Get the bench tag name.
|
||||
* \return the name.
|
||||
*/
|
||||
static std::string GetName (void) {
|
||||
std::ostringstream oss;
|
||||
oss << "anon::BenchTag<" << N << ">";
|
||||
|
||||
@@ -39,9 +39,15 @@ std::string g_me;
|
||||
// Output field width
|
||||
int g_fwidth = 6;
|
||||
|
||||
/// Bench class
|
||||
class Bench
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* constructor
|
||||
* \param population the population
|
||||
* \param total the total
|
||||
*/
|
||||
Bench (const uint32_t population, const uint32_t total)
|
||||
: m_population (population),
|
||||
m_total (total),
|
||||
@@ -49,29 +55,43 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Set random stream
|
||||
* \param stream the random variable stream
|
||||
*/
|
||||
void SetRandomStream (Ptr<RandomVariableStream> stream)
|
||||
{
|
||||
m_rand = stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set population function
|
||||
* \param population the population
|
||||
*/
|
||||
void SetPopulation (const uint32_t population)
|
||||
{
|
||||
m_population = population;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set total function
|
||||
* \param total
|
||||
*/
|
||||
void SetTotal (const uint32_t total)
|
||||
{
|
||||
m_total = total;
|
||||
}
|
||||
|
||||
/// Run function
|
||||
void RunBench (void);
|
||||
private:
|
||||
/// callback function
|
||||
void Cb (void);
|
||||
|
||||
Ptr<RandomVariableStream> m_rand;
|
||||
uint32_t m_population;
|
||||
uint32_t m_total;
|
||||
uint32_t m_count;
|
||||
Ptr<RandomVariableStream> m_rand; ///< random variable
|
||||
uint32_t m_population; ///< population
|
||||
uint32_t m_total; ///< total
|
||||
uint32_t m_count; ///< count
|
||||
};
|
||||
|
||||
void
|
||||
|
||||
@@ -130,31 +130,83 @@ cmt_indent_multi=False # really, do not touch them
|
||||
dst.close()
|
||||
return pathname
|
||||
|
||||
## PatchChunkLine class
|
||||
class PatchChunkLine:
|
||||
## @var __type
|
||||
# type
|
||||
## @var __line
|
||||
# line
|
||||
## @var SRC
|
||||
# Source
|
||||
SRC = 1
|
||||
## @var DST
|
||||
# Destination
|
||||
DST = 2
|
||||
## @var BOTH
|
||||
# Both
|
||||
BOTH = 3
|
||||
def __init__(self):
|
||||
"""! Initializer
|
||||
@param self The current class
|
||||
@return none
|
||||
"""
|
||||
self.__type = 0
|
||||
self.__line = ''
|
||||
def set_src(self,line):
|
||||
"""! Set source
|
||||
@param self The current class
|
||||
@param line source line
|
||||
@return none
|
||||
"""
|
||||
self.__type = self.SRC
|
||||
self.__line = line
|
||||
def set_dst(self,line):
|
||||
"""! Set destination
|
||||
@param self The current class
|
||||
@param line destination line
|
||||
@return none
|
||||
"""
|
||||
self.__type = self.DST
|
||||
self.__line = line
|
||||
def set_both(self,line):
|
||||
"""! Set both
|
||||
@param self The current class
|
||||
@param line
|
||||
@return none
|
||||
"""
|
||||
self.__type = self.BOTH
|
||||
self.__line = line
|
||||
def append_to_line(self, s):
|
||||
"""! Append to line
|
||||
@param self The current class
|
||||
@param s line to append
|
||||
@return none
|
||||
"""
|
||||
self.__line = self.__line + s
|
||||
def line(self):
|
||||
"""! Get line
|
||||
@param self The current class
|
||||
@return line
|
||||
"""
|
||||
return self.__line
|
||||
def is_src(self):
|
||||
"""! Is source
|
||||
@param self The current class
|
||||
@return true if type is source
|
||||
"""
|
||||
return self.__type == self.SRC or self.__type == self.BOTH
|
||||
def is_dst(self):
|
||||
"""! Is destination
|
||||
@param self The current class
|
||||
@return true if type is destination
|
||||
"""
|
||||
return self.__type == self.DST or self.__type == self.BOTH
|
||||
def write(self, f):
|
||||
"""! Write to file
|
||||
@param self The current class
|
||||
@param f file
|
||||
@return exception if invalid type
|
||||
"""
|
||||
if self.__type == self.SRC:
|
||||
f.write('-%s\n' % self.__line)
|
||||
elif self.__type == self.DST:
|
||||
@@ -164,55 +216,141 @@ class PatchChunkLine:
|
||||
else:
|
||||
raise Exception('invalid patch')
|
||||
|
||||
|
||||
## PatchChunk class
|
||||
class PatchChunk:
|
||||
## @var __lines
|
||||
# list of lines
|
||||
## @var __src_pos
|
||||
# source position
|
||||
## @var __dst_pos
|
||||
# destination position
|
||||
## @var src
|
||||
# source
|
||||
## @var dst
|
||||
# destination
|
||||
def __init__(self, src_pos, dst_pos):
|
||||
"""! Initializer
|
||||
@param self: this object
|
||||
@param src_pos: source position
|
||||
@param dst_pos: destination position
|
||||
@return none
|
||||
"""
|
||||
self.__lines = []
|
||||
self.__src_pos = int(src_pos)
|
||||
self.__dst_pos = int(dst_pos)
|
||||
def src_start(self):
|
||||
"""! Source start function
|
||||
@param self this object
|
||||
@return source position
|
||||
"""
|
||||
return self.__src_pos
|
||||
def add_line(self,line):
|
||||
"""! Add line function
|
||||
@param self The current class
|
||||
@param line line to add
|
||||
@return none
|
||||
"""
|
||||
self.__lines.append(line)
|
||||
def src(self):
|
||||
"""! Get source lines
|
||||
@param self The current class
|
||||
@return the source lines
|
||||
"""
|
||||
src = []
|
||||
for line in self.__lines:
|
||||
if line.is_src():
|
||||
src.append(line)
|
||||
return src
|
||||
def dst(self):
|
||||
"""! Get destination lines
|
||||
@param self The current class
|
||||
@return the destination lines
|
||||
"""
|
||||
dst = []
|
||||
for line in self.__lines:
|
||||
if line.is_dst():
|
||||
dst.append(line)
|
||||
return dst
|
||||
def src_len(self):
|
||||
"""! Get number of source lines
|
||||
@param self The current class
|
||||
@return number of source lines
|
||||
"""
|
||||
return len(self.src())
|
||||
def dst_len(self):
|
||||
"""! Get number of destinaton lines
|
||||
@param self The current class
|
||||
@return number of destination lines
|
||||
"""
|
||||
return len(self.dst())
|
||||
def write(self,f):
|
||||
"""! Write lines to file
|
||||
@param self The current class
|
||||
@param f: file to write to
|
||||
@return none
|
||||
"""
|
||||
f.write('@@ -%d,%d +%d,%d @@\n' % (self.__src_pos, self.src_len(),
|
||||
self.__dst_pos, self.dst_len()))
|
||||
for line in self.__lines:
|
||||
line.write(f)
|
||||
|
||||
## Patch class
|
||||
class Patch:
|
||||
## @var __src
|
||||
# source
|
||||
## @var __dst
|
||||
# destination
|
||||
## @var __chunks
|
||||
# chunks
|
||||
def __init__(self):
|
||||
"""! Initializer
|
||||
@param self The current class
|
||||
@return none
|
||||
"""
|
||||
self.__src = ''
|
||||
self.__dst = ''
|
||||
self.__chunks = []
|
||||
def add_chunk(self, chunk):
|
||||
"""! Add chunk
|
||||
@param self this object
|
||||
@param chunk chunk
|
||||
@return none
|
||||
"""
|
||||
self.__chunks.append(chunk)
|
||||
def chunks(self):
|
||||
"""! Get the chunks
|
||||
@param self The current class
|
||||
@return the chunks
|
||||
"""
|
||||
return self.__chunks
|
||||
def set_src(self,src):
|
||||
"""! Set source
|
||||
@param self this object
|
||||
@param src source
|
||||
@return none
|
||||
"""
|
||||
self.__src = src
|
||||
def set_dst(self,dst):
|
||||
"""! Set destination
|
||||
@param self this object
|
||||
@param dst destintion
|
||||
@return none
|
||||
"""
|
||||
self.__dst = dst
|
||||
def apply(self,filename):
|
||||
"""! Apply function
|
||||
@param self The current class
|
||||
@param filename file name
|
||||
@return none
|
||||
"""
|
||||
# XXX: not implemented
|
||||
return
|
||||
def write(self,f):
|
||||
"""! Write to file
|
||||
@param self The current class
|
||||
@param f the file
|
||||
@return none
|
||||
"""
|
||||
f.write('--- %s\n' % self.__src )
|
||||
f.write('+++ %s\n' % self.__dst )
|
||||
for chunk in self.__chunks:
|
||||
|
||||
644
utils/grid.py
644
utils/grid.py
File diff suppressed because it is too large
Load Diff
@@ -674,7 +674,7 @@ PrintAttributeValueSection (std::ostream & os,
|
||||
/**
|
||||
* Print the AttributeValue documentation for a class.
|
||||
*
|
||||
* This will print documentation for the \p <name>Value class and methods.
|
||||
* This will print documentation for the \p AttributeValue class and methods.
|
||||
*
|
||||
* \param [in,out] os The output stream.
|
||||
* \param [in] name The token to use in defining the accessor name.
|
||||
@@ -1248,8 +1248,8 @@ StaticInformation::DoGather (TypeId tid)
|
||||
} // StaticInformation::DoGather ()
|
||||
|
||||
|
||||
StaticInformation
|
||||
GetTypicalAggregations ()
|
||||
/// GetTypicalAggregations function
|
||||
StaticInformation GetTypicalAggregations ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
// The below statements register typical aggregation relationships
|
||||
@@ -1297,13 +1297,18 @@ GetTypicalAggregations ()
|
||||
} // GetTypicalAggregations ()
|
||||
|
||||
|
||||
// Map from TypeId name to tid
|
||||
/// Map from TypeId name to tid
|
||||
typedef std::map< std::string, int32_t> NameMap;
|
||||
typedef NameMap::const_iterator NameMapIterator;
|
||||
typedef NameMap::const_iterator NameMapIterator; ///< NameMap iterator
|
||||
|
||||
|
||||
// Create a map from the class names to their index in the vector of
|
||||
// TypeId's so that the names will end up in alphabetical order.
|
||||
/**
|
||||
* Create a map from the class names to their index in the vector of
|
||||
* TypeId's so that the names will end up in alphabetical order.
|
||||
*
|
||||
* \param info type names withut type ids
|
||||
* \returns NameMap
|
||||
*/
|
||||
NameMap
|
||||
GetNameMap (const StaticInformation & info)
|
||||
{
|
||||
@@ -1344,6 +1349,12 @@ GetNameMap (const StaticInformation & info)
|
||||
} // GetNameMap ()
|
||||
|
||||
|
||||
/**
|
||||
* Print config paths
|
||||
* \param os the output stream
|
||||
* \param info the information
|
||||
* \param tid the type ID
|
||||
*/
|
||||
void
|
||||
PrintConfigPaths (std::ostream & os, const StaticInformation & info,
|
||||
const TypeId tid)
|
||||
|
||||
@@ -8,10 +8,27 @@ import ns.csma
|
||||
import ns.applications
|
||||
|
||||
|
||||
## TestSimulator class
|
||||
class TestSimulator(unittest.TestCase):
|
||||
## @var _received_packet
|
||||
# received packet
|
||||
## @var _args_received
|
||||
# args
|
||||
## @var _cb_time
|
||||
# current time
|
||||
## @var _context_received
|
||||
# context
|
||||
|
||||
def testScheduleNow(self):
|
||||
"""! Test schedule now
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
def callback(args):
|
||||
"""! Callback function
|
||||
@param args arguments
|
||||
return none
|
||||
"""
|
||||
self._args_received = args
|
||||
self._cb_time = Simulator.Now()
|
||||
Simulator.Destroy()
|
||||
@@ -23,7 +40,15 @@ class TestSimulator(unittest.TestCase):
|
||||
self.assertEqual(self._cb_time.GetSeconds(), 0.0)
|
||||
|
||||
def testSchedule(self):
|
||||
"""! Test schedule
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
def callback(args):
|
||||
"""! Callback function
|
||||
@param args arguments
|
||||
@return none
|
||||
"""
|
||||
self._args_received = args
|
||||
self._cb_time = Simulator.Now()
|
||||
Simulator.Destroy()
|
||||
@@ -35,7 +60,15 @@ class TestSimulator(unittest.TestCase):
|
||||
self.assertEqual(self._cb_time.GetSeconds(), 123.0)
|
||||
|
||||
def testScheduleDestroy(self):
|
||||
"""! Test schedule destroy
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
def callback(args):
|
||||
"""! Callback function
|
||||
@param args
|
||||
@return none
|
||||
"""
|
||||
self._args_received = args
|
||||
self._cb_time = Simulator.Now()
|
||||
Simulator.Destroy()
|
||||
@@ -50,7 +83,16 @@ class TestSimulator(unittest.TestCase):
|
||||
self.assertEqual(self._cb_time.GetSeconds(), 123.0)
|
||||
|
||||
def testScheduleWithContext(self):
|
||||
"""! Test schedule with context
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
def callback(context, args):
|
||||
"""! Callback
|
||||
@param context the cntet
|
||||
@param args the arguments
|
||||
@return none
|
||||
"""
|
||||
self._context_received = context
|
||||
self._args_received = args
|
||||
self._cb_time = Simulator.Now()
|
||||
@@ -65,6 +107,10 @@ class TestSimulator(unittest.TestCase):
|
||||
self.assertEqual(self._cb_time.GetSeconds(), 123.0)
|
||||
|
||||
def testTimeComparison(self):
|
||||
"""! Test time comparison
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
self.assert_(Seconds(123) == Seconds(123))
|
||||
self.assert_(Seconds(123) >= Seconds(123))
|
||||
self.assert_(Seconds(123) <= Seconds(123))
|
||||
@@ -72,6 +118,10 @@ class TestSimulator(unittest.TestCase):
|
||||
self.assert_(Seconds(123) < Seconds(124))
|
||||
|
||||
def testTimeNumericOperations(self):
|
||||
"""! Test numeric operations
|
||||
@param self ths object
|
||||
@return none
|
||||
"""
|
||||
self.assertEqual(Seconds(10) + Seconds(5), Seconds(15))
|
||||
self.assertEqual(Seconds(10) - Seconds(5), Seconds(5))
|
||||
|
||||
@@ -79,16 +129,28 @@ class TestSimulator(unittest.TestCase):
|
||||
self.assertEqual(v1, int64x64_t(50))
|
||||
|
||||
def testConfig(self):
|
||||
"""! Test configuration
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
Config.SetDefault("ns3::OnOffApplication::PacketSize", ns.core.UintegerValue(123))
|
||||
# hm.. no Config.Get?
|
||||
|
||||
def testSocket(self):
|
||||
"""! Test socket
|
||||
@param self
|
||||
@return none
|
||||
"""
|
||||
node = ns.network.Node()
|
||||
internet = ns.internet.InternetStackHelper()
|
||||
internet.Install(node)
|
||||
self._received_packet = None
|
||||
|
||||
def rx_callback(socket):
|
||||
"""! Receive Callback
|
||||
@param socket the socket to receive
|
||||
@return none
|
||||
"""
|
||||
assert self._received_packet is None
|
||||
self._received_packet = socket.Recv()
|
||||
|
||||
@@ -105,6 +167,10 @@ class TestSimulator(unittest.TestCase):
|
||||
|
||||
|
||||
def testAttributes(self):
|
||||
"""! Test attributes function
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
##
|
||||
## Yes, I know, the GetAttribute interface for Python is
|
||||
## horrible, we should fix this soon, I hope.
|
||||
@@ -131,6 +197,10 @@ class TestSimulator(unittest.TestCase):
|
||||
self.assert_(ptr.GetObject() is not None)
|
||||
|
||||
def testIdentity(self):
|
||||
"""! Test identify
|
||||
@param self thsi object
|
||||
@return none
|
||||
"""
|
||||
csma = ns.csma.CsmaNetDevice()
|
||||
channel = ns.csma.CsmaChannel()
|
||||
csma.Attach(channel)
|
||||
@@ -141,12 +211,20 @@ class TestSimulator(unittest.TestCase):
|
||||
self.assert_(c1 is c2)
|
||||
|
||||
def testTypeId(self):
|
||||
"""! Test type ID
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
typeId1 = ns.core.TypeId.LookupByNameFailSafe("ns3::UdpSocketFactory")
|
||||
self.assertEqual(typeId1.GetName (), "ns3::UdpSocketFactory")
|
||||
|
||||
self.assertRaises(KeyError, ns.core.TypeId.LookupByNameFailSafe, "__InvalidTypeName__")
|
||||
|
||||
def testCommandLine(self):
|
||||
"""! Test command line
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
cmd = ns.core.CommandLine()
|
||||
cmd.AddValue("Test1", "this is a test option")
|
||||
cmd.AddValue("Test2", "this is a test option")
|
||||
@@ -168,8 +246,17 @@ class TestSimulator(unittest.TestCase):
|
||||
self.assertEqual(foo.test_foo, "xpto")
|
||||
|
||||
def testSubclass(self):
|
||||
"""! Test subclass
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
## MyNode class
|
||||
class MyNode(ns.network.Node):
|
||||
def __init__(self):
|
||||
"""! Initializer
|
||||
@param self this object
|
||||
@return none
|
||||
"""
|
||||
super(MyNode, self).__init__()
|
||||
|
||||
node = MyNode()
|
||||
|
||||
@@ -49,14 +49,28 @@ def set_workdir():
|
||||
print('Error: Invalid working directory')
|
||||
sys.exit(1)
|
||||
|
||||
## TestBaseClass class
|
||||
class TestBaseClass:
|
||||
"""
|
||||
Generic class for testing tools based on provided commands and test cases.
|
||||
"""
|
||||
## @var my_env
|
||||
# os environment
|
||||
## @var mode
|
||||
# mode
|
||||
## @var outfile
|
||||
# output file
|
||||
## @var options
|
||||
# options
|
||||
|
||||
def __init__(self, argv, desc, mode):
|
||||
"""
|
||||
"""!
|
||||
Provide input argument list, description and mode of the suite being executed.
|
||||
@param self this object
|
||||
@param argv argument list
|
||||
@param desc description
|
||||
@param mode test mode
|
||||
@return none
|
||||
"""
|
||||
self.my_env = os.environ
|
||||
set_workdir()
|
||||
@@ -66,8 +80,12 @@ class TestBaseClass:
|
||||
self.options = self.parseargs(argv , desc)
|
||||
|
||||
def parseargs(self, argv, desc):
|
||||
"""
|
||||
"""!
|
||||
Parses the commandline arguments
|
||||
@param self this object
|
||||
@param argv argument list
|
||||
@param desc description
|
||||
@return command line arguments
|
||||
"""
|
||||
parser = argparse.ArgumentParser(description = desc)
|
||||
parser.add_argument('-f', '--file', action='store', dest='out_file', default = self.outfile,
|
||||
@@ -82,14 +100,19 @@ class TestBaseClass:
|
||||
return parser.parse_args(argv)
|
||||
|
||||
def override_cmds(self):
|
||||
"""
|
||||
"""!
|
||||
Can be used by importing suite to handle custom commands
|
||||
@param self this object
|
||||
@return custom commands
|
||||
"""
|
||||
return self.options.custcmd
|
||||
|
||||
def runtests(self, cmds):
|
||||
"""
|
||||
"""!
|
||||
Execute the tests.
|
||||
@param self this object
|
||||
@param cmds test commands
|
||||
@return error code
|
||||
"""
|
||||
if self.options.cmds:
|
||||
print_cmds(cmds)
|
||||
|
||||
Reference in New Issue
Block a user