summaryrefslogtreecommitdiffstats
path: root/meta/lib
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:42:15 +0100
commit4b15e82c4fcb0c40b0e316ef2050944eee4418ef (patch)
treea9b8bba135221cd7a4dc2f0468c2c3a3435873d9 /meta/lib
parent9de7fe11967576f4a8b24e653c6b9a02e5f6d85b (diff)
downloadopenembedded-core-4b15e82c4fcb0c40b0e316ef2050944eee4418ef.tar.gz
openembedded-core-4b15e82c4fcb0c40b0e316ef2050944eee4418ef.tar.bz2
openembedded-core-4b15e82c4fcb0c40b0e316ef2050944eee4418ef.zip
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. 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>
Diffstat (limited to 'meta/lib')
-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 @@
+# Copyright (C) 2013 Intel Corporation
+#
+# Released under the MIT license (see COPYING.MIT)
+
+# Provides a class for automating build tests for projects
+
+from oeqa.oetest import oeRuntimeTest
+import bb.fetch2
+import bb.data
+import os
+import re
+
+
+class TargetBuildProject():
+
+ def __init__(self, target, uri, foldername=None):
+ self.target = target
+ self.uri = uri
+ self.targetdir = "/home/root/"
+
+ self.localdata = bb.data.createCopy(oeRuntimeTest.tc.d)
+ bb.data.update_data(self.localdata)
+
+ if not foldername:
+ self.archive = os.path.basename(uri)
+ self.fname = re.sub(r'.tar.bz2|tar.gz$', '', self.archive)
+ else:
+ self.fname = foldername
+
+ def download_archive(self):
+
+ try:
+ self.localdata.delVar("BB_STRICT_CHECKSUM")
+ fetcher = bb.fetch2.Fetch([self.uri], self.localdata)
+ fetcher.download()
+ self.localarchive = fetcher.localpath(self.uri)
+ except bb.fetch2.BBFetchException:
+ raise Exception("Failed to download archive: %s" % self.uri)
+
+ (status, output) = self.target.copy_to(self.localarchive, self.targetdir)
+ if status != 0:
+ raise Exception("Failed to copy archive to target, output: %s" % output)
+
+ (status, output) = self.target.run('tar xf %s%s -C %s' % (self.targetdir, self.archive, self.targetdir))
+ if status != 0:
+ raise Exception("Failed to extract archive, output: %s" % output)
+
+ #Change targetdir to project folder
+ self.targetdir = self.targetdir + self.fname
+
+ # The timeout parameter of target.run is set to 0 to make the ssh command
+ # run with no timeout.
+ def run_configure(self):
+ return self.target.run('cd %s; ./configure' % self.targetdir, 0)[0]
+
+ def run_make(self):
+ return self.target.run('cd %s; make' % self.targetdir, 0)[0]
+
+ def run_install(self):
+ return self.target.run('cd %s; make install' % self.targetdir, 0)[0]
+
+ def clean(self):
+ self.target.run('rm -rf %s' % self.targetdir)