In order to trim down the amount of autotest output, and leave the most relevant information to INFO level logs, removed some non overly relevant debug messages, turned some INFO messages into DEBUG ones, and in the process made the symlink of init scripts on harness_standalone more pythonic. Changes tested and pylinted.
Now a simple sleeptest run is down to the following output: [lmr@freedom autotest-git]$ sudo client/bin/autotest client/tests/sleeptest/control 15:21:25 INFO | Writing results to /home/lmr/Code/autotest-git/client/results/default 15:21:35 INFO | START ---- ---- timestamp=1309371695 localtime=Jun 29 15:21:35 15:21:35 INFO | START sleeptest sleeptest timestamp=1309371695 localtime=Jun 29 15:21:35 15:21:46 INFO | GOOD sleeptest sleeptest timestamp=1309371706 localtime=Jun 29 15:21:46 completed successfully 15:21:46 INFO | END GOOD sleeptest sleeptest timestamp=1309371706 localtime=Jun 29 15:21:46 15:21:49 INFO | END GOOD ---- ---- timestamp=1309371709 localtime=Jun 29 15:21:49 Thanks to Don Zickus <[email protected]> for the suggestions on the subject. I plan on doing more cleanups on other entry points. Signed-off-by: Lucas Meneghel Rodrigues <[email protected]> --- client/bin/harness_standalone.py | 16 ++++++++++---- client/bin/job.py | 4 +-- client/common_lib/test.py | 40 +++++++++++++++++++------------------- client/tools/html_report.py | 1 - 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/client/bin/harness_standalone.py b/client/bin/harness_standalone.py index c4b7f26..be50aa7 100644 --- a/client/bin/harness_standalone.py +++ b/client/bin/harness_standalone.py @@ -30,7 +30,7 @@ class harness_standalone(harness.harness): shutil.copyfile(src, dest) job.control_set(dest) - logging.info('Symlinking init scripts') + logging.debug("Symlinking init scripts") rc = os.path.join(self.autodir, 'tools/autotest') # see if system supports event.d versus systemd versus inittab supports_eventd = os.path.exists('/etc/event.d') @@ -46,7 +46,13 @@ class harness_standalone(harness.harness): initdefault = '2' try: - utils.system('ln -sf %s /etc/init.d/autotest' % rc) - utils.system('ln -sf %s /etc/rc%s.d/S99autotest' % (rc,initdefault)) - except: - logging.warning("Linking init scripts failed") + service = '/etc/init.d/autotest' + service_link = '/etc/rc%s.d/S99autotest' % initdefault + if os.path.islink(service): + os.remove(service) + if os.path.islink(service_link): + os.remove(service_link) + os.symlink(rc, service) + os.symlink(rc, service_link) + except Exception, e: + logging.error("Symlink init scripts failed with %s", e) diff --git a/client/bin/job.py b/client/bin/job.py index 09f26f8..1abdbcd 100644 --- a/client/bin/job.py +++ b/client/bin/job.py @@ -45,7 +45,6 @@ def _run_test_complete_on_exit(f): if self._logger.global_filename == 'status': self.harness.run_test_complete() if self.drop_caches: - logging.debug("Dropping caches") utils.drop_caches() wrapped.__name__ = f.__name__ wrapped.__doc__ = f.__doc__ @@ -276,7 +275,6 @@ class base_client_job(base_job.base_job): type=bool, default=True)) self.drop_caches = drop_caches if self.drop_caches: - logging.debug("Dropping caches") utils.drop_caches() @@ -981,7 +979,7 @@ class base_client_job(base_job.base_job): 'this is a continuation') if not has_steps: - logging.info('Initializing the state engine') + logging.debug('Initializing the state engine') self._state.set('client', 'steps', []) diff --git a/client/common_lib/test.py b/client/common_lib/test.py index 5b2e12c..a1d68ab 100644 --- a/client/common_lib/test.py +++ b/client/common_lib/test.py @@ -186,7 +186,6 @@ class base_test(object): def drop_caches_between_iterations(self): if self.job.drop_caches_between_iterations: - print "Dropping caches between iterations" utils.drop_caches() @@ -258,38 +257,38 @@ class base_test(object): # If the user called this test in an odd way (specified both iterations # and test_length), let's warn them. if iterations and test_length: - logging.info('Iterations parameter ignored (timed execution).') + logging.debug('Iterations parameter ignored (timed execution)') if test_length: test_start = _get_time() time_elapsed = 0 timed_counter = 0 - logging.info('Test started. Minimum test length: %d s', - test_length) + logging.debug('Test started. Specified %d s as the minimum test ' + 'length', test_length) while time_elapsed < test_length: timed_counter = timed_counter + 1 if time_elapsed == 0: - logging.info('Executing iteration %d', timed_counter) + logging.debug('Executing iteration %d', timed_counter) elif time_elapsed > 0: - logging.info( - 'Executing iteration %d, time_elapsed %d s', - timed_counter, time_elapsed) + logging.debug('Executing iteration %d, time_elapsed %d s', + timed_counter, time_elapsed) self._call_run_once(constraints, profile_only, postprocess_profiled_run, args, dargs) test_iteration_finish = _get_time() time_elapsed = test_iteration_finish - test_start - logging.info('Test finished after %d iterations', - timed_counter) - logging.info('Time elapsed: %d s', time_elapsed) + logging.debug('Test finished after %d iterations, ' + 'time elapsed: %d s', timed_counter, time_elapsed) else: if iterations is None: iterations = 1 - logging.info('Test started. Number of iterations: %d', iterations) - for self.iteration in xrange(1, iterations+1): - logging.info('Executing iteration %d of %d', self.iteration, - iterations) + if iterations > 1: + logging.debug('Test started. Specified %d iterations', + iterations) + for self.iteration in xrange(1, iterations + 1): + if iterations > 1: + logging.debug('Executing iteration %d of %d', + self.iteration, iterations) self._call_run_once(constraints, profile_only, postprocess_profiled_run, args, dargs) - logging.info('Test finished after %d iterations.', iterations) if not profile_only: self.iteration += 1 @@ -309,7 +308,7 @@ class base_test(object): self.before_run_once() profilers.start(self) - print 'Profilers present. Profiling run started' + logging.debug('Profilers present. Profiling run started') try: self.run_once(*args, **dargs) @@ -431,9 +430,10 @@ class base_test(object): if run_cleanup: _cherry_pick_call(self.cleanup, *args, **dargs) except Exception: - print 'Ignoring exception during cleanup() phase:' + logging.error('Ignoring exception during cleanup() phase:') traceback.print_exc() - print 'Now raising the earlier %s error' % exc_info[0] + logging.error('Now raising the earlier %s error', + exc_info[0]) self.crash_handler_report() finally: self.job.logging.restore() @@ -591,7 +591,7 @@ def _installtest(job, url): f = file(os.path.join(group_dir, '__init__.py'), 'w+') f.close() - print name + ": installing test url=" + url + logging.debug("%s: installing test url=%s", name, url) tarball = os.path.basename(url) tarball_path = os.path.join(group_dir, tarball) test_dir = os.path.join(group_dir, name) diff --git a/client/tools/html_report.py b/client/tools/html_report.py index 563a7a9..ac5db41 100755 --- a/client/tools/html_report.py +++ b/client/tools/html_report.py @@ -1475,7 +1475,6 @@ id="t1" class="stats table-autosort:4 table-autofilter table-stripeclass:alterna def print_result(result, indent): while result != []: r = result.pop(0) - print r res = results[r][2] print >> output, '<tr>' print >> output, '<td align="left">%s</td>' % res['time'] -- 1.7.5.4 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
