3 # NEPI, a framework to manage network experiments
4 # Copyright (C) 2013 INRIA
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 2 as
8 # published by the Free Software Foundation;
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20 from nepi.execution.ec import ExperimentController
21 from test_utils import skipIfNotAlive, skipInteractive
28 class LinuxTcpdumpTestCase(unittest.TestCase):
30 self.fedora_host = "nepi2.pl.sophia.inria.fr"
31 self.fedora_user = "inria_nepi"
33 self.ubuntu_host = "roseval.pl.sophia.inria.fr"
34 self.ubuntu_user = "alina"
36 self.target = "nepi5.pl.sophia.inria.fr"
39 def t_tofile(self, host, user):
40 ec = ExperimentController(exp_id = "test-to-file")
42 node = ec.register_resource("linux::Node")
43 ec.set(node, "hostname", host)
44 ec.set(node, "username", user)
45 ec.set(node, "cleanExperiment", True)
46 ec.set(node, "cleanProcesses", True)
48 pcap = ec.register_resource("linux::Tcpdump")
49 ec.set(pcap, "i", "eth0")
50 ec.set(pcap, "w", "custom_output")
51 ec.register_connection(pcap, node)
53 app = ec.register_resource("linux::Ping")
54 ec.set(app, "count", "20")
55 ec.set(app, "target", self.target)
56 ec.register_connection(app, node)
62 output = ec.trace(pcap, "custom_output")
63 self.assertTrue(len(output) > 0)
67 def test_tofile_fedora(self):
68 self.t_tofile(self.fedora_host, self.fedora_user)
70 def test_tofile_ubuntu(self):
71 self.t_tofile(self.ubuntu_host, self.ubuntu_user)
73 if __name__ == '__main__':