1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 00:59:48 +00:00

selftest/eSDK.py: Cleanup when there is an error in setUpClass

Lately autobuilders are experiencing hangs with selftest,
it seems it is cause if an error happens in setUpClass
method of oeSDKExtSelfTest class because HTTP server
keeps running in background.

This patch will ensure tearDownClass will be run if there
is an error in setUpClass.

(From OE-Core rev: eb1383949f76c6eb36f86c051057f761a71016a3)

(From OE-Core rev: 5dc68a378d9f4ec2c313ac395e91225a02e5b2c7)

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Mariano Lopez
2017-02-22 13:12:55 +00:00
committed by Richard Purdie
parent 4ff1c8ddba
commit ce4016c070
+25 -21
View File
@@ -64,7 +64,7 @@ class oeSDKExtSelfTest(oeSelfTest):
runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA)) runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA) cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
sstate_config=""" sstate_config="""
SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS" SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
SSTATE_MIRRORS = "file://.* http://%s/PATH" SSTATE_MIRRORS = "file://.* http://%s/PATH"
@@ -73,37 +73,41 @@ CORE_IMAGE_EXTRA_INSTALL = "perl"
with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f: with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
f.write(sstate_config) f.write(sstate_config)
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
# Start to serve sstate dir # If there is an exception in setUpClass it will not run tearDownClass
sstate_dir = get_bb_var('SSTATE_DIR') # method and it leaves HTTP server running forever, so we need to be
cls.http_service = HTTPService(sstate_dir) # sure tearDownClass is run.
cls.http_service.start() try:
cls.tmpdir_eSDKQA = tempfile.mkdtemp(prefix='eSDKQA')
cls.http_url = "http://127.0.0.1:%d" % cls.http_service.port # Start to serve sstate dir
sstate_dir = get_bb_var('SSTATE_DIR')
cls.image = 'core-image-minimal' cls.http_service = HTTPService(sstate_dir)
cls.http_url = "http://127.0.0.1:%d" % cls.http_service.port
cls.http_service.start()
cls.tmpdir_eSDKQA = tempfile.mkdtemp(prefix='eSDKQA') cls.image = 'core-image-minimal'
oeSDKExtSelfTest.generate_eSDK(cls.image) oeSDKExtSelfTest.generate_eSDK(cls.image)
# Install eSDK # Install eSDK
cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image) cls.ext_sdk_path = oeSDKExtSelfTest.get_eSDK_toolchain(cls.image)
runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA)) runCmd("%s -y -d \"%s\"" % (cls.ext_sdk_path, cls.tmpdir_eSDKQA))
cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA) cls.env_eSDK = oeSDKExtSelfTest.get_esdk_environment('', cls.tmpdir_eSDKQA)
# Configure eSDK to use sstate mirror from poky # Configure eSDK to use sstate mirror from poky
sstate_config=""" sstate_config="""
SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS" SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS"
SSTATE_MIRRORS = "file://.* http://%s/PATH" SSTATE_MIRRORS = "file://.* http://%s/PATH"
""" % cls.http_url """ % cls.http_url
with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f: with open(os.path.join(cls.tmpdir_eSDKQA, 'conf', 'local.conf'), 'a+') as f:
f.write(sstate_config) f.write(sstate_config)
except:
cls.tearDownClass()
raise
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
shutil.rmtree(cls.tmpdir_eSDKQA) shutil.rmtree(cls.tmpdir_eSDKQA)