diff options
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r-- | meta/lib/oeqa/utils/targetbuild.py | 63 |
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 | |||
7 | from oeqa.oetest import oeRuntimeTest | ||
8 | import bb.fetch2 | ||
9 | import bb.data | ||
10 | import os | ||
11 | import re | ||
12 | |||
13 | |||
14 | class 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) | ||