summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/contrib/tts/tests.py
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-05-18 14:04:53 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-29 11:59:46 +0100
commit225daf45a46aca31dfd21897ee302b32f671cd4b (patch)
tree76ab4e06c3239b7e04b332eaaed5da62fce5edc8 /bitbake/lib/toaster/contrib/tts/tests.py
parent29143915ae543f3cd389a7b1e32967ab42730e45 (diff)
downloadpoky-225daf45a46aca31dfd21897ee302b32f671cd4b.tar.gz
bitbake: toaster tests: enable url check test
Integrate the HTML5 validation as a test instead of calling a separate script. This enables us to get the HTML5 validation report as part of patch-level testing. gitignore the cache directory created by the http client (Bitbake rev: 931caab56301876cb8632b289835c2545a096ef6) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/contrib/tts/tests.py')
-rw-r--r--bitbake/lib/toaster/contrib/tts/tests.py55
1 files changed, 53 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/tests.py b/bitbake/lib/toaster/contrib/tts/tests.py
index 2e630db575..15a9a874ff 100644
--- a/bitbake/lib/toaster/contrib/tts/tests.py
+++ b/bitbake/lib/toaster/contrib/tts/tests.py
@@ -26,6 +26,9 @@
26import unittest 26import unittest
27from shellutils import * 27from shellutils import *
28 28
29import pexpect
30import sys, os, signal, time
31
29class TestPyCompilable(unittest.TestCase): 32class TestPyCompilable(unittest.TestCase):
30 ''' Verifies that all Python files are syntactically correct ''' 33 ''' Verifies that all Python files are syntactically correct '''
31 def test_compile_file(self): 34 def test_compile_file(self):
@@ -44,14 +47,62 @@ class TestPySystemStart(unittest.TestCase):
44 47
45 def test_start_interactive_mode(self): 48 def test_start_interactive_mode(self):
46 try: 49 try:
47 run_shell_cmd("bash -c 'source %s/oe-init-build-env && source toaster start webport=56789 && source toaster stop'" % config.testdir, config.testdir) 50 run_shell_cmd("bash -c 'source %s/oe-init-build-env && source toaster start webport=%d && source toaster stop'" % (config.testdir, config.TOASTER_PORT), config.testdir)
48 except ShellCmdException as e: 51 except ShellCmdException as e:
49 self.fail("Failed starting interactive mode: %s" % (e)) 52 self.fail("Failed starting interactive mode: %s" % (e))
50 53
51 def test_start_managed_mode(self): 54 def test_start_managed_mode(self):
52 try: 55 try:
53 run_shell_cmd("./poky/bitbake/bin/toaster webport=56789 & sleep 10 && curl http://localhost:56789/ && kill -2 %1") 56 run_shell_cmd("%s/bitbake/bin/toaster webport=%d nobrowser & sleep 10 && curl http://localhost:%d/ && kill -2 %1" % (config.testdir, config.TOASTER_PORT, config.TOASTER_PORT), config.testdir)
54 pass 57 pass
55 except ShellCmdException as e: 58 except ShellCmdException as e:
56 self.fail("Failed starting managed mode: %s" % (e)) 59 self.fail("Failed starting managed mode: %s" % (e))
57 60
61class TestHTML5Compliance(unittest.TestCase):
62 def setUp(self):
63 self.origdir = os.getcwd()
64 self.crtdir = os.path.dirname(config.testdir)
65 os.chdir(self.crtdir)
66 if not os.path.exists(os.path.join(self.crtdir, "toaster.sqlite")):
67 run_shell_cmd("%s/bitbake/lib/toaster/manage.py syncdb --noinput" % config.testdir)
68 run_shell_cmd("%s/bitbake/lib/toaster/manage.py migrate orm" % config.testdir)
69 run_shell_cmd("%s/bitbake/lib/toaster/manage.py migrate bldcontrol" % config.testdir)
70 run_shell_cmd("%s/bitbake/lib/toaster/manage.py loadconf %s/meta-yocto/conf/toasterconf.json" % (config.testdir, config.testdir))
71
72 setup = pexpect.spawn("%s/bitbake/lib/toaster/manage.py checksettings" % config.testdir)
73 setup.logfile = sys.stdout
74 setup.expect(r".*or type the full path to a different directory: ")
75 setup.sendline('')
76 setup.sendline('')
77 setup.expect(r".*or type the full path to a different directory: ")
78 setup.sendline('')
79 setup.expect(r"Enter your option: ")
80 setup.sendline('0')
81
82 self.child = pexpect.spawn("%s/bitbake/bin/toaster webport=%d nobrowser" % (config.testdir, config.TOASTER_PORT))
83 self.child.logfile=sys.stdout
84 self.child.expect("Toaster is now running. You can stop it with Ctrl-C")
85
86 def test_html5_compliance(self):
87 import urllist, urlcheck
88 results = {}
89 for url in urllist.URLS:
90 results[url] = urlcheck.validate_html5(config.TOASTER_BASEURL + url)
91
92 failed = []
93 for url in results:
94 if results[url][1] != 0:
95 failed.append((url, results[url]))
96
97
98 self.assertTrue(len(failed)== 0, "Not all URLs validate: \n%s " % "\n".join(map(lambda x: "".join(str(x)),failed)))
99
100 #(config.TOASTER_BASEURL + url, status, errors, warnings))
101
102 def tearDown(self):
103 while self.child.isalive():
104 self.child.kill(signal.SIGINT)
105 time.sleep(1)
106 os.chdir(self.origdir)
107# if os.path.exists(os.path.join(self.crtdir, "toaster.sqlite")):
108# os.remove(os.path.join(self.crtdir, "toaster.sqlite"))