From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Burns Subject: Re: [PATCH][KVM-AUTOTEST] Check exit status of custom install script and fail if script failed. Date: Mon, 01 Jun 2009 14:22:11 -0400 Message-ID: <4A241C53.2080604@redhat.com> References: <1242851931-8492-1-git-send-email-mburns@redhat.com> <1242851931-8492-2-git-send-email-mburns@redhat.com> <4A195E48.5080300@redhat.com> <1243491918.2976.1.camel@localhost.localdomain> <4A2389FB.7050009@redhat.com> Reply-To: mburns@redhat.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Lucas Meneghel Rodrigues , kvm@vger.kernel.org, dhuff@redhat.com, ulublin@redhat.com To: Avi Kivity Return-path: Received: from mx2.redhat.com ([66.187.237.31]:48080 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750992AbZFASWL (ORCPT ); Mon, 1 Jun 2009 14:22:11 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n51IMEYO005766 for ; Mon, 1 Jun 2009 14:22:14 -0400 In-Reply-To: <4A2389FB.7050009@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Avi Kivity wrote: > Lucas Meneghel Rodrigues wrote: >> On Sun, 2009-05-24 at 17:48 +0300, Avi Kivity wrote: >> >>> Mike Burns wrote: >>> >>>> Signed-off-by: Mike Burns >>>> --- >>>> client/tests/kvm_runtest_2/kvm_install.py | 7 ++++++- >>>> 1 files changed, 6 insertions(+), 1 deletions(-) >>>> >>>> diff --git a/client/tests/kvm_runtest_2/kvm_install.py >>>> b/client/tests/kvm_runtest_2/kvm_install.py >>>> index ebd8b7d..392ef0c 100755 >>>> --- a/client/tests/kvm_runtest_2/kvm_install.py >>>> +++ b/client/tests/kvm_runtest_2/kvm_install.py >>>> @@ -90,7 +90,12 @@ def run_kvm_install(test, params, env): >>>> kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k)) >>>> os.putenv("KVM_INSTALL_%s" % (k), str(params[k])) >>>> kvm_log.info("Running " + script + " to install kvm") >>>> - os.system("cd %s; %s" % (test.bindir, script)) >>>> + install_result = os.system("cd %s; %s" % (test.bindir, >>>> script)) >>>> + if os.WEXITSTATUS(install_result) != 0: >>>> + message = "Custom Script encountered an error" >>>> + kvm_log.error(message) >>>> + raise error.TestError, message >>>> + >>>> >>> How about a helper that does os.system() (or rather, >>> commands.getstatusoutput()) and throws an exception on failure? I >>> imagine it could be used in many places. >>> >> >> utils.system() does that. If we have exit code != 0, it throws an >> error.CmdError exception. >> > > Well let's use it then. Every time I see 'raise' used I'm going to > complain, so it will be a lot more efficient as well as smaller code. > Agreed. I'll rework this and my other patches and get them re-posted in the next day or two. Mike