[OE-core] [PATCH 12/21] lib/oeqa/utils: targetbuild: Add helper class for building packages on target
Stefan Stanacar
stefanx.stanacar at intel.com
Fri Aug 23 15:30:52 UTC 2013
From: Mihai Prica <mihai.prica at intel.com>
This class can be used for test cases that configure
and build packages on target.
Signed-off-by: Mihai Prica <mihai.prica at intel.com>
Signed-off-by: Stefan Stanacar <stefanx.stanacar at intel.com>
---
meta/lib/oeqa/utils/targetbuild.py | 66 ++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
create mode 100644 meta/lib/oeqa/utils/targetbuild.py
diff --git a/meta/lib/oeqa/utils/targetbuild.py b/meta/lib/oeqa/utils/targetbuild.py
new file mode 100644
index 0000000..7555add
--- /dev/null
+++ b/meta/lib/oeqa/utils/targetbuild.py
@@ -0,0 +1,66 @@
+# 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
+from oeqa.utils.decorators import *
+import bb.process
+import os
+import re
+
+
+class TargetBuildProject():
+
+ def __init__(self, target, uri, foldername=None):
+ self.target = target
+ self.uri = uri
+ self.targetdir = "/home/root/"
+
+ 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):
+ wgetcmd = oeRuntimeTest.tc.d.getVar('FETCHCMD_wget', True).split()
+ self.testdir = oeRuntimeTest.tc.d.getVar('TEST_LOG_DIR', True)
+
+ try:
+ output = bb.process.run(wgetcmd + ['-P', self.testdir, self.uri])[0]
+ except bb.process.CmdError:
+ raise Exception("Failed to download archive, output: %s" % output)
+
+ (status, output) = oeRuntimeTest.tc.target.copy_to(
+ os.path.join(self.testdir, self.archive),
+ self.targetdir)
+ if status != 0:
+ raise Exception("Failed to copy archive to target, output: %s" % output)
+
+ (status, output) = oeRuntimeTest.tc.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 -r %s*' % self.targetdir)
+ try:
+ bb.process.run(['rm', '-rf', os.path.join(self.testdir, self.archive)])
+ except bb.process.CmdError:
+ bb.note("Failed to remove archive")
--
1.8.3.1
More information about the Openembedded-core
mailing list