Lines Matching +full:test +full:- +full:results

1 #!/usr/bin/python -u
2 # Copyright 2007-2008 Martin J. Bligh <mbligh@google.com>, Google Inc.
62 # Control segment to stage server-side package.
81 """Get a list of machine names from command line arg -m or a file.
85 @return: A list of machine names from command line arg -m or the
86 machines file specified in the command line arg -M.
113 """Stage server-side package.
115 This function calls a control segment to stage server-side package based on
119 The script returns None if no server-side package is available. However,
121 server-side package) not found.
124 @param resultsdir: Folder to store results. This could be different from
125 parser.options.results: parser.options.results can be set to None
126 for results to be stored in a temp folder. resultsdir can be None
129 @return: url to the autotest server-side package. None in case of errors.
154 def _run_with_ssp(job, container_id, job_id, results, parser, ssp_url, argument
156 """Run the server job with server-side packaging.
159 @param container_id: ID of the container to run the test.
160 @param job_id: ID of the test job.
161 @param results: Folder to store results. This could be different from
162 parser.options.results:
163 parser.options.results can be set to None for results to be
165 results can be None for autoserv run requires no logging.
167 @param ssp_url: url of the staged server-side package.
168 @param machines: A list of machines to run the test.
172 'Failed to stage server-side package')
173 raise error.AutoservError('Failed to stage server-side package')
181 results, control=control,
187 'Failed to setup container for test: %s. Check logs in '
192 args.remove('--require-ssp')
193 # --parent_job_id is only useful in autoserv running in host, not in
194 # container. Include this argument will cause test to fail for builds before
196 if '--parent_job_id' in args:
197 index = args.index('--parent_job_id')
198 args.remove('--parent_job_id')
212 if parser.options.results:
213 paths_to_replace[parser.options.results] = container_result_dir
216 # Apply --use-existing-results, results directory is aready created and
218 if not '--use-existing-results' in args:
219 args.append('--use-existing-results')
222 if not '--pidfile-label' in args:
223 args.extend(['--pidfile-label', 'container_autoserv'])
232 # If the test run inside container fails without generating any log,
234 debug_files = os.listdir(os.path.join(results, 'debug'))
237 'Failed to run test inside the container: %s. Check '
247 def correct_results_folder_permission(results): argument
248 """Make sure the results folder has the right permission settings.
250 For tests running with server-side packaging, the results folder has the
252 process, so parsing job can access the results folder.
253 TODO(dshi): crbug.com/459344 Remove this function when test container can be
256 @param results: Path to the results folder.
259 if not results:
262 utils.run('sudo -n chown -R %s "%s"' % (os.getuid(), results))
263 utils.run('sudo -n chgrp -R %s "%s"' % (os.getgid(), results))
270 @param machine: Name of the dut used for test.
294 cmd_line = utils.run('ps -fp %s' % pid).stdout
295 if ('--board %s' % board in cmd_line and
296 '--port %s' % servo_port in cmd_line):
339 @param results_dir: Results directory to stage the control file into.
348 def run_autoserv(pid_file_manager, results, parser, ssp_url, use_ssp): argument
352 @param results: Folder to store results.
354 @param ssp_url: Url to server-side package.
355 @param use_ssp: Set to True to run with server-side packaging.
371 parser.options.results)
381 # Update results folder's file permission. This needs to be done ASAP
383 if use_ssp and results:
384 correct_results_folder_permission(results)
386 # TODO (sbasi) - remove the time.sleep when crbug.com/302815 is solved.
407 if results:
408 correct_results_folder_permission(results)
416 # be imported in the chroot as part of VMTest, so Try-Except it.
459 # can't be both a client and a server side test
461 parser.parser.error("Can not specify a test as both server and client!")
471 # When use_ssp is True, autoserv will be re-executed inside a
472 # container preserving the --control-name argument. Control file
478 results)
493 ssh_verbosity_flag = '-' + 'v' * ssh_verbosity
499 parser.parser.error('-G %r may only be supplied with more than one '
505 'resultdir': results,
511 store_dir=os.path.join(results,
567 results, parser, ssp_url, machines)
570 correct_results_folder_permission(results)
578 correct_results_folder_permission(results)
599 if results and (repair or verify or reset or cleanup or provision):
603 results, control_data.DEFAULT_MAX_RESULT_SIZE_KB)
606 'Non-critical failure: Failed to throttle results '
607 'in directory %s.', results)
609 site_utils.collect_result_sizes(results)
644 """Read the value of REQUIRE_SSP from test control file.
650 [1] Any change in REQUIRE_SSP directive in a test requires a prod-push to go
653 package may contain the test file. This function conservatively returns True
686 results = None
688 results = parser.options.results
689 if not results:
690 results = 'results.' + time.strftime('%Y-%m-%d-%H.%M.%S')
691 results = os.path.abspath(results)
694 if os.path.exists(os.path.join(results, filename)):
697 error = "Error: results directory already exists: %s\n" % results
701 # Now that we certified that there's no leftover results dir from
704 if not os.path.isdir(results):
705 os.makedirs(results)
708 # This is currently only used for skylab (i.e., when --control-name is
716 log_dir = os.path.join(results, 'ssp_logs') if results else None
720 log_dir = results
734 ssp_url = _stage_ssp(parser, results)
738 if results:
739 logging.info("Results placed in %s" % results)
744 logging.error("No existing results directory found: %s", results)
747 if parser.options.write_pidfile and results:
749 results)
764 # what label autoserv is invoked with by looking through the logs of a test
765 # for the autoserv command's -l option.
779 parser.options.results)
789 # happy signals without faking results.
791 machine = parser.options.results.split('/')[-1]
800 'unknown-test', parser.options.results, machine
805 run_autoserv(pid_file_manager, results, parser, ssp_url,