View | Details | Raw Unified | Return to bug 1027
Collapse All | Expand All

(-)a/src/contrib/topology-read/rocketfuel-topology-reader.cc (-1 / +80 lines)
 Lines 293-298    Link Here 
293
  std::istringstream lineBuffer;
293
  std::istringstream lineBuffer;
294
  std::string line;
294
  std::string line;
295
  int lineNumber = 0;
295
  int lineNumber = 0;
296
  enum RF_FileType ftype = RF_UNKNOWN;
296
  char errbuf[512];
297
  char errbuf[512];
297
298
298
  if (!topgen.is_open ())
299
  if (!topgen.is_open ())
 Lines 307-313    Link Here 
307
      int argc;
308
      int argc;
308
      char *argv[REGMATCH_MAX];
309
      char *argv[REGMATCH_MAX];
309
      char *buf;
310
      char *buf;
310
      enum RF_FileType ftype = RF_UNKNOWN;
311
311
312
      lineNumber++;
312
      lineNumber++;
313
      line.clear ();
313
      line.clear ();
 Lines 409-411    Link Here 
409
409
410
} /* namespace ns3 */
410
} /* namespace ns3 */
411
411
412
413
//-----------------------------------------------------------------------------
414
// Unit tests
415
//-----------------------------------------------------------------------------
416
417
#include "ns3/log.h"
418
#include "ns3/abort.h"
419
#include "ns3/attribute.h"
420
#include "ns3/object-factory.h"
421
#include "ns3/object-factory.h"
422
#include "ns3/simulator.h"
423
#include "ns3/test.h"
424
425
namespace ns3 {
426
427
class RocketfuelTopologyReaderTest: public TestCase 
428
{
429
public:
430
  RocketfuelTopologyReaderTest ();
431
private:
432
  virtual bool DoRun (void);
433
};
434
435
RocketfuelTopologyReaderTest::RocketfuelTopologyReaderTest ()
436
  : TestCase ("RocketfuelTopologyReaderTest") 
437
{}
438
439
440
bool
441
RocketfuelTopologyReaderTest::DoRun (void)
442
{
443
  Ptr<RocketfuelTopologyReader> inFile;
444
  NodeContainer nodes;
445
  
446
  std::string input ("./examples/topology-read/RocketFuel_toposample_1239_weights.txt");
447
448
  inFile = CreateObject<RocketfuelTopologyReader> ();
449
  inFile->SetFileName(input);
450
451
  if (inFile != 0)
452
    {
453
      nodes = inFile->Read ();
454
    }
455
456
  if (nodes.GetN () == 0)
457
    {
458
      NS_LOG_ERROR ("Problems reading node information the topology file. Failing.");
459
      return true;
460
    }
461
  if (inFile->LinksSize () == 0)
462
    {
463
      NS_LOG_ERROR ("Problems reading the topology file. Failing.");
464
      return true;
465
    }
466
  NS_LOG_INFO ("Rocketfuel topology created with " << nodes.GetN () << " nodes and " << 
467
               inFile->LinksSize () << " links (from " << input << ")");
468
469
  NS_TEST_EXPECT_MSG_EQ (nodes.GetN (),315, "noes");
470
  NS_TEST_EXPECT_MSG_EQ (inFile->LinksSize (),972, "links");
471
  Simulator::Destroy ();
472
473
  return false;
474
}
475
476
static class RocketfuelTopologyReaderTestSuite : public TestSuite
477
{
478
public:
479
  RocketfuelTopologyReaderTestSuite ();
480
private:
481
} g_rocketfueltopologyreaderTests;
482
483
RocketfuelTopologyReaderTestSuite::RocketfuelTopologyReaderTestSuite ()
484
  : TestSuite ("rocketfuel-topology-reader", UNIT)
485
{
486
  AddTestCase (new RocketfuelTopologyReaderTest ());
487
}
488
489
490
}

Return to bug 1027