Yi Huang | 3d23067 | 2014-04-26 04:25:24 -0700 | [diff] [blame] | 1 | #!/usr/bin/python2 |
| 2 | # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 3 | # |
| 4 | # Copyright (C) 2014 University of Arizona |
| 5 | # Author: Yi Huang <ltr120@email.arizona.edu> |
| 6 | # See COPYING for copyright and distribution information. |
| 7 | # |
| 8 | |
| 9 | import os |
| 10 | import unittest |
| 11 | import subprocess |
| 12 | |
| 13 | class test_interest_loop(unittest.TestCase): |
| 14 | """Test case for Interest loop scenario""" |
| 15 | |
| 16 | errormsg = { |
| 17 | 1 : "Counter for incoming interest is greater than 200.", |
| 18 | 2 : "Counter for outgoing interest is greater than 200.", |
Eric Newberry | 4aeadeb | 2015-06-23 21:21:12 -0700 | [diff] [blame] | 19 | 3 : "add-nexthop failed", |
| 20 | 4 : "nfd-status failed", |
Yi Huang | 3d23067 | 2014-04-26 04:25:24 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | def setUp(self): |
| 24 | print "\nTesting Interest loop scenario" |
| 25 | print "******************************" |
| 26 | os.chdir("test_interest_loop") |
| 27 | |
| 28 | def tearDown(self): |
| 29 | print "******************************" |
| 30 | os.chdir("..") |
| 31 | |
| 32 | def test_broadcast(self): |
| 33 | print ">>> Testing with Broadcast Strategy <<<" |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 34 | ret = subprocess.call(["./interest-loop-test.sh ndn:/localhost/nfd/strategy/broadcast broadcast"], shell=True) |
Yi Huang | 3d23067 | 2014-04-26 04:25:24 -0700 | [diff] [blame] | 35 | print "Test script return value:", ret |
| 36 | if ret != 0: |
| 37 | self.fail(self.errormsg[ret]) |
| 38 | |
| 39 | def test_best_route(self): |
| 40 | print ">>> Testing with Best-route Strategy <<<" |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 41 | ret = subprocess.call(["./interest-loop-test.sh ndn:/localhost/nfd/strategy/best-route best-route"], shell=True) |
Yi Huang | 3d23067 | 2014-04-26 04:25:24 -0700 | [diff] [blame] | 42 | print "Test script return value:", ret |
| 43 | if ret != 0: |
| 44 | self.fail(self.errormsg[ret]) |
| 45 | |
| 46 | def test_client_control(self): |
| 47 | print ">>> Testing with Client Control Strategy <<<" |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 48 | ret = subprocess.call(["./interest-loop-test.sh ndn:/localhost/nfd/strategy/client-control client-control"], shell=True) |
Yi Huang | 3d23067 | 2014-04-26 04:25:24 -0700 | [diff] [blame] | 49 | print "Test script return value:", ret |
| 50 | if ret != 0: |
| 51 | self.fail(self.errormsg[ret]) |
| 52 | |
| 53 | def test_ncc(self): |
| 54 | print ">>> Testing with NCC Strategy <<<" |
Eric Newberry | 6fc8822 | 2015-06-19 10:43:24 -0700 | [diff] [blame] | 55 | ret = subprocess.call(["./interest-loop-test.sh ndn:/localhost/nfd/strategy/ncc ncc"], shell=True) |
Yi Huang | 3d23067 | 2014-04-26 04:25:24 -0700 | [diff] [blame] | 56 | print "Test script return value:", ret |
| 57 | if ret != 0: |
| 58 | self.fail(self.errormsg[ret]) |