John,

Attached is a separate patch that adds support for args to
client/bin/autotest. The downside of doing it this way is that it implements
a separate path for passing args to client-side control. The benefit is that
it's simple.

Darin

On Mon, Mar 29, 2010 at 8:33 AM, John Admanski <[email protected]> wrote:

> I was looking at this a bit more, and I still see an issue; now you can't
> write code that uses args that just works on a straight client, you have to
> be launching the client via autoserv. I suppose that's not a huge problem,
> since autoserv is the only way that you can set args anyway, but I guess I'd
> just envisioned a grander patch that actually added support for command-line
> args to client/bin/autotest, and then just used server/autotest.py to pass
> through any autoserv args.
>
> Still, I think it's not a huge deal. I'm just a little worried about the
> continued trend of more and more code being written that just assumes you're
> using all the higher layers to run your tests. These days it seems everyone
> just wants to write client tests that assume you're using autoserv, or even
> assumes you're using a full scheduler setup.
>
> -- John
>
>
> On Fri, Mar 26, 2010 at 3:08 PM, Darin Petkov <[email protected]> wrote:
>
>>
>>
>> On Fri, Mar 26, 2010 at 2:43 PM, John Admanski <[email protected]>wrote:
>>
>>> This should probably use %r instead of %s. In practice I think repr(args)
>>> and str(args) will end up being the same, but in principle repr is supposed
>>> to be the inverse of eval so it's the more correct choice of formatting.
>>
>>
>> Good point. Updated the patch. PTAL.
>>
>>
>>>
>>>
>>> On Fri, Mar 26, 2010 at 2:40 PM, Darin Petkov <[email protected]> wrote:
>>>
>>>> A simple patch to propagate user args (autoserv -a/--args) to the
>>>> client-side control file.
>>>>
>>>>
>>>
>>
>
From cdc4d7200f07bc626968e25b4e52452b7750a1fc Mon Sep 17 00:00:00 2001
From: Darin Petkov <[email protected]>
Date: Mon, 29 Mar 2010 10:54:50 -0700
Subject: [PATCH] Add args support to client/bin/autotest.

---
 client/bin/autotest |    3 +++
 client/bin/job.py   |    7 ++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/client/bin/autotest b/client/bin/autotest
index 5cebebe..3b88135 100755
--- a/client/bin/autotest
+++ b/client/bin/autotest
@@ -26,6 +26,9 @@ os.environ['PYTHONPATH'] = autodirbin
 
 parser = OptionParser()
 
+parser.add_option("-a", "--args", dest='args',
+                        help="additional args to pass to control file")
+
 parser.add_option("-c", "--continue", dest="cont", action="store_true",
                         default=False, help="continue previously started job")
 
diff --git a/client/bin/job.py b/client/bin/job.py
index 04804ec..fb19b45 100644
--- a/client/bin/job.py
+++ b/client/bin/job.py
@@ -190,6 +190,10 @@ class base_client_job(base_job.base_job):
         self.hosts = set([local_host.LocalHost(hostname=options.hostname,
                                                bootloader=self.bootloader)])
 
+        self.args = []
+        if options.args:
+            self.args = options.args.split()
+
         if options.user:
             self.user = options.user
         else:
@@ -961,7 +965,8 @@ class base_client_job(base_job.base_job):
         # Some control files will have code outside of functions,
         # which means we need to have our state engine initialized
         # before reading in the file.
-        global_control_vars = {'job': self}
+        global_control_vars = {'job': self,
+                               'args': self.args}
         exec(JOB_PREAMBLE, global_control_vars, global_control_vars)
         try:
             execfile(self.control, global_control_vars, global_control_vars)
-- 
1.7.0.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to