use print() - import print_function - should be fine for both py2 and py3
[nepi.git] / test / resources / linux / netns / netnsemulation.py
old mode 100644 (file)
new mode 100755 (executable)
index d6d0b44..48186b8
@@ -4,9 +4,8 @@
 #    Copyright (C) 2013 INRIA
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
-#    (at your option) any later version.
+#    it under the terms of the GNU General Public License version 2 as
+#    published by the Free Software Foundation;
 #
 #    This program is distributed in the hope that it will be useful,
 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
 #
 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
 
+from __future__ import print_function
+
 from nepi.execution.ec import ExperimentController 
 from nepi.execution.trace import TraceAttr
 
-from test_utils import skipIfNotAlive
+from test_utils import skipIfNotAlive, skipIf
 
 import os
 import time
@@ -39,8 +40,8 @@ def add_node(ec, emu, addr, prefix):
     ec.set(ip, "prefix", prefix)
     ec.register_connection(ip, iface)
 
-    print ec.get(ip, "ip"), addr
-    print ec.get(ip, "prefix"), prefix
+    print(ec.get(ip, "ip"), addr)
+    print(ec.get(ip, "prefix"), prefix)
 
     return node, iface
 
@@ -51,10 +52,11 @@ class LinuxNetNSEmulationTest(unittest.TestCase):
         self.fedora_identity = "%s/.ssh/id_rsa" % (os.environ['HOME'])
 
     @skipIfNotAlive
+    @skipIf(os.getuid() != 0, "Test requires root privileges")
     def t_ping(self, host, user = None, identity = None):
         ec = ExperimentController(exp_id = "test-netns-p2p-ping")
         
-        node = ec.register_resource("LinuxNode")
+        node = ec.register_resource("linux::Node")
         if host == "localhost":
             ec.set(node, "hostname", "localhost")
         else:
@@ -65,7 +67,7 @@ class LinuxNetNSEmulationTest(unittest.TestCase):
         ec.set(node, "cleanProcesses", True)
         #ec.set(node, "cleanHome", True)
 
-        emu = ec.register_resource("LinuxNetNSEmulation")
+        emu = ec.register_resource("linux::netns::Emulation")
         ec.set(emu, "verbose", True)
         ec.register_connection(emu, node)
 
@@ -77,7 +79,7 @@ class LinuxNetNSEmulationTest(unittest.TestCase):
         ec.register_connection(iface2, switch)
  
         ping = ec.register_resource("netns::Application")
-        ec.set(ping, "command", "10.0.0.2")
+        ec.set(ping, "command", "ping -c20 10.0.0.2")
         ec.register_connection(ping, netnode1)
 
         ec.deploy()