summaryrefslogtreecommitdiffstats
path: root/testing/talos/tests
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
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')
-rw-r--r--testing/talos/tests/__init__.py0
-rw-r--r--testing/talos/tests/browser_output.ts.txt8
-rw-r--r--testing/talos/tests/browser_output.tsvg.txt214
-rw-r--r--testing/talos/tests/ps-Acj.out44
-rw-r--r--testing/talos/tests/test_browser_output.py190
-rwxr-xr-xtesting/talos/tests/test_filter.py78
-rwxr-xr-xtesting/talos/tests/test_results.py79
-rw-r--r--testing/talos/tests/test_talosconfig.py155
-rw-r--r--testing/talos/tests/test_talosconfig_browser_config.json1
-rw-r--r--testing/talos/tests/test_talosconfig_test_config.json1
-rwxr-xr-xtesting/talos/tests/test_urlsplit.py53
-rw-r--r--testing/talos/tests/test_utils.py40
-rwxr-xr-xtesting/talos/tests/test_xrestop.py63
-rw-r--r--testing/talos/tests/xrestop_output.txt224
14 files changed, 1150 insertions, 0 deletions
diff --git a/testing/talos/tests/__init__.py b/testing/talos/tests/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/testing/talos/tests/__init__.py
diff --git a/testing/talos/tests/browser_output.ts.txt b/testing/talos/tests/browser_output.ts.txt
new file mode 100644
index 000000000..90b59744d
--- /dev/null
+++ b/testing/talos/tests/browser_output.ts.txt
@@ -0,0 +1,8 @@
+__start_report392__end_report
+
+Failed to load native module at path '/home/jhammel/firefox/components/libmozgnome.so': (80004005) libnotify.so.1: cannot open shared object file: No such file or directory
+Could not read chrome manifest 'file:///home/jhammel/firefox/extensions/%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D/chrome.manifest'.
+[JavaScript Warning: "Use of enablePrivilege is deprecated. Please use code that runs with the system principal (e.g. an extension) instead." {file: "http://localhost:15707/startup_test/startup_test.html?begin=1333663595557" line: 0}]
+__startTimestamp1333663595953__endTimestamp
+__startBeforeLaunchTimestamp1333663595557__endBeforeLaunchTimestamp
+__startAfterTerminationTimestamp1333663596551__endAfterTerminationTimestamp
diff --git a/testing/talos/tests/browser_output.tsvg.txt b/testing/talos/tests/browser_output.tsvg.txt
new file mode 100644
index 000000000..f220f8627
--- /dev/null
+++ b/testing/talos/tests/browser_output.tsvg.txt
@@ -0,0 +1,214 @@
+RSS: Main: 54116352
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/gearflowers.svg (next: http://localhost:15707/page_load_test/svg/composite-scale.svg)
+RSS: Main: 57442304
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/composite-scale.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg)
+RSS: Main: 57868288
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg)
+RSS: Main: 57880576
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg)
+RSS: Main: 58232832
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg (next: http://localhost:15707/page_load_test/svg/hixie-001.xml)
+RSS: Main: 56283136
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/hixie-001.xml (next: http://localhost:15707/page_load_test/svg/hixie-002.xml)
+RSS: Main: 58114048
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/hixie-002.xml (next: http://localhost:15707/page_load_test/svg/hixie-003.xml)
+RSS: Main: 55123968
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/hixie-003.xml (next: http://localhost:15707/page_load_test/svg/hixie-004.xml)
+RSS: Main: 57470976
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/hixie-004.xml (next: http://localhost:15707/page_load_test/svg/hixie-005.xml)
+RSS: Main: 57995264
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/hixie-005.xml (next: http://localhost:15707/page_load_test/svg/hixie-006.xml)
+RSS: Main: 58552320
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/hixie-006.xml (next: http://localhost:15707/page_load_test/svg/hixie-007.xml)
+RSS: Main: 58793984
+
+Cycle 1(1): loaded http://localhost:15707/page_load_test/svg/hixie-007.xml (next: http://localhost:15707/page_load_test/svg/gearflowers.svg)
+RSS: Main: 59756544
+
+RSS: Main: 59756544
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/gearflowers.svg (next: http://localhost:15707/page_load_test/svg/composite-scale.svg)
+RSS: Main: 61984768
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/composite-scale.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg)
+RSS: Main: 62033920
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg)
+RSS: Main: 62033920
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg)
+RSS: Main: 62058496
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg (next: http://localhost:15707/page_load_test/svg/hixie-001.xml)
+RSS: Main: 59916288
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/hixie-001.xml (next: http://localhost:15707/page_load_test/svg/hixie-002.xml)
+RSS: Main: 58867712
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/hixie-002.xml (next: http://localhost:15707/page_load_test/svg/hixie-003.xml)
+RSS: Main: 58101760
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/hixie-003.xml (next: http://localhost:15707/page_load_test/svg/hixie-004.xml)
+RSS: Main: 58953728
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/hixie-004.xml (next: http://localhost:15707/page_load_test/svg/hixie-005.xml)
+RSS: Main: 59559936
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/hixie-005.xml (next: http://localhost:15707/page_load_test/svg/hixie-006.xml)
+RSS: Main: 58613760
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/hixie-006.xml (next: http://localhost:15707/page_load_test/svg/hixie-007.xml)
+RSS: Main: 58822656
+
+Cycle 2(1): loaded http://localhost:15707/page_load_test/svg/hixie-007.xml (next: http://localhost:15707/page_load_test/svg/gearflowers.svg)
+RSS: Main: 61407232
+
+RSS: Main: 61407232
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/gearflowers.svg (next: http://localhost:15707/page_load_test/svg/composite-scale.svg)
+RSS: Main: 62328832
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/composite-scale.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg)
+RSS: Main: 62447616
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg)
+RSS: Main: 62382080
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg)
+RSS: Main: 62398464
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg (next: http://localhost:15707/page_load_test/svg/hixie-001.xml)
+RSS: Main: 60207104
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/hixie-001.xml (next: http://localhost:15707/page_load_test/svg/hixie-002.xml)
+RSS: Main: 59191296
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/hixie-002.xml (next: http://localhost:15707/page_load_test/svg/hixie-003.xml)
+RSS: Main: 59179008
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/hixie-003.xml (next: http://localhost:15707/page_load_test/svg/hixie-004.xml)
+RSS: Main: 59752448
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/hixie-004.xml (next: http://localhost:15707/page_load_test/svg/hixie-005.xml)
+RSS: Main: 59912192
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/hixie-005.xml (next: http://localhost:15707/page_load_test/svg/hixie-006.xml)
+RSS: Main: 58626048
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/hixie-006.xml (next: http://localhost:15707/page_load_test/svg/hixie-007.xml)
+RSS: Main: 59596800
+
+Cycle 3(1): loaded http://localhost:15707/page_load_test/svg/hixie-007.xml (next: http://localhost:15707/page_load_test/svg/gearflowers.svg)
+RSS: Main: 61300736
+
+RSS: Main: 61300736
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/gearflowers.svg (next: http://localhost:15707/page_load_test/svg/composite-scale.svg)
+RSS: Main: 62353408
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/composite-scale.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg)
+RSS: Main: 62541824
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg)
+RSS: Main: 62488576
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg)
+RSS: Main: 62500864
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg (next: http://localhost:15707/page_load_test/svg/hixie-001.xml)
+RSS: Main: 60387328
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/hixie-001.xml (next: http://localhost:15707/page_load_test/svg/hixie-002.xml)
+RSS: Main: 59912192
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/hixie-002.xml (next: http://localhost:15707/page_load_test/svg/hixie-003.xml)
+RSS: Main: 59858944
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/hixie-003.xml (next: http://localhost:15707/page_load_test/svg/hixie-004.xml)
+RSS: Main: 60334080
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/hixie-004.xml (next: http://localhost:15707/page_load_test/svg/hixie-005.xml)
+RSS: Main: 60751872
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/hixie-005.xml (next: http://localhost:15707/page_load_test/svg/hixie-006.xml)
+RSS: Main: 60944384
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/hixie-006.xml (next: http://localhost:15707/page_load_test/svg/hixie-007.xml)
+RSS: Main: 59129856
+
+Cycle 4(1): loaded http://localhost:15707/page_load_test/svg/hixie-007.xml (next: http://localhost:15707/page_load_test/svg/gearflowers.svg)
+RSS: Main: 61718528
+
+RSS: Main: 61718528
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/gearflowers.svg (next: http://localhost:15707/page_load_test/svg/composite-scale.svg)
+RSS: Main: 62312448
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/composite-scale.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg)
+RSS: Main: 62607360
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-opacity.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg)
+RSS: Main: 62611456
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate.svg (next: http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg)
+RSS: Main: 62570496
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/composite-scale-rotate-opacity.svg (next: http://localhost:15707/page_load_test/svg/hixie-001.xml)
+RSS: Main: 60448768
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/hixie-001.xml (next: http://localhost:15707/page_load_test/svg/hixie-002.xml)
+RSS: Main: 59535360
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/hixie-002.xml (next: http://localhost:15707/page_load_test/svg/hixie-003.xml)
+RSS: Main: 59113472
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/hixie-003.xml (next: http://localhost:15707/page_load_test/svg/hixie-004.xml)
+RSS: Main: 59822080
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/hixie-004.xml (next: http://localhost:15707/page_load_test/svg/hixie-005.xml)
+RSS: Main: 60170240
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/hixie-005.xml (next: http://localhost:15707/page_load_test/svg/hixie-006.xml)
+RSS: Main: 61100032
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/hixie-006.xml (next: http://localhost:15707/page_load_test/svg/hixie-007.xml)
+RSS: Main: 59305984
+
+Cycle 5(1): loaded http://localhost:15707/page_load_test/svg/hixie-007.xml (next: http://localhost:15707/page_load_test/svg/gearflowers.svg)
+RSS: Main: 61734912
+
+__start_tp_report
+_x_x_mozilla_page_load
+_x_x_mozilla_page_load_details
+|i|pagename|runs|
+|0;gearflowers.svg;79;65;68;68;67
+|1;composite-scale.svg;46;35;44;41;42
+|2;composite-scale-opacity.svg;21;22;24;22;20
+|3;composite-scale-rotate.svg;23;21;21;20;19
+|4;composite-scale-rotate-opacity.svg;19;24;19;19;23
+|5;hixie-001.xml;45643;14976;17807;14971;17235
+|6;hixie-002.xml;51257;15193;21693;14969;14974
+|7;hixie-003.xml;5016;37375;5021;5024;5008
+|8;hixie-004.xml;5052;5053;5054;5054;5053
+|9;hixie-005.xml;4618;4533;4611;4532;4554
+|10;hixie-006.xml;5059;5107;9741;5107;5089
+|11;hixie-007.xml;1629;1651;1648;1652;1649
+__end_tp_report
+__start_cc_report
+_x_x_mozilla_cycle_collect,729
+__end_cc_report
+__startTimestamp1333666702130__endTimestamp
+
+__startBeforeLaunchTimestamp1333666292747__endBeforeLaunchTimestamp
+__startAfterTerminationTimestamp1333666702743__endAfterTerminationTimestamp
diff --git a/testing/talos/tests/ps-Acj.out b/testing/talos/tests/ps-Acj.out
new file mode 100644
index 000000000..c0139143f
--- /dev/null
+++ b/testing/talos/tests/ps-Acj.out
@@ -0,0 +1,44 @@
+USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND
+root 1 0 1 d49fe78 0 Ss ?? 0:00.28 launchd
+root 10 1 10 d49fc08 0 Ss ?? 0:00.77 kextd
+root 11 1 11 d49fad0 0 Ss ?? 0:00.69 DirectoryService
+root 12 1 12 d49f998 0 Ss ?? 0:00.15 notifyd
+root 13 1 13 d49f860 0 Ss ?? 0:00.04 syslogd
+root 14 1 14 d49f728 0 Ss ?? 0:00.07 diskarbitrationd
+root 15 1 15 d49f5f0 0 Ss ?? 0:01.06 configd
+daemon 16 1 16 d49f4b8 0 Ss ?? 0:00.08 distnoted
+_mdnsresponder 17 1 17 d49f380 0 Ss ?? 0:01.93 mDNSResponder
+root 23 1 23 d49efd8 0 Ss ?? 0:00.12 securityd
+root 27 1 27 d49ed68 0 Ss ?? 0:00.27 httpd
+root 28 1 28 d49ec30 0 Ss ?? 0:00.04 krb5kdc
+_usbmuxd 31 1 31 db264b8 0 Ss ?? 0:00.07 usbmuxd
+root 35 1 35 d49e3a8 0 Ss ?? 0:00.02 RFBRegisterMDNS
+root 36 1 36 d49e270 0 Ss ?? 0:00.02 ptmd
+root 37 1 37 d49e000 0 Ss ?? 0:00.35 mds
+cltbld 38 1 38 d49e750 0 Ss ?? 0:00.25 loginwindow
+root 39 1 39 d49e138 0 Ss ?? 0:00.01 KernelEventAgent
+root 41 1 41 db26ad0 0 Ss ?? 0:00.01 hidd
+root 42 1 42 db26998 0 Ss ?? 0:00.15 fseventsd
+root 44 1 44 db26d40 0 Ss ?? 0:00.01 dynamic_pager
+root 50 1 50 db25ea0 0 Ss ?? 0:00.01 autofsd
+root 72 1 72 db26c08 0 Ss ?? 0:02.66 coreservicesd
+_www 73 27 27 d49ed68 0 S ?? 0:00.00 httpd
+_windowserver 74 1 74 d49e888 0 Ss ?? 0:01.72 WindowServer
+root 79 1 79 db26e78 0 Ss ?? 0:00.01 cvmsServ
+_coreaudiod 90 1 90 db26380 0 Ss ?? 0:00.05 coreaudiod
+cltbld 94 1 94 db265f0 0 Ss ?? 0:00.10 launchd
+cltbld 98 94 98 db265f0 1 S ?? 0:03.08 Dock
+cltbld 99 94 99 db265f0 1 S ?? 0:00.45 SystemUIServer
+cltbld 100 94 100 db265f0 1 S ?? 0:04.43 Finder
+cltbld 103 94 103 db265f0 1 S ?? 0:00.35 fontd
+cltbld 110 94 110 db265f0 1 S ?? 0:00.11 UserEventAgent
+cltbld 113 94 113 db265f0 1 S ?? 0:00.02 AppleVNCServer
+cltbld 118 94 118 db265f0 1 S ?? 0:00.01 AirPort Base Station Agent
+cltbld 122 94 122 db265f0 1 S ?? 0:00.00 pboard
+cltbld 123 94 123 db265f0 1 ?? 0:00.00 (CCacheServer)
+root 268 1 268 d49eea0 0 Ss ?? 0:00.03 ntpd
+cltbld 285 1 284 db26110 0 S ?? 0:02.01 python
+cltbld 334 285 334 db26110 1 S ?? 0:01.93 python
+root 358 1 358 db25fd8 0 Ss ?? 0:00.01 taskgated
+cltbld 378 94 378 db265f0 1 S ?? 0:00.03 cvmsComp_x86_64
+root 547 334 334 db26110 1 R ?? 0:00.00 ps \ No newline at end of file
diff --git a/testing/talos/tests/test_browser_output.py b/testing/talos/tests/test_browser_output.py
new file mode 100644
index 000000000..7b95733c0
--- /dev/null
+++ b/testing/talos/tests/test_browser_output.py
@@ -0,0 +1,190 @@
+#!/usr/bin/env python
+
+"""
+test talos browser output parsing
+"""
+
+import os
+import unittest
+
+from talos.results import BrowserLogResults
+from talos.results import PageloaderResults
+from talos.utils import TalosError
+
+here = os.path.dirname(os.path.abspath(__file__))
+
+
+class TestBrowserOutput(unittest.TestCase):
+
+ def test_ts_format(self):
+
+ # output file
+ browser_ts = os.path.join(here, 'browser_output.ts.txt')
+
+ # parse the results
+ browser_log = BrowserLogResults(browser_ts)
+
+ # ensure the results meet what we expect
+ self.assertEqual(browser_log.format, 'tsformat')
+ self.assertEqual(browser_log.browser_results.strip(), '392')
+ self.assertEqual(browser_log.startTime, 1333663595953)
+ self.assertEqual(browser_log.endTime, 1333663596551)
+
+ def test_tsvg_format(self):
+
+ # output file
+ browser_tsvg = os.path.join(here, 'browser_output.tsvg.txt')
+
+ # parse the results
+ browser_log = BrowserLogResults(browser_tsvg)
+
+ # ensure the results meet what we expect
+ self.assertEqual(browser_log.format, 'tpformat')
+ self.assertEqual(browser_log.startTime, 1333666702130)
+ self.assertEqual(browser_log.endTime, 1333666702743)
+
+ # we won't validate the exact string because it is long
+ raw_report = browser_log.browser_results.strip()
+ raw_report.startswith('_x_x_mozilla_page_load')
+ raw_report.endswith('|11;hixie-007.xml;1629;1651;1648;1652;1649')
+
+ # but we will ensure that it is parseable
+ pageloader_results = PageloaderResults(raw_report)
+ self.assertEqual(len(pageloader_results.results), 12)
+ indices = [i['index'] for i in pageloader_results.results]
+ self.assertEqual(indices, range(12))
+
+ # test hixie-001.xml just as a spot-check
+ hixie_001 = pageloader_results.results[5]
+ expected_values = [45643, 14976, 17807, 14971, 17235]
+ self.assertEqual(hixie_001['runs'], expected_values)
+ self.assertEqual(hixie_001['page'], 'hixie-001.xml')
+
+ def test_garbage(self):
+ """
+ send in garbage input and ensure the output is the
+ inability to find the report
+ """
+
+ garbage = "hjksdfhkhasdfjkhsdfkhdfjklasd"
+ self.compare_error_message(garbage, "Could not find report")
+
+ def test_missing_end_report(self):
+ """what if you're not done with a report?"""
+ garbage = "hjksdfhkhasdfjkhsdfkhdfjklasd"
+
+ input = self.start_report()
+ input += garbage
+ self.compare_error_message(input, "Could not find end token: '__end_report'")
+
+ def test_double_end_report(self):
+ """double end report tokens"""
+
+ garbage = "hjksdfhkhasdfjkhsdfkhdfjklasd"
+ input = self.start_report() + garbage + self.end_report() + self.end_report()
+ self.compare_error_message(input, "Unmatched number of tokens")
+
+ def test_end_report_before_start_report(self):
+ """the end report token occurs before the start report token"""
+
+ garbage = "hjksdfhkhasdfjkhsdfkhdfjklasd"
+ input = self.end_report() + garbage + self.start_report()
+ self.compare_error_message(input,
+ "End token '%s' occurs before start token" %
+ self.end_report())
+
+ def test_missing_timestamps(self):
+ """what if the timestamps are missing?"""
+
+ # make a bogus report but missing the timestamps
+ garbage = "hjksdfhkhasdfjkhsdfkhdfjklasd"
+ input = self.start_report() + garbage + self.end_report()
+
+ # it will fail
+ self.compare_error_message(input, "Could not find startTime in browser output")
+
+ def test_wrong_order(self):
+ """what happens if you mix up the token order?"""
+
+ # i've secretly put the AfterTerminationTimestamp before
+ # the BeforeLaunchTimestamp
+ # Let's see if the parser notices
+ bad_report = """__start_report392__end_report
+
+Failed to load native module at path '/home/jhammel/firefox/components/libmozgnome.so':
+(80004005) libnotify.so.1: cannot open shared object file: No such file or directory
+Could not read chrome manifest
+'file:///home/jhammel/firefox/extensions/%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D/chrome.manifest'.
+[JavaScript Warning: "Use of enablePrivilege is deprecated.
+Please use code that runs with the system principal (e.g. an extension) instead.
+" {file: "http://localhost:15707/startup_test/startup_test.html?begin=1333663595557" line: 0}]
+__startTimestamp1333663595953__endTimestamp
+__startAfterTerminationTimestamp1333663596551__endAfterTerminationTimestamp
+__startBeforeLaunchTimestamp1333663595557__endBeforeLaunchTimestamp
+"""
+
+ self.compare_error_message(bad_report, "] found before " +
+ "('__startBeforeLaunchTimestamp', " +
+ "'__endBeforeLaunchTimestamp') " +
+ "[character position:")
+
+ def test_multiple_reports(self):
+ """you're only allowed to have one report in a file"""
+
+ # this one works fine
+ good_report = """__start_report392__end_report
+
+Failed to load native module at path '/home/jhammel/firefox/components/libmozgnome.so':
+(80004005) libnotify.so.1: cannot open shared object file: No such file or directory
+Could not read chrome manifest
+'file:///home/jhammel/firefox/extensions/%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D/chrome.manifest'.
+[JavaScript Warning: "Use of enablePrivilege is deprecated.
+Please use code that runs with the system principal (e.g. an extension) instead.
+" {file: "http://localhost:15707/startup_test/startup_test.html?begin=1333663595557" line: 0}]
+__startTimestamp1333663595953__endTimestamp
+__startBeforeLaunchTimestamp1333663595557__endBeforeLaunchTimestamp
+__startAfterTerminationTimestamp1333663596551__endAfterTerminationTimestamp
+"""
+
+ # but there's no hope for this one
+ bad_report = good_report + good_report # interesting math
+
+ self.compare_error_message(bad_report, "Multiple matches for %s,%s" %
+ (self.start_report(), self.end_report()))
+
+ def start_report(self):
+ """return a start report token"""
+ return BrowserLogResults.report_tokens[0][1][0] # start token
+
+ def end_report(self):
+ """return a start report token"""
+ return BrowserLogResults.report_tokens[0][1][-1] # end token
+
+ def compare_error_message(self, browser_log, substr):
+ """
+ ensures that exceptions give correct error messages
+ - browser_log : a browser log file
+ - substr : substring of the error message
+ """
+
+ try:
+ BrowserLogResults(results_raw=browser_log)
+ except TalosError as e:
+ if substr not in str(e):
+ import pdb
+ pdb.set_trace()
+ self.assertTrue(substr in str(e))
+
+
+class TestTalosError(unittest.TestCase):
+ """
+ test TalosError class
+ """
+ def test_browser_log_results(self):
+ # an example that should fail
+ # passing invalid value for argument result_raw
+ with self.assertRaises(TalosError):
+ BrowserLogResults(results_raw="__FAIL<bad test>__FAIL")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/talos/tests/test_filter.py b/testing/talos/tests/test_filter.py
new file mode 100755
index 000000000..b4e2d39cf
--- /dev/null
+++ b/testing/talos/tests/test_filter.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+
+"""
+test talos' filter module:
+
+http://hg.mozilla.org/build/talos/file/tip/talos/filter.py
+"""
+
+import unittest
+import talos.filter
+
+
+class TestFilter(unittest.TestCase):
+
+ data = range(30) # test data
+
+ def test_ignore(self):
+ """test the ignore filter"""
+ # a bit of a stub sanity test for a single filter
+
+ filtered = talos.filter.ignore_first(self.data)
+ self.assertEquals(filtered, self.data[1:])
+
+ filtered = talos.filter.ignore_first(self.data, 10)
+ self.assertEquals(filtered, self.data[10:])
+
+ # short series won't be filtered
+ filtered = talos.filter.ignore_first(self.data, 50)
+ self.assertEquals(filtered, self.data)
+
+ def test_getting_filters(self):
+ """test getting a list of filters from a string"""
+
+ filter_names = ['ignore_max', 'ignore_max', 'max']
+
+ # get the filter functions
+ filters = talos.filter.filters(*filter_names)
+ self.assertEquals(len(filter_names), len(filters))
+ for filter in filters:
+ self.assertTrue(self, hasattr(filter, '__call__'))
+
+ # apply them on the data
+ filtered = talos.filter.apply(self.data, filters)
+ self.assertEquals(filtered, 27)
+
+ def test_parse(self):
+ """test the filter name parse function"""
+
+ # an example with no arguments
+ parsed = talos.filter.parse('mean')
+ self.assertEquals(parsed, ['mean', []])
+
+ # an example with one integer argument
+ parsed = talos.filter.parse('ignore_first:10')
+ self.assertEquals(parsed, ['ignore_first', [10]])
+ self.assertEquals(type(parsed[1][0]), int)
+ self.assertNotEqual(type(parsed[1][0]), float)
+
+ # an example with several arguments
+
+ # temporarily add foo
+ # value is lambda function to mimic filter_dict key:value pair
+ talos.filter.scalar_filters['foo'] = lambda *args: args
+ parsed = talos.filter.parse('foo:10.1,2,5.0,6.')
+ self.assertEquals(parsed, ['foo', [10.1, 2, 5.0, 6.0]])
+ for index in (2, 3):
+ self.assertEquals(type(parsed[1][index]), float)
+ self.assertNotEqual(type(parsed[1][index]), int)
+
+ # an example that should fail
+ self.assertRaises(ValueError, talos.filter.parse, 'foo:bar')
+ self.assertRaises(ValueError, talos.filter.parse, 'foo:1,')
+
+ # delete foo again
+ del talos.filter.scalar_filters['foo']
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/talos/tests/test_results.py b/testing/talos/tests/test_results.py
new file mode 100755
index 000000000..015da8ed2
--- /dev/null
+++ b/testing/talos/tests/test_results.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+"""
+test talos results parsing
+
+http://hg.mozilla.org/build/talos/file/tip/talos/results.py
+"""
+
+import unittest
+import talos.filter
+import talos.results
+
+# example page load test results string
+results_string = """_x_x_mozilla_page_load
+_x_x_mozilla_page_load_details
+|i|pagename|runs|
+|0;gearflowers.svg;74;65;68;66;62
+|1;composite-scale.svg;43;44;35;41;41
+|2;composite-scale-opacity.svg;19;16;19;19;21
+|3;composite-scale-rotate.svg;18;19;20;20;19
+|4;composite-scale-rotate-opacity.svg;18;17;17;17;19
+|5;hixie-001.xml;71836;15057;15063;57436;15061
+|6;hixie-002.xml;53940;15057;38246;55323;31818
+|7;hixie-003.xml;5027;5026;13540;31503;5031
+|8;hixie-004.xml;5050;5054;5053;5054;5055
+|9;hixie-005.xml;4568;4569;4562;4545;4567
+|10;hixie-006.xml;5090;5165;5054;5015;5077
+|11;hixie-007.xml;1628;1623;1623;1617;1622
+"""
+
+
+class TestPageloaderResults(unittest.TestCase):
+
+ def test_parsing(self):
+ """test our ability to parse results data"""
+ results = talos.results.PageloaderResults(results_string)
+
+ # ensure you got all of them
+ self.assertEqual(len(results.results), 12)
+
+ # test the indices
+ indices = [i['index'] for i in results.results]
+ self.assertEqual(indices, range(12))
+
+ # test some pages
+ pages = [i['page'] for i in results.results]
+ comparison = ['hixie-00%d.xml' % i for i in range(1, 8)]
+ self.assertEqual(pages[-len(comparison):], comparison)
+
+ # test a few values
+ last = [1628., 1623., 1623, 1617., 1622.]
+ self.assertEqual(results.results[-1]['runs'], last)
+ first = [74., 65., 68., 66., 62.]
+ self.assertEqual(results.results[0]['runs'], first)
+
+ def test_filter(self):
+ """test PageloaderResults.filter function"""
+
+ # parse the data
+ results = talos.results.PageloaderResults(results_string)
+
+ # apply some filters
+ filters = [[talos.filter.ignore_first, [2]], [talos.filter.median]]
+ filtered = results.filter(*filters)
+ self.assertEqual(filtered[0][0], 66.)
+ self.assertEqual(filtered[-1][0], 1622.)
+
+ # apply some different filters
+ filters = [[talos.filter.ignore_max, []], [max, []]]
+ filtered = results.filter(*filters)
+ self.assertEqual(filtered[0][0], 68.)
+ self.assertEqual(filtered[-1][0], 1623.)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/talos/tests/test_talosconfig.py b/testing/talos/tests/test_talosconfig.py
new file mode 100644
index 000000000..85b6c953f
--- /dev/null
+++ b/testing/talos/tests/test_talosconfig.py
@@ -0,0 +1,155 @@
+from talos import talosconfig
+from talos.configuration import YAML
+import unittest
+import json
+
+
+# globals
+ffox_path = 'test/path/to/firefox'
+command_args = [ffox_path,
+ '-profile',
+ 'pathtoprofile',
+ '-tp',
+ 'pathtotpmanifest',
+ '-tpchrome',
+ '-tpmozafterpaint',
+ '-tpnoisy',
+ '-rss',
+ '-tpcycles',
+ '1',
+ '-tppagecycles',
+ '1']
+with open("test_talosconfig_browser_config.json") as json_browser_config:
+ browser_config = json.load(json_browser_config)
+with open("test_talosconfig_test_config.json") as json_test_config:
+ test_config = json.load(json_test_config)
+
+
+class TestWriteConfig(unittest.TestCase):
+ def test_writeConfigFile(self):
+ obj = dict(some=123, thing='456', other=789)
+
+ self.assertEquals(
+ json.loads(talosconfig.writeConfigFile(obj, ('some', 'thing'))),
+ dict(some=123, thing='456')
+ )
+
+ # test without keys
+ self.assertEquals(
+ json.loads(talosconfig.writeConfigFile(obj, None)),
+ obj
+ )
+
+
+class TalosConfigUnitTest(unittest.TestCase):
+ """
+ A class inheriting from unittest.TestCase to test the generateTalosConfig function.
+ """
+
+ def validate(self, var1, var2):
+ # Function to check whether the output generated is correct or not.
+ # If the output generated is not correct then specify the expected output to be generated.
+ if var1 == var2:
+ return 1
+ else:
+ print("input '%s' != expected '%s'" % (var1, var2))
+
+ def test_talosconfig(self):
+ # This function stimulates a call to generateTalosConfig in talosconfig.py .
+ # It is then tested whether the output generated is correct or not.
+ # ensure that the output generated in yaml file is as expected or not.
+ yaml = YAML()
+ content = yaml.read(browser_config['bcontroller_config'])
+ self.validate(content['command'],
+ "test/path/to/firefox " +
+ "-profile " +
+ "pathtoprofile " +
+ "-tp " +
+ "pathtotpmanifest " +
+ "-tpchrome " +
+ "-tpmozafterpaint " +
+ "-tpnoisy " +
+ "-rss " +
+ "-tpcycles " +
+ "1 " +
+ "-tppagecycles " +
+ "1")
+ self.validate(content['child_process'], "plugin-container")
+ self.validate(content['process'], "firefox.exe")
+ self.validate(content['browser_wait'], 5)
+ self.validate(content['test_timeout'], 1200)
+ self.validate(content['browser_log'], "browser_output.txt")
+ self.validate(content['browser_path'], "test/path/to/firefox")
+ self.validate(content['error_filename'], "pathtoerrorfile")
+ self.validate(content['xperf_path'],
+ "C:/Program Files/Microsoft Windows Performance Toolkit/xperf.exe")
+ self.validate(content['buildid'], 20131205075310)
+ self.validate(content['sourcestamp'], "39faf812aaec")
+ self.validate(content['repository'], "http://hg.mozilla.org/releases/mozilla-release")
+ self.validate(content['title'], "qm-pxp01")
+ self.validate(content['testname'], "tp5n")
+ self.validate(content['xperf_providers'], ['PROC_THREAD',
+ 'LOADER',
+ 'HARD_FAULTS',
+ 'FILENAME',
+ 'FILE_IO',
+ 'FILE_IO_INIT'])
+ self.validate(content['xperf_user_providers'],
+ ['Mozilla Generic Provider', 'Microsoft-Windows-TCPIP'])
+ self.validate(content['xperf_stackwalk'],
+ ['FileCreate', 'FileRead', 'FileWrite', 'FileFlush', 'FileClose'])
+ self.validate(content['processID'], "None")
+ self.validate(content['approot'], "test/path/to")
+
+ def test_errors(self):
+ # Tests if errors are correctly raised.
+
+ # Testing that error is correctly raised or not if xperf_path is missing
+ browser_config_copy = browser_config.copy()
+ test_config_copy = test_config.copy()
+ del browser_config_copy['xperf_path']
+ talosconfig.generateTalosConfig(command_args, browser_config_copy, test_config_copy)
+ yaml = YAML()
+ content = yaml.read(browser_config['bcontroller_config'])
+
+ with self.assertRaises(KeyError):
+ self.validate(content['xperf_path'],
+ "C:/Program Files/Microsoft Windows Performance Toolkit/xperf.exe")
+
+ # Test to see if keyerror is raised or not for calling testname when xperf_path is missing
+ with self.assertRaises(KeyError):
+ self.validate(content['testname'], "tp5n")
+
+ # Testing that error is correctly raised or not if xperf_providers is missing
+ browser_config_copy = browser_config.copy()
+ test_config_copy = test_config.copy()
+ del test_config_copy['xperf_providers']
+ talosconfig.generateTalosConfig(command_args, browser_config_copy, test_config_copy)
+ yaml = YAML()
+ content = yaml.read(browser_config['bcontroller_config'])
+
+ # Checking keyerror when calling xperf_providers
+ with self.assertRaises(KeyError):
+ self.validate(content['xperf_providers'], ['PROC_THREAD', 'LOADER', 'HARD_FAULTS',
+ 'FILENAME', 'FILE_IO', 'FILE_IO_INIT'])
+
+ # Checking keyerror when calling xperf_user_providers when xperf_providers is missing
+ with self.assertRaises(KeyError):
+ self.validate(content['xperf_user_providers'],
+ ['Mozilla Generic Provider', 'Microsoft-Windows-TCPIP'])
+
+ # Checking keyerror when calling xperf_stackwalk when xperf_providers is missing
+ with self.assertRaises(KeyError):
+ self.validate(content['xperf_stackwalk'],
+ ['FileCreate', 'FileRead', 'FileWrite', 'FileFlush', 'FileClose'])
+
+ # Checking keyerror when calling processID when xperf_providers is missing
+ with self.assertRaises(KeyError):
+ self.validate(content['processID'], "None")
+
+ # Checking keyerror when calling approot when xperf_providers is missing
+ with self.assertRaises(KeyError):
+ self.validate(content['approot'], "test/path/to")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/talos/tests/test_talosconfig_browser_config.json b/testing/talos/tests/test_talosconfig_browser_config.json
new file mode 100644
index 000000000..7e7226c9f
--- /dev/null
+++ b/testing/talos/tests/test_talosconfig_browser_config.json
@@ -0,0 +1 @@
+{'deviceroot': '', 'dirs': {}, 'repository': 'http://hg.mozilla.org/releases/mozilla-release', 'buildid': '20131205075310', 'results_log': 'pathtoresults_log', 'symbols_path': None, 'bcontroller_config': 'pathtobcontroller', 'host': '', 'browser_name': 'Firefox', 'sourcestamp': '39faf812aaec', 'remote': False, 'child_process': 'plugin-container', 'branch_name': '', 'browser_version': '26.0', 'extra_args': '', 'develop': True, 'preferences': {'browser.display.overlaynavbuttons': False, 'extensions.getAddons.get.url': 'http://127.0.0.1/extensions-dummy/repositoryGetURL', 'dom.max_chrome_script_run_time': 0, 'network.proxy.type': 1, 'extensions.update.background.url': 'http://127.0.0.1/extensions-dummy/updateBackgroundURL', 'network.proxy.http': 'localhost', 'plugins.update.url': 'http://127.0.0.1/plugins-dummy/updateCheckURL', 'dom.max_script_run_time': 0, 'extensions.update.enabled': False, 'browser.safebrowsing.keyURL': 'http://127.0.0.1/safebrowsing-dummy/newkey', 'media.navigator.permission.disabled': True, 'app.update.enabled': False, 'extensions.blocklist.url': 'http://127.0.0.1/extensions-dummy/blocklistURL', 'browser.EULA.override': True, 'extensions.checkCompatibility': False, 'talos.logfile': 'pathtofile', 'browser.safebrowsing.gethashURL': 'http://127.0.0.1/safebrowsing-dummy/gethash', 'extensions.hotfix.url': 'http://127.0.0.1/extensions-dummy/hotfixURL', 'dom.disable_window_move_resize': True, 'network.proxy.http_port': 80, 'browser.dom.window.dump.enabled': True, 'extensions.update.url': 'http://127.0.0.1/extensions-dummy/updateURL', 'browser.chrome.dynamictoolbar': False, 'browser.link.open_newwindow': 2, 'extensions.getAddons.search.url': 'http://127.0.0.1/extensions-dummy/repositorySearchURL', 'browser.cache.disk.smart_size.first_run': False, 'security.turn_off_all_security_so_that_viruses_can_take_over_this_computer': True, 'dom.disable_open_during_load': False, 'extensions.getAddons.search.browseURL': 'http://127.0.0.1/extensions-dummy/repositoryBrowseURL', 'browser.cache.disk.smart_size.enabled': False, 'extensions.getAddons.getWithPerformance.url': 'http://127.0.0.1/extensions-dummy/repositoryGetWithPerformanceURL', 'hangmonitor.timeout': 0, 'extensions.getAddons.maxResults': 0, 'dom.send_after_paint_to_content': True, 'security.fileuri.strict_origin_policy': False, 'media.capturestream_hints.enabled': True, 'extensions.update.notifyUser': False, 'extensions.blocklist.enabled': False, 'browser.bookmarks.max_backups': 0, 'browser.shell.checkDefaultBrowser': False, 'media.peerconnection.enabled': True, 'dom.disable_window_flip': True, 'security.enable_java': False, 'browser.warnOnQuit': False, 'media.navigator.enabled': True, 'browser.safebrowsing.updateURL': 'http://127.0.0.1/safebrowsing-dummy/update', 'dom.allow_scripts_to_close_windows': True, 'extensions.webservice.discoverURL': 'http://127.0.0.1/extensions-dummy/discoveryURL'}, 'test_timeout': 1200, 'title': 'qm-pxp01', 'error_filename': 'pathtoerrorfile', 'webserver': 'localhost:15707', 'browser_path':ffox_path, 'port': 20701, 'browser_log': 'browser_output.txt', 'process': 'firefox.exe', 'xperf_path': 'C:/Program Files/Microsoft Windows Performance Toolkit/xperf.exe', 'extensions': ['pathtopageloader'], 'fennecIDs': '', 'env': {'NO_EM_RESTART': '1'}, 'init_url': 'http://localhost:15707/getInfo.html', 'browser_wait': 5} \ No newline at end of file
diff --git a/testing/talos/tests/test_talosconfig_test_config.json b/testing/talos/tests/test_talosconfig_test_config.json
new file mode 100644
index 000000000..541bad3bc
--- /dev/null
+++ b/testing/talos/tests/test_talosconfig_test_config.json
@@ -0,0 +1 @@
+{'remote_counters': [], 'filters': [['ignore_first', [5]], ['median', []]], 'xperf_user_providers': ['Mozilla Generic Provider', 'Microsoft-Windows-TCPIP'], 'tpcycles': 1, 'browser_log': 'browser_output.txt', 'shutdown': False, 'fennecIDs': False, 'responsiveness': False, 'tpmozafterpaint': True, 'cleanup': 'pathtofile', 'tprender': False, 'xperf_counters': ['main_startup_fileio', 'main_startup_netio', 'main_normal_fileio', 'main_normal_netio', 'nonmain_startup_fileio', 'nonmain_normal_fileio', 'nonmain_normal_netio', 'mainthread_readcount', 'mainthread_readbytes', 'mainthread_writecount', 'mainthread_writebytes'], 'mac_counters': [], 'tpnoisy': True, 'tppagecycles': 1, 'tploadaboutblank': False, 'xperf_providers': ['PROC_THREAD', 'LOADER', 'HARD_FAULTS', 'FILENAME', 'FILE_IO', 'FILE_IO_INIT'], 'rss': True, 'profile_path': 'path', 'name': 'tp5n', 'url': '-tp pathtotp5n.manifest -tpchrome -tpmozafterpaint -tpnoisy -rss -tpcycles 1 -tppagecycles 1', 'setup': 'pathtosetup', 'linux_counters': [], 'tpmanifest': 'pathtotp5n.manifest', 'w7_counters': [], 'timeout': 1800, 'xperf_stackwalk': ['FileCreate', 'FileRead', 'FileWrite', 'FileFlush', 'FileClose'], 'win_counters': [], 'cycles': 1, 'resolution': 20, 'tpchrome': True} \ No newline at end of file
diff --git a/testing/talos/tests/test_urlsplit.py b/testing/talos/tests/test_urlsplit.py
new file mode 100755
index 000000000..045481577
--- /dev/null
+++ b/testing/talos/tests/test_urlsplit.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+"""
+test URL parsing; see
+https://bugzilla.mozilla.org/show_bug.cgi?id=793875
+"""
+
+import unittest
+import talos.utils
+
+
+class TestURLParsing(unittest.TestCase):
+
+ def test_http_url(self):
+ """test parsing an HTTP URL"""
+
+ url = 'https://www.mozilla.org/en-US/about/'
+ parsed = talos.utils.urlsplit(url)
+ self.assertEqual(parsed,
+ ['https', 'www.mozilla.org', '/en-US/about/', '', ''])
+
+ def test_file_url(self):
+ """test parsing file:// URLs"""
+
+ # unix-like file path
+ url = 'file:///foo/bar'
+ parsed = talos.utils.urlsplit(url)
+ self.assertEqual(parsed,
+ ['file', '', '/foo/bar', '', ''])
+
+ # windows-like file path
+ url = r'file://c:\foo\bar'
+ parsed = talos.utils.urlsplit(url)
+ self.assertEqual(parsed,
+ ['file', '', r'c:\foo\bar', '', ''])
+
+ def test_implicit_file_url(self):
+ """
+ test parsing URLs with no scheme, which by default are assumed
+ to be file:// URLs
+ """
+
+ path = '/foo/bar'
+ parsed = talos.utils.urlsplit(path)
+ self.assertEqual(parsed,
+ ['file', '', '/foo/bar', '', ''])
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/testing/talos/tests/test_utils.py b/testing/talos/tests/test_utils.py
new file mode 100644
index 000000000..0157234f5
--- /dev/null
+++ b/testing/talos/tests/test_utils.py
@@ -0,0 +1,40 @@
+from talos import utils
+import unittest
+import os
+
+
+class TestTimer(unittest.TestCase):
+ def test_timer(self):
+ timer = utils.Timer()
+ timer._start_time -= 3 # remove three seconds for the test
+ self.assertEquals(timer.elapsed(), '00:00:03')
+
+
+class TestRestoreEnv(unittest.TestCase):
+ def test_basic(self):
+ env_var = 'THIS_IS_A_ENV_VAR_NOT_USED'
+ self.assertNotIn(env_var, os.environ)
+ with utils.restore_environment_vars():
+ os.environ[env_var] = '1'
+ self.assertNotIn(env_var, os.environ)
+
+
+class TestInterpolate(unittest.TestCase):
+ def test_interpolate_talos_is_always_defines(self):
+ self.assertEquals(utils.interpolate('${talos}'), utils.here)
+
+ def test_interpolate_custom_placeholders(self):
+ self.assertEquals(utils.interpolate('${talos} ${foo} abc', foo='bar', unused=1),
+ utils.here + ' bar abc')
+
+
+class TestParsePref(unittest.TestCase):
+ def test_parse_string(self):
+ self.assertEquals(utils.parse_pref('abc'), 'abc')
+
+ def test_parse_int(self):
+ self.assertEquals(utils.parse_pref('12'), 12)
+
+ def test_parse_bool(self):
+ self.assertEquals(utils.parse_pref('true'), True)
+ self.assertEquals(utils.parse_pref('false'), False)
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()
diff --git a/testing/talos/tests/xrestop_output.txt b/testing/talos/tests/xrestop_output.txt
new file mode 100644
index 000000000..25a1b48ef
--- /dev/null
+++ b/testing/talos/tests/xrestop_output.txt
@@ -0,0 +1,224 @@
+0 - Thunderbird ( PID: 2035 ):
+ res_base : 0x1600000
+ res_mask : 0x1fffff
+ windows : 69
+ GCs : 35
+ fonts : 1
+ pixmaps : 175
+ pictures : 272
+ glyphsets : 73
+ colormaps : 0
+ passive grabs : 0
+ cursors : 9
+ unknowns : 42
+ pixmap bytes : 4715737
+ other bytes : ~13024
+ total bytes : ~4728761
+1 - 809276 – GetXRes should parse output of xrestop in process versus crazy shell commands - Nightly ( PID: 6076 ):
+ res_base : 0x1400000
+ res_mask : 0x1fffff
+ windows : 24
+ GCs : 36
+ fonts : 1
+ pixmaps : 122
+ pictures : 172
+ glyphsets : 49
+ colormaps : 0
+ passive grabs : 0
+ cursors : 6
+ unknowns : 19
+ pixmap bytes : 3535225
+ other bytes : ~8368
+ total bytes : ~3543593
+2 - Terminal ( PID: 1668 ):
+ res_base : 0x800000
+ res_mask : 0x1fffff
+ windows : 27
+ GCs : 3
+ fonts : 1
+ pixmaps : 32
+ pictures : 50
+ glyphsets : 4
+ colormaps : 0
+ passive grabs : 0
+ cursors : 5
+ unknowns : 56
+ pixmap bytes : 1943716
+ other bytes : ~4504
+ total bytes : ~1948220
+3 - Fluxbox ( PID: ? ):
+ res_base : 0xa00000
+ res_mask : 0x1fffff
+ windows : 286
+ GCs : 21
+ fonts : 1
+ pixmaps : 33
+ pictures : 562
+ glyphsets : 3
+ colormaps : 1
+ passive grabs : 254
+ cursors : 19
+ unknowns : 27
+ pixmap bytes : 684196
+ other bytes : ~29176
+ total bytes : ~713372
+4 - notify-osd ( PID: 1813 ):
+ res_base : 0x1000000
+ res_mask : 0x1fffff
+ windows : 2
+ GCs : 3
+ fonts : 0
+ pixmaps : 1
+ pictures : 2
+ glyphsets : 0
+ colormaps : 0
+ passive grabs : 0
+ cursors : 0
+ unknowns : 10
+ pixmap bytes : 74408
+ other bytes : ~408
+ total bytes : ~74816
+5 - <unknown> ( PID: ? ):
+ res_base : 0x0
+ res_mask : 0x1fffff
+ windows : 1
+ GCs : 0
+ fonts : 2
+ pixmaps : 0
+ pictures : 0
+ glyphsets : 0
+ colormaps : 0
+ passive grabs : 0
+ cursors : 1
+ unknowns : 68
+ pixmap bytes : 28940
+ other bytes : ~3728
+ total bytes : ~32668
+6 - <unknown> ( PID: ? ):
+ res_base : 0xe00000
+ res_mask : 0x1fffff
+ windows : 0
+ GCs : 0
+ fonts : 0
+ pixmaps : 1
+ pictures : 0
+ glyphsets : 0
+ colormaps : 0
+ passive grabs : 0
+ cursors : 0
+ unknowns : 0
+ pixmap bytes : 28940
+ other bytes : ~0
+ total bytes : ~28940
+7 - emacs@jhammel-ThinkPad-X230 ( PID: 4824 ):
+ res_base : 0x1a00000
+ res_mask : 0x1fffff
+ windows : 5
+ GCs : 45
+ fonts : 1
+ pixmaps : 8
+ pictures : 18
+ glyphsets : 3
+ colormaps : 1
+ passive grabs : 0
+ cursors : 9
+ unknowns : 9
+ pixmap bytes : 9239
+ other bytes : ~3184
+ total bytes : ~12423
+8 - NetworkManager Applet ( PID: 1798 ):
+ res_base : 0xc00000
+ res_mask : 0x1fffff
+ windows : 4
+ GCs : 3
+ fonts : 1
+ pixmaps : 17
+ pictures : 33
+ glyphsets : 2
+ colormaps : 0
+ passive grabs : 0
+ cursors : 1
+ unknowns : 15
+ pixmap bytes : 408
+ other bytes : ~2416
+ total bytes : ~2824
+9 - gnome-screensaver ( PID: 1817 ):
+ res_base : 0x1200000
+ res_mask : 0x1fffff
+ windows : 3
+ GCs : 1
+ fonts : 0
+ pixmaps : 0
+ pictures : 0
+ glyphsets : 0
+ colormaps : 0
+ passive grabs : 0
+ cursors : 0
+ unknowns : 9
+ pixmap bytes : 0
+ other bytes : ~312
+ total bytes : ~312
+10 - xrestop ( PID: ? ):
+ res_base : 0x1800000
+ res_mask : 0x1fffff
+ windows : 1
+ GCs : 1
+ fonts : 0
+ pixmaps : 0
+ pictures : 0
+ glyphsets : 0
+ colormaps : 0
+ passive grabs : 0
+ cursors : 0
+ unknowns : 0
+ pixmap bytes : 0
+ other bytes : ~48
+ total bytes : ~48
+11 - <unknown> ( PID: ? ):
+ res_base : 0x400000
+ res_mask : 0x1fffff
+ windows : 1
+ GCs : 1
+ fonts : 0
+ pixmaps : 0
+ pictures : 0
+ glyphsets : 0
+ colormaps : 0
+ passive grabs : 0
+ cursors : 0
+ unknowns : 0
+ pixmap bytes : 0
+ other bytes : ~48
+ total bytes : ~48
+12 - <unknown> ( PID: ? ):
+ res_base : 0x600000
+ res_mask : 0x1fffff
+ windows : 0
+ GCs : 1
+ fonts : 0
+ pixmaps : 0
+ pictures : 0
+ glyphsets : 0
+ colormaps : 0
+ passive grabs : 0
+ cursors : 0
+ unknowns : 0
+ pixmap bytes : 0
+ other bytes : ~24
+ total bytes : ~24
+13 - <unknown> ( PID: ? ):
+ res_base : 0x200000
+ res_mask : 0x1fffff
+ windows : 0
+ GCs : 0
+ fonts : 0
+ pixmaps : 0
+ pictures : 0
+ glyphsets : 0
+ colormaps : 0
+ passive grabs : 0
+ cursors : 0
+ unknowns : 0
+ pixmap bytes : 0
+ other bytes : ~0
+ total bytes : ~0