def run(self, **options): "" quiet = options.get( 'quiet', False ) raise_on_error = options.get( 'raise_on_error', True ) chdir = options.get( 'chdir', None ) x,out = util.runcmd( self.cmd, chdir=chdir, raise_on_error=False, print_output=False ) if not quiet: print3( out ) self.x = x self.out = out self.cntD = parse_vvtest_counts( out ) self.testdates = None self.plat = get_platform_name( out ) self.rdir = get_results_dir( out ) if self.rdir: if not os.path.isabs( self.rdir ): if chdir: self.rdir = abspath( pjoin( chdir, self.rdir ) ) else: self.rdir = abspath( self.rdir ) elif chdir: self.rdir = abspath( chdir ) else: self.rdir = os.getcwd() assert x == 0 or not raise_on_error, \ 'vvtest command returned nonzero exit status: '+str(x)
def launch_vvtest_then_terminate_it( *cmd_args, **options ): "" signum = options.pop( 'signum', signal.SIGTERM ) seconds_before_signaling = options.pop( 'seconds_before_signaling', 4 ) logfilename = options.pop( 'logfilename', 'run.log' ) batch = options.pop( 'batch', False ) addverbose = options.pop( 'addverbose', True ) cmd = vvtest_command_line( *cmd_args, batch=batch, addverbose=addverbose ) fp = open( logfilename, 'w' ) try: print3( cmd ) pop = subprocess.Popen( cmd, shell=True, stdout=fp.fileno(), stderr=fp.fileno(), preexec_fn=lambda:os.setpgid(os.getpid(),os.getpid()) ) time.sleep( seconds_before_signaling ) os.kill( -pop.pid, signum ) pop.wait() finally: fp.close() return util.readfile( logfilename )
def remove_results(): """ Removes all TestResults from the current working directory. If a TestResults directory is a soft link, the link destination is removed as well. """ for f in os.listdir('.'): if f.startswith( 'TestResults.' ): if os.path.islink(f): dest = os.readlink(f) print3( 'rm -rf ' + dest ) util.fault_tolerant_remove( dest ) print3( 'rm ' + f ) os.remove(f) else: print3( 'rm -rf ' + f ) util.fault_tolerant_remove( f )