# 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
self.netblock = "192.168.1"
@skipIfNotAlive
- def t_tun_create(self, host, user, identity):
+ def t_tun_create(self, host, user=None, identity=None):
- ec = ExperimentController(exp_id = "test-tun-create")
+ ec = ExperimentController(exp_id="test-tun-create")
- node = ec.register_resource("LinuxNode")
+ node = ec.register_resource("linux::Node")
ec.set(node, "hostname", host)
- ec.set(node, "username", user)
- ec.set(node, "identity", identity)
- ec.set(node, "cleanHome", True)
+
+ if host != "localhost":
+ ec.set(node, "username", user)
+ ec.set(node, "identity", identity)
+
+ ec.set(node, "cleanExperiment", True)
ec.set(node, "cleanProcesses", True)
- tun = ec.register_resource("LinuxTun")
- ec.set(tun, "endpoint_ip", "%s.1" % self.netblock)
- ec.set(tun, "endpoint_prefix", 24)
+ tun = ec.register_resource("linux::Tun")
+ ec.set(tun, "ip", "%s.1" % self.netblock)
+ ec.set(tun, "prefix", "24")
ec.register_connection(tun, node)
- app = ec.register_resource("LinuxApplication")
+ app = ec.register_resource("linux::Application")
cmd = "ping -c3 %s.1" % self.netblock
ec.set(app, "command", cmd)
ec.register_connection(app, node)
ec.wait_finished(app)
- ping = ec.trace(app, 'stdout')
+ ping = ec.trace(app, "stdout")
expected = """3 packets transmitted, 3 received, 0% packet loss"""
self.assertTrue(ping.find(expected) > -1)
def test_tun_create(self):
self.t_tun_create(self.host, self.user, self.identity)
+ def test_tun_create_local(self):
+ self.t_tun_create("localhost")
+
+
if __name__ == '__main__':
unittest.main()