On 02/07/2012 08:30 PM, Lucas Meneghel Rodrigues wrote:
> Fix the small amount of issues that require the autotest
> client to require super user rights:
>   * Symlinking init scripts
>   * Logging system files
>
> They are not critical to the test results, making non-root
> runs more pleasant. Of course, tests themselves still need
> to be disciplined with not requiring superuser operations
> themselves.
>
> Now running the local code with a regular user will only
> print INFO messages saying it couldn't perform some
> operations:
>
> [lmr@freedom autotest.lmr]$ client/bin/autotest-local run sleeptest
> 16:26:39 INFO | Writing results to 
> /home/lmr/Code/autotest.lmr/client/results/default
> 16:26:39 INFO | Could not symlink init scripts (lack of permissions)
> 16:26:39 INFO | Not logging /proc/slabinfo (lack of permissions)
> 16:26:40 INFO | START ----    ----    timestamp=1328639200 localtime=Feb 07 
> 16:26:40
> 16:26:40 INFO |       START   sleeptest       sleeptest timestamp=1328639200  
> localtime=Feb 07 16:26:40
> 16:26:40 INFO | Not logging /proc/slabinfo (lack of permissions)
> 16:26:41 INFO | Not logging /proc/slabinfo (lack of permissions)
> 16:26:41 ERROR| System log collection failed with [Errno 13] Permission 
> denied: '/var/log/messages'
> 16:26:41 INFO |               GOOD    sleeptest       sleeptest 
> timestamp=1328639201  localtime=Feb 07 16:26:41 completed successfully
> 16:26:41 INFO |       END GOOD        sleeptest       sleeptest 
> timestamp=1328639201  localtime=Feb 07 16:26:41
> 16:26:41 INFO | END GOOD      ----    ----    timestamp=1328639201 
> localtime=Feb 07 16:26:41
>
> This is part of the work described on github issue #151:
>
>     https://github.com/autotest/autotest/issues/151
>
> Signed-off-by: Lucas Meneghel Rodrigues<[email protected]>
> ---
>   client/bin/base_sysinfo.py       |    8 ++++++--
>   client/bin/harness_standalone.py |   16 ++++++++--------
>   2 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/client/bin/base_sysinfo.py b/client/bin/base_sysinfo.py
> index a195c95..eac013d 100644
> --- a/client/bin/base_sysinfo.py
> +++ b/client/bin/base_sysinfo.py
> @@ -80,7 +80,11 @@ class logfile(loggable):
>
>       def run(self, logdir):
>           if os.path.exists(self.path):
> -            shutil.copyfile(self.path, os.path.join(logdir, self.logf))
> +            try:
> +                shutil.copyfile(self.path, os.path.join(logdir, self.logf))
> +            except IOError:
> +                logging.info("Not logging %s (lack of permissions)",
> +                             self.path)
>

Is it possible to log the exact exception/return value?
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to