From patchwork Sat Jan 29 23:22:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 517081 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0TNMXEe019212 for ; Sat, 29 Jan 2011 23:22:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754773Ab1A2XW0 (ORCPT ); Sat, 29 Jan 2011 18:22:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32696 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751905Ab1A2XWZ (ORCPT ); Sat, 29 Jan 2011 18:22:25 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0TNMOD9008595 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 29 Jan 2011 18:22:24 -0500 Received: from freedom.redhat.com (vpn-8-173.rdu.redhat.com [10.11.8.173]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0TNMMsT020249; Sat, 29 Jan 2011 18:22:22 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues , Jason Wang Subject: [PATCH] Recognize parameters surrounded by quotes v2 Date: Sat, 29 Jan 2011 21:22:21 -0200 Message-Id: <1296343341-21198-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 29 Jan 2011 23:22:55 +0000 (UTC) diff --git a/client/bin/job.py b/client/bin/job.py index 3d5d937..3e285c6 100644 --- a/client/bin/job.py +++ b/client/bin/job.py @@ -135,6 +135,11 @@ class base_client_job(base_job.base_job): return autodir, clientdir, None + @classmethod + def _parse_args(cls, args): + return re.findall("[^\s]*?['|\"].*?['|\"]|[^\s]+", args) + + def _find_resultdir(self, options): """ Determine the directory for storing results. On a client this is @@ -243,7 +248,7 @@ class base_client_job(base_job.base_job): self.args = [] if options.args: - self.args = options.args.split() + self.args = self._parse_args(options.args) if options.user: self.user = options.user diff --git a/client/bin/job_unittest.py b/client/bin/job_unittest.py index dba7e08..0e5aede 100755 --- a/client/bin/job_unittest.py +++ b/client/bin/job_unittest.py @@ -694,5 +694,18 @@ class test_base_job(unittest.TestCase): self.god.check_playback() + def test_parse_args(self): + test_set = {"a='foo bar baz' b='moo apt'": + ["a='foo bar baz'", "b='moo apt'"], + "a='foo bar baz' only=gah": + ["a='foo bar baz'", "only=gah"], + "a='b c d' no=argh": + ["a='b c d'", "no=argh"]} + for t in test_set: + parsed_args = job.base_client_job._parse_args(t) + expected_args = test_set[t] + self.assertEqual(parsed_args, expected_args) + + if __name__ == "__main__": unittest.main()