Add extensible SDK update test
v2 cover Add extensible SDK update test
The following changes since commit ea8c34e976c11757ed9869c51b48f39050e25708:
libnewt: Fix build with PIE flags (2016-02-21 09:32:43 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib alimon/esdk_update_v2
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=alimon/esdk_update_v2
Aníbal Limón (4):
classes/testsdk: Move code for avoid PATHs to oeqa.utils classes/testsdk: Move the removal of bitbake PATH to eSDK context only classes/testsdk: Pass tcname to SDK and SDKExt contexts oeqa/sdkext: Add sdk_update.SDKUpdateTest class.
meta/classes/testsdk.bbclass | 29 +++++++++------------------- meta/lib/oeqa/oetest.py | 19 +++++++++++++++---- meta/lib/oeqa/sdkext/sdk_update.py | 39 ++++++++++++++++++++++++++++++++++++++ meta/lib/oeqa/utils/__init__.py | 23 ++++++++++++++++++++++ 4 files changed, 86 insertions(+), 24 deletions(-) create mode 100644 meta/lib/oeqa/sdkext/sdk_update.py
Signature · 1 line
2.1.4
PATCH v2 1/4 classes/testsdk: Move code for avoid PATHs to oeqa.utils
From: Aníbal Limón <[email protected]>
Due to the neeed to use in other modules.
--- meta/classes/testsdk.bbclass | 18 ++++-------------- meta/lib/oeqa/utils/__init__.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 14 deletions(-)
meta/classes/testsdk.bbclass +4 -14
@@ -88,30 +88,20 @@ def testsdkext_main(d): import os import oeqa.sdkext import subprocess - from oeqa.oetest import SDKTestContext, SDKExtTestContext from bb.utils import export_proxies + from oeqa.oetest import SDKTestContext, SDKExtTestContext + from oeqa.utils import avoid_paths_in_environ + # extensible sdk use network export_proxies(d) # extensible sdk shows a warning if found bitbake in the path # because can cause problems so clean it - new_path = '' paths_to_avoid = ['bitbake/bin', 'poky/scripts', d.getVar('STAGING_DIR', True), d.getVar('BASE_WORKDIR', True)] - for p in os.environ['PATH'].split(':'): - avoid = False - for pa in paths_to_avoid: - if pa in p: - avoid = True - break - if avoid: - continue - - new_path = new_path + p + ':' - new_path = new_path[:-1] - os.environ['PATH'] = new_path + os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid) pn = d.getVar("PN", True) bb.utils.mkdirhier(d.getVar("TEST_LOG_SDKEXT_DIR", True))
meta/lib/oeqa/utils/__init__.py +23 -0
@@ -13,3 +13,26 @@ class CommandError(Exception): def __str__(self): return "Command '%s' returned non-zero exit status %d with output: %s" % (self.cmd, self.retcode, self.output) +def avoid_paths_in_environ(paths): + """ + Searches for every path in os.environ['PATH'] + if found remove it. + + Returns new PATH without avoided PATHs. + """ + import os + + new_path = '' + for p in os.environ['PATH'].split(':'): + avoid = False + for pa in paths: + if pa in p: + avoid = True + break + if avoid: + continue + + new_path = new_path + p + ':' + + new_path = new_path[:-1] + return new_path
Signature · 1 line
2.1.4
PATCH v2 2/4 classes/testsdk: Move the removal of bitbake PATH to eSDK context only
In reply to Aníbal LimónFrom: Aníbal Limón <[email protected]>
The removal of bitbake and scripts PATH is only needed by eSDK tests so move to eSDK context only.
This also it's a support for eSDK update test because it needs to execute oe-publish-sdk from scripts.
--- meta/classes/testsdk.bbclass | 9 ++++----- meta/lib/oeqa/oetest.py | 12 +++++++++++- 2 files changed, 15 insertions(+), 6 deletions(-)
meta/classes/testsdk.bbclass +4 -5
@@ -96,11 +96,10 @@ def testsdkext_main(d): # extensible sdk use network export_proxies(d) - # extensible sdk shows a warning if found bitbake in the path - # because can cause problems so clean it - paths_to_avoid = ['bitbake/bin', 'poky/scripts', - d.getVar('STAGING_DIR', True), - d.getVar('BASE_WORKDIR', True)] + # extensible sdk can be contaminated if native programs are + # in PATH, i.e. use perl-native instead of eSDK one. + paths_to_avoid = [d.getVar('STAGING_DIR', True), + d.getVar('BASE_WORKDIR', True)] os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid) pn = d.getVar("PN", True)
meta/lib/oeqa/oetest.py +11 -1
@@ -21,6 +21,7 @@ import logging import oeqa.runtime import oeqa.sdkext from oeqa.utils.decorators import LogResults, gettag, getResults +from oeqa.utils import avoid_paths_in_environ logger = logging.getLogger("BitBake")
@@ -128,7 +129,16 @@ class oeSDKTest(oeTest): return subprocess.check_output(". %s > /dev/null; %s;" % (self.tc.sdkenv, cmd), shell=True) class oeSDKExtTest(oeSDKTest): - pass + def _run(self, cmd): + # extensible sdk shows a warning if found bitbake in the path + # because can cause contamination, i.e. use devtool from + # poky/scripts instead of eSDK one. + env = os.environ.copy() + paths_to_avoid = ['bitbake/bin', 'poky/scripts'] + env['PATH'] = avoid_paths_in_environ(paths_to_avoid) + + return subprocess.check_output(". %s > /dev/null;"\ + " %s;" % (self.tc.sdkenv, cmd), shell=True, env=env) def getmodule(pos=2): # stack returns a list of tuples containg frame information
Signature · 1 line
2.1.4
PATCH v2 3/4 classes/testsdk: Pass tcname to SDK and SDKExt contexts
In reply to Aníbal LimónFrom: Aníbal Limón <[email protected]>
tcname is needed for eSDK update testcase will be used for
publish it and then try to update
--- meta/classes/testsdk.bbclass | 2 +- meta/lib/oeqa/oetest.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
meta/classes/testsdk.bbclass +1 -1
@@ -22,7 +22,7 @@ def run_test_context(CTestContext, d, testdir, tcname, pn, *args): targets = glob.glob(d.expand(testdir + "/tc/environment-setup-*")) for sdkenv in targets: bb.plain("Testing %s" % sdkenv) - tc = CTestContext(d, testdir, sdkenv, args) + tc = CTestContext(d, testdir, sdkenv, tcname, args) # this is a dummy load of tests # we are doing that to find compile errors in the tests themselves
meta/lib/oeqa/oetest.py +4 -3
@@ -386,11 +386,12 @@ class ImageTestContext(TestContext): setattr(oeRuntimeTest, "pscmd", "ps -ef" if oeTest.hasPackage("procps") else "ps") class SDKTestContext(TestContext): - def __init__(self, d, sdktestdir, sdkenv, *args): + def __init__(self, d, sdktestdir, sdkenv, tcname, *args): super(SDKTestContext, self).__init__(d) self.sdktestdir = sdktestdir self.sdkenv = sdkenv + self.tcname = tcname if not hasattr(self, 'target_manifest'): self.target_manifest = d.getVar("SDK_TARGET_MANIFEST", True)
@@ -419,7 +420,7 @@ class SDKTestContext(TestContext): "auto").split() if t != "auto"] class SDKExtTestContext(SDKTestContext): - def __init__(self, d, sdktestdir, sdkenv, *args): + def __init__(self, d, sdktestdir, sdkenv, tcname, *args): self.target_manifest = d.getVar("SDK_EXT_TARGET_MANIFEST", True) self.host_manifest = d.getVar("SDK_EXT_HOST_MANIFEST", True) if args:
@@ -427,7 +428,7 @@ class SDKExtTestContext(SDKTestContext): else: self.cm = False - super(SDKExtTestContext, self).__init__(d, sdktestdir, sdkenv) + super(SDKExtTestContext, self).__init__(d, sdktestdir, sdkenv, tcname) self.sdkextfilesdir = os.path.join(os.path.dirname(os.path.abspath( oeqa.sdkext.__file__)), "files")
Signature · 1 line
2.1.4
PATCH v2 4/4 oeqa/sdkext: Add sdk_update.SDKUpdateTest class.
In reply to Aníbal LimónFrom: Aníbal Limón <[email protected]>
The SDKUpdateTest class test devtool sdk-update mechanism inside eSDK.
The SDKUpdateTest class search for new sdk if not found uses the main one then it publish the eSDK into known folder inside work and it starts a web server for serve the eSDK.
Finally it executes sdk-update over http, the local test is commented due to bug [1].
[1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=9043
[YOCTO #9089]
--- meta/lib/oeqa/sdkext/sdk_update.py | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 meta/lib/oeqa/sdkext/sdk_update.py
meta/lib/oeqa/sdkext/sdk_update.py new file +39 -0
@@ -0,0 +1,39 @@ +import os +import shutil +import subprocess + +from oeqa.oetest import oeSDKExtTest +from oeqa.utils.httpserver import HTTPService + +class SdkUpdateTest(oeSDKExtTest): + + @classmethod + def setUpClass(self): + self.publish_dir = os.path.join(self.tc.sdktestdir, 'esdk_publish') + if os.path.exists(self.publish_dir): + shutil.rmtree(self.publish_dir) + os.mkdir(self.publish_dir) + + tcname_new = self.tc.d.expand( + "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}-new.sh") + if not os.path.exists(tcname_new): + tcname_new = self.tc.tcname + + cmd = 'oe-publish-sdk %s %s' % (tcname_new, self.publish_dir) + subprocess.check_output(cmd, shell=True) + + self.http_service = HTTPService(self.publish_dir) + self.http_service.start() + + self.http_url = "http://127.0.0.1:%d" % self.http_service.port + + def test_sdk_update_http(self): + output = self._run("devtool sdk-update \"%s\"" % self.http_url) + +# def test_sdk_update_local(self): +# output = self._run("devtool sdk-update \"%s\"" % self.publish_dir) + + @classmethod + def tearDownClass(self): + self.http_service.stop() + shutil.rmtree(self.publish_dir)
Signature · 1 line
2.1.4
Re: [PATCHv2 4/4] oeqa/sdkext: Add sdk_update.SDKUpdateTest class.
Hi Aníbal,
Quoted 57 lines · On Mon, 22 Feb 2016 12:31:33 Aníbal Limón wrote:
From: Aníbal Limón <[email protected]>
The SDKUpdateTest class test devtool sdk-update mechanism inside eSDK.
The SDKUpdateTest class search for new sdk if not found uses the main one then it publish the eSDK into known folder inside work and it starts a web server for serve the eSDK.
Finally it executes sdk-update over http, the local test is commented due to bug [1].
[1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=9043
[YOCTO #9089]
Signed-off-by Aníbal Limón <[email protected]>--- meta/lib/oeqa/sdkext/sdk_update.py | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 meta/lib/oeqa/sdkext/sdk_update.py(quoted diff) +0
-0
b/meta/lib/oeqa/sdkext/sdk_update.pynew file mode 100644 index 0000000..16f5b10meta/lib/oeqa/sdkext/sdk_update.py new file +29
-0@@ -0,0 +1,39 @@ +import os +import shutil +import subprocess + +from oeqa.oetest import oeSDKExtTest +from oeqa.utils.httpserver import HTTPService + +class SdkUpdateTest(oeSDKExtTest): + + @classmethod + def setUpClass(self): + self.publish_dir = os.path.join(self.tc.sdktestdir, 'esdk_publish') + if os.path.exists(self.publish_dir): + shutil.rmtree(self.publish_dir) + os.mkdir(self.publish_dir) + + tcname_new = self.tc.d.expand( + "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}-new.sh") + if not os.path.exists(tcname_new): + tcname_new = self.tc.tcname + + cmd = 'oe-publish-sdk %s %s' % (tcname_new, self.publish_dir) + subprocess.check_output(cmd, shell=True) + + self.http_service = HTTPService(self.publish_dir) + self.http_service.start() + + self.http_url = "http://127.0.0.1:%d" % self.http_service.port +
meta/lib/oeqa/sdkext/sdk_update.py line 39
Quoted 10 lines
meta/lib/oeqa/sdkext/sdk_update.py new file +10
-0+ def test_sdk_update_http(self): + output = self._run("devtool sdk-update \"%s\"" % self.http_url) + +# def test_sdk_update_local(self): +# output = self._run("devtool sdk-update \"%s\"" % self.publish_dir) + + @classmethod + def tearDownClass(self): + self.http_service.stop() + shutil.rmtree(self.publish_dir)
You're testing invocation of the sdk-update command, but nothing much beyond that - the update isn't going to be doing anything here since nothing will have changed. However since this would involve modifying the metadata though I guess that may have to be done as an oe-selftest test.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre
Re: [PATCHv2 4/4] oeqa/sdkext: Add sdk_update.SDKUpdateTest class.
Quoted 67 lines · Paul Eggleton
Hi Aníbal,
Quoted 64 lines · On Mon, 22 Feb 2016 12:31:33 Aníbal Limón wrote:
From: Aníbal Limón <[email protected]>
The SDKUpdateTest class test devtool sdk-update mechanism inside eSDK.
The SDKUpdateTest class search for new sdk if not found uses the main one then it publish the eSDK into known folder inside work and it starts a web server for serve the eSDK.
Finally it executes sdk-update over http, the local test is commented due to bug [1].
[1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=9043
[YOCTO #9089]
Signed-off-by Aníbal Limón <[email protected]>--- meta/lib/oeqa/sdkext/sdk_update.py | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 meta/lib/oeqa/sdkext/sdk_update.py(quoted diff) +0
-0
b/meta/lib/oeqa/sdkext/sdk_update.pynew file mode 100644 index 0000000..16f5b10meta/lib/oeqa/sdkext/sdk_update.py new file +36
-0@@ -0,0 +1,39 @@ +import os +import shutil +import subprocess + +from oeqa.oetest import oeSDKExtTest +from oeqa.utils.httpserver import HTTPService + +class SdkUpdateTest(oeSDKExtTest): + + @classmethod + def setUpClass(self): + self.publish_dir = os.path.join(self.tc.sdktestdir, 'esdk_publish') + if os.path.exists(self.publish_dir): + shutil.rmtree(self.publish_dir) + os.mkdir(self.publish_dir) + + tcname_new = self.tc.d.expand( + "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}-new.sh") + if not os.path.exists(tcname_new): + tcname_new = self.tc.tcname + + cmd = 'oe-publish-sdk %s %s' % (tcname_new, self.publish_dir) + subprocess.check_output(cmd, shell=True) + + self.http_service = HTTPService(self.publish_dir) + self.http_service.start() + + self.http_url = "http://127.0.0.1:%d" % self.http_service.port + + def test_sdk_update_http(self): + output = self._run("devtool sdk-update \"%s\"" % self.http_url) + +# def test_sdk_update_local(self): +# output = self._run("devtool sdk-update \"%s\"" % self.publish_dir) + + @classmethod
Quoted 8 lines
meta/lib/oeqa/sdkext/sdk_update.py line 39
Quoted 3 lines
meta/lib/oeqa/sdkext/sdk_update.py new file +3
-0+ def tearDownClass(self): + self.http_service.stop() + shutil.rmtree(self.publish_dir)You're testing invocation of the sdk-update command, but nothing much beyond that - the update isn't going to be doing anything here since nothing will have changed. However since this would involve modifying the metadata though I guess that may have to be done as an oe-selftest test.
Yes Paul is only testing the exeution of sdk update command but if you read the commit comment (may be i'm not too clear) the test search for a new sdk with -new suffix the AB or selftest could easily modify the meta data and then generate new eSDK.
alimon
Quoted 4 lines
Cheers,
Paul