localhop-scenario-test: Add test case for localhop scenario
Refs: #1386
Change-Id: I3fdf47350abfeca9a39bb35abb78587f8d2fc902
diff --git a/test_localhop/test_localhop.py b/test_localhop/test_localhop.py
new file mode 100644
index 0000000..f4d56f5
--- /dev/null
+++ b/test_localhop/test_localhop.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python2
+# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+#
+# Copyright (C) 2014 University of Arizona
+# Author: Yi Huang <ltr120@email.arizona.edu>
+# See COPYING for copyright and distribution information.
+#
+
+import os
+import unittest
+import subprocess
+
+class test_localhop(unittest.TestCase):
+ """Test case for testing /localhop"""
+
+ def setUp(self):
+ print "\nTesting /localhop"
+ print "*****************"
+ os.chdir("test_localhop")
+
+ def tearDown(self):
+ print "*****************"
+ os.chdir("..")
+
+ def test_localhost_scope(self):
+ ret = subprocess.call(["./localhop-test.sh"], shell=True)
+ print "Test script return value:", ret
+ errormsg = {
+ 1 : "Invalid command line arguments",
+ 2 : "Fail to add nexthop of ndn:/localhop",
+ 3 : "Interest with name ndn:/localhop/test-localhop/A/1 was received on host C",
+ 4 : "ndn:/localhop/test-localhop/A/1 is answered.",
+ 5 : "ndn:/localhop/test-localhop/B/1 is not correctly answered.",
+ }
+ if (ret != 0):
+ self.fail(errormsg[ret])