summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorMihai Prica <mihai.prica@intel.com>2013-08-19 15:25:23 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-26 11:47:21 +0100
commitc70bf6531c7aa0c2d1124ab4cffa91d16cc0109c (patch)
treec021f336d2ecb69ea7886024b81c09feb7f04673 /meta/lib/oeqa/utils
parent51588936d4a8cde3c9bb05800240c0a0f5dedf8d (diff)
downloadpoky-c70bf6531c7aa0c2d1124ab4cffa91d16cc0109c.tar.gz
lib/oeqa/utils: targetbuild: Add helper class for building packages on target
This class can be used for test cases that configure and build packages on target. (From OE-Core rev: 4b15e82c4fcb0c40b0e316ef2050944eee4418ef) Signed-off-by: Mihai Prica <mihai.prica@intel.com> Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/targetbuild.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py
new file mode 100644
index 0000000000..9b2cf53773
--- /dev/null
+++ b/meta/lib/oeqa/utils/targetbuild.py
@@ -0,0 +1,63 @@
1# Copyright (C) 2013 Intel Corporation
2#
3# Released under the MIT license (see COPYING.MIT)
4
5# Provides a class for automating build tests for projects
6
7from oeqa.oetest import oeRuntimeTest
8import bb.fetch2
9import bb.data
10import os
11import re
12
13
14class TargetBuildProject():
15
16 def __init__(self, target, uri, foldername=None):
17 self.target = target
18 self.uri = uri
19 self.targetdir = "/home/root/"
20
21 self.localdata = bb.data.createCopy(oeRuntimeTest.tc.d)
22 bb.data.update_data(self.localdata)
23
24 if not foldername:
25 self.archive = os.path.basename(uri)
26 self.fname = re.sub(r'.tar.bz2|tar.gz$', '', self.archive)
27 else:
28 self.fname = foldername
29
30 def download_archive(self):
31
32 try:
33 self.localdata.delVar("BB_STRICT_CHECKSUM")
34 fetcher = bb.fetch2.Fetch([self.uri], self.localdata)
35 fetcher.download()
36 self.localarchive = fetcher.localpath(self.uri)
37 except bb.fetch2.BBFetchException:
38 raise Exception("Failed to download archive: %s" % self.uri)
39
40 (status, output) = self.target.copy_to(self.localarchive, self.targetdir)
41 if status != 0:
42 raise Exception("Failed to copy archive to target, output: %s" % output)
43
44 (status, output) = self.target.run('tar xf %s%s -C %s' % (self.targetdir, self.archive, self.targetdir))
45 if status != 0:
46 raise Exception("Failed to extract archive, output: %s" % output)
47
48 #Change targetdir to project folder
49 self.targetdir = self.targetdir + self.fname
50
51 # The timeout parameter of target.run is set to 0 to make the ssh command
52 # run with no timeout.
53 def run_configure(self):
54 return self.target.run('cd %s; ./configure' % self.targetdir, 0)[0]
55
56 def run_make(self):
57 return self.target.run('cd %s; make' % self.targetdir, 0)[0]
58
59 def run_install(self):
60 return self.target.run('cd %s; make install' % self.targetdir, 0)[0]
61
62 def clean(self):
63 self.target.run('rm -rf %s' % self.targetdir)