summaryrefslogtreecommitdiffstats
path: root/testing/talos/tests/test_xrestop.py
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/talos/tests/test_xrestop.py
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/talos/tests/test_xrestop.py')
-rwxr-xr-xtesting/talos/tests/test_xrestop.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/testing/talos/tests/test_xrestop.py b/testing/talos/tests/test_xrestop.py
new file mode 100755
index 000000000..1e0ed32aa
--- /dev/null
+++ b/testing/talos/tests/test_xrestop.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+
+"""
+Tests for talos.xrestop
+"""
+
+import os
+import subprocess
+import unittest
+from talos.cmanager_linux import xrestop
+
+here = os.path.dirname(os.path.abspath(__file__))
+xrestop_output = os.path.join(here, 'xrestop_output.txt')
+
+
+class TestXrestop(unittest.TestCase):
+
+ def test_parsing(self):
+ """test parsing xrestop output from xrestop_output.txt"""
+
+ class MockPopen(object):
+ """
+ stub class for subprocess.Popen
+ We mock this to return a local static copy of xrestop output
+ This has the unfortunate nature of depending on implementation
+ details.
+ """
+ def __init__(self, *args, **kwargs):
+ self.returncode = 0
+
+ def communicate(self):
+ stdout = open(xrestop_output).read()
+ return stdout, ''
+
+ # monkey-patch subprocess.Popen
+ Popen = subprocess.Popen
+ subprocess.Popen = MockPopen
+
+ # get the output
+ output = xrestop()
+
+ # ensure that the parsed output is equal to what is in
+ # xrestop_output.txt
+ self.assertEqual(len(output), 7) # seven windows with PIDs
+
+ # the first window is Thunderbird
+ pid = 2035 # thundrbird's pid
+ self.assertTrue(pid in output)
+ thunderbird = output[pid]
+ self.assertEqual(thunderbird['index'], 0)
+ self.assertEqual(thunderbird['total bytes'], '~4728761')
+
+ # PID=1668 is a Terminal
+ pid = 1668
+ self.assertTrue(pid in output)
+ terminal = output[pid]
+ self.assertEqual(terminal['pixmap bytes'], '1943716')
+
+ # cleanup: set subprocess.Popen back
+ subprocess.Popen = Popen
+
+if __name__ == '__main__':
+ unittest.main()