Adding DCE/ns-3 serialization tests
[nepi.git] / test / util / plot.py
1 #!/usr/bin/env python
2 #
3 #    NEPI, a framework to manage network experiments
4 #    Copyright (C) 2013 INRIA
5 #
6 #    This program is free software: you can redistribute it and/or modify
7 #    it under the terms of the GNU General Public License as published by
8 #    the Free Software Foundation, either version 3 of the License, or
9 #    (at your option) any later version.
10 #
11 #    This program is distributed in the hope that it will be useful,
12 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #    GNU General Public License for more details.
15 #
16 #    You should have received a copy of the GNU General Public License
17 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19 # Author: Alina Quereilhac <alina.quereilhac@inria.fr>
20
21
22 from nepi.design.box import Box 
23 from nepi.util.plot import Plotter
24
25 import subprocess
26 import unittest
27
28 class BoxPlotTestCase(unittest.TestCase):
29     def xtest_plot(self):
30         """ XXX: This test is interactive, it will open an evince instance,
31         so it should not run automatically """
32         node1 = Box(label="node1")
33         ping1 = Box(label="ping")
34         mobility1 = Box(label="mob1")
35         node2 = Box(label="node2")
36         mobility2 = Box(label="mob2")
37         iface1 = Box(label="iface1")
38         iface2 = Box(label="iface2")
39         channel = Box(label="chan")
40
41         node1.connect(ping1)
42         node1.connect(mobility1)
43         node1.connect(iface1)
44         channel.connect(iface1)
45         channel.connect(iface2)
46         node2.connect(iface2)
47         node2.connect(mobility2)
48
49         plotter = Plotter(node1)
50         fname = plotter.plot()
51         subprocess.call(["dot", "-Tps", fname, "-o", "%s.ps"%fname])
52         subprocess.call(["evince","%s.ps"%fname])
53        
54 if __name__ == '__main__':
55     unittest.main()
56