summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-10-28 18:48:44 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-04 12:50:55 +0000
commit953b2f50f003a53fc387edfdeb8aa96d904526b2 (patch)
tree1cda5e8447cfea32e6cc294b8abd614ed7960ec5
parenteffbf9e09e527a4bfb1e1ba5146ade2bad02e673 (diff)
downloadpoky-953b2f50f003a53fc387edfdeb8aa96d904526b2.tar.gz
bitbake: toaster: Delete useless bldcontrol/test
It doesn't work nor does it test anything useful (Bitbake rev: cf727757767d96b2cd2055f519289712bdf0e505) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/bldcontrol/tests.py141
1 files changed, 0 insertions, 141 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/tests.py b/bitbake/lib/toaster/bldcontrol/tests.py
deleted file mode 100644
index 475ac0a16f..0000000000
--- a/bitbake/lib/toaster/bldcontrol/tests.py
+++ /dev/null
@@ -1,141 +0,0 @@
1"""
2This file demonstrates writing tests using the unittest module. These will pass
3when you run "manage.py test".
4
5Replace this with more appropriate tests for your application.
6"""
7
8from django.test import TestCase
9
10from bldcontrol.bbcontroller import BitbakeController, BuildSetupException
11from bldcontrol.localhostbecontroller import LocalhostBEController
12from bldcontrol.models import BuildEnvironment, BuildRequest
13from bldcontrol.management.commands.runbuilds import Command
14
15import socket
16import subprocess
17import os
18
19# standard poky data hardcoded for testing
20BITBAKE_LAYER = type('bitbake_info', (object,), { "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "", "commit": "HEAD"})
21POKY_LAYERS = [
22 type('poky_info', (object,), { "name": "meta", "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "meta", "commit": "HEAD"}),
23 type('poky_info', (object,), { "name": "meta-yocto", "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "meta-yocto", "commit": "HEAD"}),
24 type('poky_info', (object,), { "name": "meta-yocto-bsp", "giturl": "git://git.yoctoproject.org/poky.git", "dirpath": "meta-yocto-bsp", "commit": "HEAD"}),
25 ]
26
27
28
29# we have an abstract test class designed to ensure that the controllers use a single interface
30# specific controller tests only need to override the _getBuildEnvironment() method
31
32test_sourcedir = os.getenv("TTS_SOURCE_DIR")
33test_builddir = os.getenv("TTS_BUILD_DIR")
34test_address = os.getenv("TTS_TEST_ADDRESS", "localhost")
35
36if test_sourcedir == None or test_builddir == None or test_address == None:
37 raise Exception("Please set TTTS_SOURCE_DIR, TTS_BUILD_DIR and TTS_TEST_ADDRESS")
38
39# The bb server will expect a toaster-pre.conf file to exist. If it doesn't exit then we make
40# an empty one here.
41open(test_builddir + 'conf/toaster-pre.conf', 'a').close()
42
43class BEControllerTests(object):
44
45 def _serverForceStop(self, bc):
46 err = bc._shellcmd("netstat -tapn 2>/dev/null | grep 8200 | awk '{print $7}' | sort -fu | cut -d \"/\" -f 1 | grep -v -- - | tee /dev/fd/2 | xargs -r kill")
47 self.assertTrue(err == '', "bitbake server pid %s not stopped" % err)
48
49 def test_serverStartAndStop(self):
50 obe = self._getBuildEnvironment()
51 bc = self._getBEController(obe)
52 try:
53 # setting layers, skip any layer info
54 bc.setLayers(BITBAKE_LAYER, POKY_LAYERS)
55 except NotImplementedError:
56 print("Test skipped due to command not implemented yet")
57 return True
58 # We are ok with the exception as we're handling the git already exists
59 except BuildSetupException:
60 pass
61
62 bc.pokydirname = test_sourcedir
63 bc.islayerset = True
64
65 hostname = test_address.split("@")[-1]
66
67 # test start server and stop
68 bc.startBBServer()
69
70 self.assertFalse(socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex((hostname, int(bc.be.bbport))), "Server not answering")
71
72 self._serverForceStop(bc)
73
74 def test_getBBController(self):
75 obe = self._getBuildEnvironment()
76 bc = self._getBEController(obe)
77 layerSet = False
78 try:
79 # setting layers, skip any layer info
80 layerSet = bc.setLayers(BITBAKE_LAYER, POKY_LAYERS)
81 except NotImplementedError:
82 print("Test skipped due to command not implemented yet")
83 return True
84 # We are ok with the exception as we're handling the git already exists
85 except BuildSetupException:
86 pass
87
88 bc.pokydirname = test_sourcedir
89 bc.islayerset = True
90
91 bbc = bc.getBBController()
92 self.assertTrue(isinstance(bbc, BitbakeController))
93
94 self._serverForceStop(bc)
95
96class LocalhostBEControllerTests(TestCase, BEControllerTests):
97 def __init__(self, *args):
98 super(LocalhostBEControllerTests, self).__init__(*args)
99
100
101 def _getBuildEnvironment(self):
102 return BuildEnvironment.objects.create(
103 lock = BuildEnvironment.LOCK_FREE,
104 betype = BuildEnvironment.TYPE_LOCAL,
105 address = test_address,
106 sourcedir = test_sourcedir,
107 builddir = test_builddir )
108
109 def _getBEController(self, obe):
110 return LocalhostBEController(obe)
111
112class RunBuildsCommandTests(TestCase):
113 def test_bec_select(self):
114 """
115 Tests that we can find and lock a build environment
116 """
117
118 obe = BuildEnvironment.objects.create(lock = BuildEnvironment.LOCK_FREE, betype = BuildEnvironment.TYPE_LOCAL)
119 command = Command()
120 bec = command._selectBuildEnvironment()
121
122 # make sure we select the object we've just built
123 self.assertTrue(bec.be.id == obe.id, "Environment is not properly selected")
124 # we have a locked environment
125 self.assertTrue(bec.be.lock == BuildEnvironment.LOCK_LOCK, "Environment is not locked")
126 # no more selections possible here
127 self.assertRaises(IndexError, command._selectBuildEnvironment)
128
129 def test_br_select(self):
130 from orm.models import Project, Release, BitbakeVersion, Branch
131 p = Project.objects.create_project("test", Release.objects.get_or_create(name = "HEAD", bitbake_version = BitbakeVersion.objects.get_or_create(name="HEAD", branch=Branch.objects.get_or_create(name="HEAD"))[0])[0])
132 obr = BuildRequest.objects.create(state = BuildRequest.REQ_QUEUED, project = p)
133 command = Command()
134 br = command._selectBuildRequest()
135
136 # make sure we select the object we've just built
137 self.assertTrue(obr.id == br.id, "Request is not properly selected")
138 # we have a locked environment
139 self.assertTrue(br.state == BuildRequest.REQ_INPROGRESS, "Request is not updated")
140 # no more selections possible here
141 self.assertRaises(IndexError, command._selectBuildRequest)