From: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
To: "Aníbal Limón" <anibal.limon@linux.intel.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 02/30] oeqa/selftest/{context, case}: Handle KeyboardInterrupt/SIGINT and SIGTERM
Date: Wed, 12 Jul 2017 09:18:19 -0500 [thread overview]
Message-ID: <1499869099.5349.38.camel@linux.intel.com> (raw)
In-Reply-To: <2e3872acacf41d159f477c2ca15e7eda0b85263b.1499803885.git.anibal.limon@linux.intel.com>
I saw a similar patch in the past. Is this a new revision?
Leo
On Tue, 2017-07-11 at 15:23 -0500, Aníbal Limón wrote:
> In order to avoid corrupt local.conf and bblayers.conf adds
> signal handler for SIGTERM and use try/finally (KeyboardIntrrupt) block
> to restore previously backuped configuration.
>
> [YOCTO #11650]
>
> Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
> ---
> meta/lib/oeqa/selftest/case.py | 36 +++++++------
> meta/lib/oeqa/selftest/context.py | 107 +++++++++++++++++++++++++++-----------
> 2 files changed, 97 insertions(+), 46 deletions(-)
>
> diff --git a/meta/lib/oeqa/selftest/case.py b/meta/lib/oeqa/selftest/case.py
> index 31a11fddda9..871009c568b 100644
> --- a/meta/lib/oeqa/selftest/case.py
> +++ b/meta/lib/oeqa/selftest/case.py
> @@ -13,28 +13,34 @@ from oeqa.utils.commands import runCmd, bitbake, get_bb_var
> from oeqa.core.case import OETestCase
>
> class OESelftestTestCase(OETestCase):
> - builddir = os.environ.get("BUILDDIR") or ""
> - localconf_path = os.path.join(builddir, "conf/local.conf")
> - localconf_backup = os.path.join(builddir, "conf/local.bk")
> - testinc_path = os.path.join(builddir, "conf/selftest.inc")
> - local_bblayers_path = os.path.join(builddir, "conf/bblayers.conf")
> - local_bblayers_backup = os.path.join(builddir, "conf/bblayers.bk")
> - testinc_bblayers_path = os.path.join(builddir, "conf/bblayers.inc")
> - machineinc_path = os.path.join(builddir, "conf/machine.inc")
> -
> def __init__(self, methodName="runTest"):
> self._extra_tear_down_commands = []
> - self._track_for_cleanup = [
> - self.testinc_path, self.testinc_bblayers_path,
> - self.machineinc_path, self.localconf_backup,
> - self.local_bblayers_backup]
> -
> super(OESelftestTestCase, self).__init__(methodName)
>
> @classmethod
> def setUpClass(cls):
> super(OESelftestTestCase, cls).setUpClass()
> - cls.testlayer_path = cls.tc.testlayer_path
> +
> + cls.testlayer_path = cls.tc.config_paths['testlayer_path']
> + cls.builddir = cls.tc.config_paths['builddir']
> +
> + cls.localconf_path = cls.tc.config_paths['localconf']
> + cls.localconf_backup = cls.tc.config_paths['localconf_class_backup']
> + cls.local_bblayers_path = cls.tc.config_paths['bblayers']
> + cls.local_bblayers_backup = cls.tc.config_paths['bblayers_class_backup']
> +
> + cls.testinc_path = os.path.join(cls.tc.config_paths['builddir'],
> + "conf/selftest.inc")
> + cls.testinc_bblayers_path = os.path.join(cls.tc.config_paths['builddir'],
> + "conf/bblayers.inc")
> + cls.machineinc_path = os.path.join(cls.tc.config_paths['builddir'],
> + "conf/machine.inc")
> +
> + cls._track_for_cleanup = [
> + cls.testinc_path, cls.testinc_bblayers_path,
> + cls.machineinc_path, cls.localconf_backup,
> + cls.local_bblayers_backup]
> +
> cls.add_include()
>
> @classmethod
> diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py
> index ca87398224c..4575a0537fb 100644
> --- a/meta/lib/oeqa/selftest/context.py
> +++ b/meta/lib/oeqa/selftest/context.py
> @@ -6,6 +6,8 @@ import time
> import glob
> import sys
> import imp
> +import signal
> +from shutil import copyfile
> from random import choice
>
> import oeqa
> @@ -16,13 +18,12 @@ from oeqa.core.exception import OEQAPreRun
> from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer
>
> class OESelftestTestContext(OETestContext):
> - def __init__(self, td=None, logger=None, machines=None, testlayer_path=None):
> + def __init__(self, td=None, logger=None, machines=None, config_paths=None):
> super(OESelftestTestContext, self).__init__(td, logger)
>
> self.machines = machines
> self.custommachine = None
> -
> - self.testlayer_path = testlayer_path
> + self.config_paths = config_paths
>
> def runTests(self, machine=None):
> if machine:
> @@ -108,7 +109,29 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
>
> self.tc_kwargs['init']['td'] = get_bb_vars()
> self.tc_kwargs['init']['machines'] = self._get_available_machines()
> - self.tc_kwargs['init']['testlayer_path'] = get_test_layer()
> +
> + builddir = os.environ.get("BUILDDIR")
> + self.tc_kwargs['init']['config_paths'] = {}
> + self.tc_kwargs['init']['config_paths']['testlayer_path'] = \
> + get_test_layer()
> + self.tc_kwargs['init']['config_paths']['builddir'] = builddir
> + self.tc_kwargs['init']['config_paths']['localconf'] = \
> + os.path.join(builddir, "conf/local.conf")
> + self.tc_kwargs['init']['config_paths']['localconf_backup'] = \
> + os.path.join(builddir, "conf/local.conf.orig")
> + self.tc_kwargs['init']['config_paths']['localconf_class_backup'] = \
> + os.path.join(builddir, "conf/local.conf.bk")
> + self.tc_kwargs['init']['config_paths']['bblayers'] = \
> + os.path.join(builddir, "conf/bblayers.conf")
> + self.tc_kwargs['init']['config_paths']['bblayers_backup'] = \
> + os.path.join(builddir, "conf/bblayers.conf.orig")
> + self.tc_kwargs['init']['config_paths']['bblayers_class_backup'] = \
> + os.path.join(builddir, "conf/bblayers.conf.bk")
> +
> + copyfile(self.tc_kwargs['init']['config_paths']['localconf'],
> + self.tc_kwargs['init']['config_paths']['localconf_backup'])
> + copyfile(self.tc_kwargs['init']['config_paths']['bblayers'],
> + self.tc_kwargs['init']['config_paths']['bblayers_backup'])
>
> def _pre_run(self):
> def _check_required_env_variables(vars):
> @@ -131,7 +154,7 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
> runCmd("bitbake-layers add-layer %s" %meta_selftestdir)
> # reload data is needed because a meta-selftest layer was add
> self.tc.td = get_bb_vars()
> - self.tc.testlayer_path = get_test_layer()
> + self.tc.config_paths['testlayer_path'] = get_test_layer()
> else:
> self.tc.logger.error("could not locate meta-selftest in:\n%s" % meta_selftestdir)
> raise OEQAPreRun
> @@ -184,41 +207,63 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
> rc.logSummary(self.name)
>
> return rc
> +
> + def _signal_clean_handler(self, signum, frame):
> + sys.exit(1)
>
> def run(self, logger, args):
> self._process_args(logger, args)
> - rc = None
>
> - if args.machine:
> - logger.info('Custom machine mode enabled. MACHINE set to %s' %
> - args.machine)
> + signal.signal(signal.SIGTERM, self._signal_clean_handler)
>
> - if args.machine == 'all':
> - results = []
> - for m in self.tc_kwargs['init']['machines']:
> - self.tc_kwargs['run']['machine'] = m
> - results.append(self._internal_run(logger, args))
> + rc = None
> + try:
> + if args.machine:
> + logger.info('Custom machine mode enabled. MACHINE set to %s' %
> + args.machine)
> +
> + if args.machine == 'all':
> + results = []
> + for m in self.tc_kwargs['init']['machines']:
> + self.tc_kwargs['run']['machine'] = m
> + results.append(self._internal_run(logger, args))
> +
> + # XXX: the oe-selftest script only needs to know if one
> + # machine run fails
> + for r in results:
> + rc = r
> + if not r.wasSuccessful():
> + break
>
> - # XXX: the oe-selftest script only needs to know if one
> - # machine run fails
> - for r in results:
> - rc = r
> - if not r.wasSuccessful():
> - break
> + else:
> + self.tc_kwargs['run']['machine'] = args.machine
> + return self._internal_run(logger, args)
>
> else:
> self.tc_kwargs['run']['machine'] = args.machine
> - return self._internal_run(logger, args)
> -
> - else:
> - self.tc_kwargs['run']['machine'] = args.machine
> - rc = self._internal_run(logger, args)
> -
> - output_link = os.path.join(os.path.dirname(args.output_log),
> - "%s-results.log" % self.name)
> - if os.path.exists(output_link):
> - os.remove(output_link)
> - os.symlink(args.output_log, output_link)
> + rc = self._internal_run(logger, args)
> + finally:
> + config_paths = self.tc_kwargs['init']['config_paths']
> + if os.path.exists(config_paths['localconf_backup']):
> + copyfile(config_paths['localconf_backup'],
> + config_paths['localconf'])
> + os.remove(config_paths['localconf_backup'])
> +
> + if os.path.exists(config_paths['bblayers_backup']):
> + copyfile(config_paths['bblayers_backup'],
> + config_paths['bblayers'])
> + os.remove(config_paths['bblayers_backup'])
> +
> + if os.path.exists(config_paths['localconf_class_backup']):
> + os.remove(config_paths['localconf_class_backup'])
> + if os.path.exists(config_paths['bblayers_class_backup']):
> + os.remove(config_paths['bblayers_class_backup'])
> +
> + output_link = os.path.join(os.path.dirname(args.output_log),
> + "%s-results.log" % self.name)
> + if os.path.exists(output_link):
> + os.remove(output_link)
> + os.symlink(args.output_log, output_link)
>
> return rc
>
next prev parent reply other threads:[~2017-07-12 14:08 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-11 20:23 [PATCH 00/30] oeqa core and oe-selftest threaded enablement Aníbal Limón
2017-07-11 20:23 ` [PATCH 01/30] oeqa/core/loader: Switch method definition for _make_failed_test Aníbal Limón
2017-07-14 9:52 ` Patrick Ohly
2017-07-14 15:27 ` Aníbal Limón
2017-07-17 19:14 ` Patrick Ohly
2017-07-17 19:41 ` Aníbal Limón
2017-07-17 20:03 ` Patrick Ohly
2017-07-11 20:23 ` [PATCH 02/30] oeqa/selftest/{context, case}: Handle KeyboardInterrupt/SIGINT and SIGTERM Aníbal Limón
2017-07-12 14:18 ` Leonardo Sandoval [this message]
2017-07-12 14:53 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 03/30] selftest/cases/package: Call parent setUpClass method Aníbal Limón
2017-07-12 6:51 ` Patrick Ohly
2017-07-12 15:44 ` Aníbal Limón
2017-07-12 17:14 ` Patrick Ohly
2017-07-11 20:23 ` [PATCH 04/30] bb/tinfoil: run_command handle busy status in bitbake server Aníbal Limón
2017-07-11 20:23 ` [PATCH 05/30] oe/copy_buildsystem: check_sstate_task_list also pop BBPATH from env Aníbal Limón
2017-07-11 20:23 ` [PATCH 06/30] oeqa/core/threaded: Enable support to use the main thread Aníbal Limón
2017-07-11 20:23 ` [PATCH 07/30] oeqa/core/threaded: Add support to run into a thread at end of execution Aníbal Limón
2017-07-12 14:22 ` Leonardo Sandoval
2017-07-12 14:54 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 08/30] oeqa/core/threaded: logSummary add skipped tests info Aníbal Limón
2017-07-11 20:23 ` [PATCH 09/30] oeqa/core/tests: Update test_loader threaded to cover main thread usage Aníbal Limón
2017-07-11 20:23 ` [PATCH 10/30] oeqa/selftest/{case, context}: Add builddir by test class and context Aníbal Limón
2017-07-11 20:23 ` [PATCH 11/30] oeqa/selftest/case: Add wrappers to utils.commands modules Aníbal Limón
2017-07-11 20:23 ` [PATCH 12/30] oeqa/selftest/case: Creates meta-selftest layer per class Aníbal Limón
2017-07-11 20:23 ` [PATCH 13/30] oeqa/selftest/case: tearDown extra commands print what actually fails Aníbal Limón
2017-07-11 20:23 ` [PATCH 14/30] oeqa/selftest/case: Support bitbake memres mode in per build directory Aníbal Limón
2017-07-11 20:23 ` [PATCH 15/30] oeqa/selftest/cases: Use testlayer_path instead of call get_test_layer() Aníbal Limón
2017-07-11 20:23 ` [PATCH 16/30] oeqa/selftest/cases: Use builddir from class instead of get from environment Aníbal Limón
2017-07-11 20:23 ` [PATCH 17/30] oeqa/selftest/cases: Use wrapper methods from OESelfTestCase class Aníbal Limón
2017-07-11 20:23 ` [PATCH 18/30] oeqa/selftest/cases: tinfoil to run in the main thread Aníbal Limón
2017-07-12 6:56 ` Patrick Ohly
2017-07-12 14:55 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 19/30] oeqa/selftest/cases: imagefeatures enable threaded runs Aníbal Limón
2017-07-11 20:23 ` [PATCH 20/30] oeqa/selftest/cases: runqemu enable thraded runs Aníbal Limón
2017-07-12 7:15 ` Patrick Ohly
2017-07-12 15:01 ` Aníbal Limón
2017-07-14 9:35 ` Patrick Ohly
2017-07-14 15:27 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 21/30] oeqa/selftest/cases: runtime enable threaded runs Aníbal Limón
2017-07-11 20:23 ` [PATCH 22/30] oeqa/selftest/cases: eSDK " Aníbal Limón
2017-07-11 20:23 ` [PATCH 23/30] oeqa/selftest/cases: devtool " Aníbal Limón
2017-07-11 20:23 ` [PATCH 24/30] oeqa/selftest/cases: recipetool enable for " Aníbal Limón
2017-07-11 20:23 ` [PATCH 25/30] oeqa/selftest/cases: Move devtool deploy test case to own module Aníbal Limón
2017-07-11 20:23 ` [PATCH 26/30] selftest/cases/devtool{, end}: Move update/finish_modify tests to its " Aníbal Limón
2017-07-11 20:23 ` [PATCH 27/30] seltest/cases/devtool: Build dbus on test_devtool_add_git_local Aníbal Limón
2017-07-11 20:23 ` [PATCH 28/30] argparse_oe: Add int_positive type Aníbal Limón
2017-07-12 14:33 ` Leonardo Sandoval
2017-07-12 14:56 ` Aníbal Limón
2017-07-11 20:23 ` [PATCH 29/30] oeqa/selftest/context: Enable support for threaded runs Aníbal Limón
2017-07-11 20:23 ` [PATCH 30/30] oeqa/selftest/cases: systemd_boot enable " Aníbal Limón
2017-07-11 20:31 ` ✗ patchtest: failure for oeqa core and oe-selftest threaded enablement Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1499869099.5349.38.camel@linux.intel.com \
--to=leonardo.sandoval.gonzalez@linux.intel.com \
--cc=anibal.limon@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.