Esempio n. 1
0
 def execCmd(self, cmd, ctid):
     """crontab 的实际执行过程"""
     pscmd = "ps -A -opid,ppid,state,user,cmd|grep '\-\-ctid %s'|grep -v 'grep '" % ctid
     rets, retv = getstatusoutput(pscmd)
     retv = retv.strip()
     log.info('ps 结果: \n%s' % retv)
     if retv:
         log.info('进程还在执行')
         return {
             'seq': -1,
             'exec_time': 0,
             'stats': 0,
             'output': '检测到相同任务正在执行,*未被调度*',
         }
     start = time.time()
     status, output = getstatusoutput(cmd)
     log.info('EXEC %s: %d' % (cmd, status))
     if len(output) > 60000:
         output = '===large output===\n...%s' % output.decode(
             'utf-8')[-10240:].encode('utf-8')
     end = time.time()
     exec_time = end - start
     return {
         'seq': 3,
         'exec_time': '%.3f' % exec_time,
         'stats': status,
         'output': output
     }
    def _runlevels_save_hook(self):
        """Save runlevel configuration to disk."""

        runlevel_changes = {"on": [], "off": []}

        for i in xrange(0, 7):
            runlevel_changes[i in self._runlevels and "on"
                             or "off"].append(str(i))

        for what in ("on", "off"):
            if not len(runlevel_changes[what]):
                continue
            (status, output) = getstatusoutput(
                "%s --level %s %s %s 2>&1" %
                (self.chkconfig_invocation, "".join(
                    runlevel_changes[what]), self.name, what))
            if status != 0:
                raise OSError(
                    "Saving service '%s' failed, command was "
                    "'%s --level %s %s %s'.\n"
                    "Output was:\n"
                    "%s" % (self.name, self.chkconfig_invocation, "".join(
                        runlevel_changes[what]), self.name, what, output))

        self.configured = True
Esempio n. 3
0
File: git.py Progetto: armvixl/vixl
def get_tracked_files():
  command = 'git ls-tree HEAD -r --full-tree --name-only'

  status, tracked = util.getstatusoutput(command)
  if status != 0: util.abort('Failed to list tracked files.')

  return tracked
Esempio n. 4
0
def get_tracked_files():
    command = 'git ls-tree HEAD -r --full-tree --name-only'

    status, tracked = util.getstatusoutput(command)
    if status != 0: util.abort('Failed to list tracked files.')

    return tracked
Esempio n. 5
0
 def build(mode):
   if args.verbose: print('Building ' + mode + ' mode cctest...')
   command = 'scons mode=%s simulator=%s all -j%u' % \
             (mode, args.simulator, args.jobs)
   status, output = util.getstatusoutput(command)
   if status != 0:
     print(output)
     util.abort('Failed building cctest: ' + command)
Esempio n. 6
0
 def clean(mode):
     if args.verbose: print('Cleaning ' + mode + ' mode cctest...')
     command = 'scons mode=%s simulator=%s target=cctest --clean' % \
               (mode, args.simulator)
     status, output = util.getstatusoutput(command)
     if status != 0:
         print(output)
         util.abort('Failed cleaning cctest: ' + command)
Esempio n. 7
0
 def build(mode):
     if args.verbose: print('Building ' + mode + ' mode cctest...')
     command = 'scons mode=%s simulator=%s target=cctest -j%u' % \
               (mode, args.simulator, args.jobs)
     status, output = util.getstatusoutput(command)
     if status != 0:
         print(output)
         util.abort('Failed building cctest: ' + command)
Esempio n. 8
0
 def clean(mode):
   if args.verbose: print('Cleaning ' + mode + ' mode cctest...')
   command = 'scons mode=%s simulator=%s all --clean' % \
             (mode, args.simulator)
   status, output = util.getstatusoutput(command)
   if status != 0:
     print(output)
     util.abort('Failed cleaning cctest: ' + command)
Esempio n. 9
0
def get_tracked_files():
    command = 'git ls-tree '
    branch = get_current_branch()
    options = ' -r --full-tree --name-only'

    status, tracked = util.getstatusoutput(command + branch + options)
    if status != 0: util.abort('Failed to list tracked files.')

    return tracked
Esempio n. 10
0
def ReadManifest(filters):
  status, output = util.getstatusoutput(args.cctest +  ' --list')
  if status != 0: util.abort('Failed to list all tests')

  names = output.split()
  for f in filters:
    names = filter(re.compile(f).search, names)

  return map(Test, names)
Esempio n. 11
0
def doTask(task):
    '''function:在线程中执行某一任务
       @params
            task:某一任务的相关信息,一个字典
       @return:任务执行成功返回执行结果
    '''
    now = int(time())
    status,output = getstatusoutput(task['task_content'])
    return json.dumps({'h':getHostname(), 'tk':task['task_name'], 's':status, 'o':output.strip(), 'tm':now, 'tp':2})
Esempio n. 12
0
def get_untracked_files():
    status, output = util.getstatusoutput('git status -s')
    if status != 0: util.abort('Failed to get git status.')

    untracked_regexp = re.compile('\?\?.*(src/|test/|tools/).*(.cc$|.h$)')
    files_in_watched_folder = lambda n: untracked_regexp.search(n) != None
    untracked_files = filter(files_in_watched_folder, output.split('\n'))

    return untracked_files
Esempio n. 13
0
def GetTests(runner, filters=[]):
    rc, output = util.getstatusoutput(runner + ' --list')
    if rc != 0: util.abort('Failed to list all tests')

    tests = output.split()
    for f in filters:
        tests = filter(re.compile(f).search, tests)

    return tests
def get_tracked_files():
  command = 'git ls-tree '
  branch = get_current_branch()
  options = ' -r --full-tree --name-only'

  status, tracked = util.getstatusoutput(command + branch + options)
  if status != 0: util.abort('Failed to list tracked files.')

  return tracked
def get_untracked_files():
  status, output = util.getstatusoutput('git status -s')
  if status != 0: util.abort('Failed to get git status.')

  untracked_regexp = re.compile('\?\?.*(src/|test/|tools/).*(.cc$|.h$)')
  files_in_watched_folder = lambda n: untracked_regexp.search(n) != None
  untracked_files = filter(files_in_watched_folder, output.split('\n'))

  return untracked_files
def get_current_branch():
  status, branches = util.getstatusoutput('git branch')
  if status != 0: util.abort('Failed to run git branch.')
  match = re.search("^\* (.*)$", branches, re.MULTILINE)
  if not match: util.abort('Failed to find the current branch.')

  branch = match.group(1);

  # If we are not on a named branch, return the hash of the HEAD commit.
  # This can occur (for example) if a specific revision is checked out by
  # commit hash, or during a rebase.
  if branch == '(no branch)':
    status, commit = util.getstatusoutput('git log -1 --pretty=format:"%H"')
    if status != 0: util.abort('Failed to run git log.')
    match = re.search('^[0-9a-fA-F]{40}$', commit, re.MULTILINE)
    if not match: util.abort('Failed to find the current revision.')
    branch = match.group(0)

  return branch
Esempio n. 17
0
File: test.py Progetto: mdupuy/vixl
def BuildRequiredObjects(arguments):
  status, output = util.getstatusoutput('scons ' +
                                        'mode=' + arguments.mode + ' ' +
                                        'simulator=' + arguments.simulator + ' ' +
                                        'target=cctest ' +
                                        '--jobs=' + str(arguments.jobs))

  if status != 0:
    print(output)
    util.abort('Failed bulding cctest')
Esempio n. 18
0
def GetTests(runner, filters = []):
  rc, output = util.getstatusoutput(runner +  ' --list')
  if rc != 0: util.abort('Failed to list all tests')

  tests = output.split()
  for f in filters:
    print f
    tests = filter(re.compile(f).search, tests)

  return tests
Esempio n. 19
0
def ReadManifest(runner, filters = [],
                 debugger = False, coloured_trace = False, verbose = False):
  status, output = util.getstatusoutput(runner +  ' --list')
  if status != 0: util.abort('Failed to list all tests')

  names = output.split()
  for f in filters:
    names = filter(re.compile(f).search, names)

  return map(lambda x:
      Test(x, runner, debugger, coloured_trace, verbose), names)
Esempio n. 20
0
def get_current_branch():
    status, branches = util.getstatusoutput('git branch')
    if status != 0: util.abort('Failed to run git branch.')
    match = re.search("^\* (.*)$", branches, re.MULTILINE)
    if not match: util.abort('Failed to find the current branch.')

    branch = match.group(1)

    # If we are not on a named branch, return the hash of the HEAD commit.
    # This can occur (for example) if a specific revision is checked out by
    # commit hash, or during a rebase.
    if branch == '(no branch)':
        status, commit = util.getstatusoutput(
            'git log -1 --pretty=format:"%H"')
        if status != 0: util.abort('Failed to run git log.')
        match = re.search('^[0-9a-fA-F]{40}$', commit, re.MULTILINE)
        if not match: util.abort('Failed to find the current revision.')
        branch = match.group(0)

    return branch
Esempio n. 21
0
 def execCmd(self, cmd, ctid):
     """crontab 的实际执行过程""" 
     pscmd = "ps -A -opid,ppid,state,user,cmd|grep '\-\-ctid %s'|grep -v 'grep '" % ctid
     rets, retv = getstatusoutput(pscmd) 
     retv = retv.strip()
     log.info('ps 结果: \n%s' % retv)
     if retv:
         log.info('进程还在执行')
         return {'seq': -1, 
                 'exec_time': 0, 
                 'stats': 0, 
                 'output': '检测到相同任务正在执行,*未被调度*',
                 }
     start = time.time()
     status, output = getstatusoutput(cmd)
     log.info('EXEC %s: %d' % (cmd, status))
     if len(output) > 60000:
         output = '===large output===\n...%s' % output.decode('utf-8')[-10240:].encode('utf-8')
     end = time.time()
     exec_time = end - start
     return {'seq': 3, 'exec_time': '%.3f' % exec_time, 'stats': status, 'output': output}
Esempio n. 22
0
def GetTests(runner, filters=[]):
    cmd = runner + ' --list'
    rc, output = util.getstatusoutput(cmd)
    if rc != 0:
        util.abort("Failed to list all tests. Output of " + cmd + ":\n" +
                   output)

    tests = output.split()
    for f in filters:
        tests = filter(re.compile(f).search, tests)

    return tests
Esempio n. 23
0
def ClangTidyIsAvailable(clang_tidy):
    if not util.IsCommandAvailable(clang_tidy):
        return False
    cmd = '%s -version' % clang_tidy
    rc, version = util.getstatusoutput(cmd)
    if rc != 0:
        util.abort("Failed to execute %s: %s" % (cmd, version))
    m = re.search("LLVM version (\d)\.(\d)\.\d.*$", version.decode(), re.M)
    if not m:
        util.abort("Failed to get clang-tidy's version: %s" % version)
    major, minor = m.groups()
    return int(major) == CLANG_TIDY_VERSION_MAJOR and \
      int(minor) == CLANG_TIDY_VERSION_MINOR
Esempio n. 24
0
 def _set_enabled(self, enabled):
     old_enabled = getattr(self, "_enabled", None)
     self._enabled = enabled
     if old_enabled != enabled:
         (status, output) = getstatusoutput("%s %s %s 2>&1" %
                                             (self.chkconfig_invocation,
                                              self.name, self.enabled and \
                                               "on" or "off"))
         if status != 0:
             raise OSError("Saving service '%(name)s' failed, command was "
                            "'%(invocation)s %(name)s %(action)s 2>&1'." % \
                                 {"name": self.name,
                                  "invocation": self.chkconfig_invocation,
                                  "action": self.enabled and "on" or "off"})
Esempio n. 25
0
def doTask(task):
    '''function:在线程中执行某一任务
       @params
            task:某一任务的相关信息,一个字典
       @return:任务执行成功返回执行结果
    '''
    now = int(time())
    status, output = getstatusoutput(task['task_content'])
    return json.dumps({
        'h': getHostname(),
        'tk': task['task_name'],
        's': status,
        'o': output.strip(),
        'tm': now,
        'tp': 2
    })
Esempio n. 26
0
File: test.py Progetto: mdupuy/vixl
def ListTests(cctest, filters):
  status, output = util.getstatusoutput(cctest +  ' --list')
  if status != 0: util.abort('Failed to list all tests')

  available_tests = output.split()
  if filters:
    filters = map(re.compile, filters)
    def is_selected(test_name):
      for e in filters:
        if e.search(test_name):
          return True
      return False

    return filter(is_selected, available_tests)
  else:
    return available_tests
Esempio n. 27
0
def RunTest(test):
    cmd = " ".join(test.args['command'])
    rc, p_out = util.getstatusoutput(cmd)
    if rc != 0:
        # This usually happens when the compiler hits a '#error' because of
        # a missing define.
        printer.Print("%sFATAL ERROR: failed to run command '%s': %s%s" %
                      (printer.COLOUR_RED, cmd, p_out, printer.NO_COLOUR))
    p_out = FilterClangTidyLines(p_out.split('\n'))

    failed = (len(p_out) > 0) or (rc != 0)

    if failed:
        with Test.n_tests_failed.get_lock():
            Test.n_tests_failed.value += 1
    else:
        with Test.n_tests_passed.get_lock():
            Test.n_tests_passed.value += 1

    printer.__print_lock__.acquire()

    printer.UpdateProgress(test.shared.start_time,
                           Test.n_tests_passed.value,
                           Test.n_tests_failed.value,
                           test.shared.n_tests,
                           Test.n_tests_skipped.value,
                           test.shared.n_known_failures,
                           test.name,
                           prevent_next_overwrite=failed,
                           has_lock=True,
                           prefix=test.shared.progress_prefix)

    if failed:
        printer.Print(printer.COLOUR_RED + 'FAILED: ' + cmd +
                      printer.NO_COLOUR,
                      has_lock=True)
        printer.Print(p_out, has_lock=True)

    printer.__print_lock__.release()
Esempio n. 28
0
def FilterKnownValgrindTestFailures(tests):
    rc, output = util.getstatusoutput('valgrind --version')

    if rc != 0:
        util.abort('Failed to get the Valgrind version.')

    version = re.search('^valgrind-([0-9]+)\.([0-9]+)\.([0-9]+)', output)

    if not version:
        util.abort('Failed to get the Valgrind version.')

    major = int(version.group(1))
    minor = int(version.group(2))

    if major > 3 or (major == 3 and minor > 10):
        return tests

    # Valgrind versions before 3.11 have issues with fused multiply-add,
    # so disable the affected tests.
    known_valgrind_test_failures = {
        'AARCH64_SIM_fmadd_d', 'AARCH64_SIM_fmadd_s', 'AARCH64_SIM_fmla_2D',
        'AARCH64_SIM_fmla_2D_2D_D', 'AARCH64_SIM_fmla_2S',
        'AARCH64_SIM_fmla_2S_2S_S', 'AARCH64_SIM_fmla_4S',
        'AARCH64_SIM_fmla_4S_4S_S', 'AARCH64_SIM_fmla_D_D_D',
        'AARCH64_SIM_fmls_2D', 'AARCH64_SIM_fmls_2D_2D_D',
        'AARCH64_SIM_fmls_2S', 'AARCH64_SIM_fmls_2S_2S_S',
        'AARCH64_SIM_fmls_4S', 'AARCH64_SIM_fmls_4S_4S_S',
        'AARCH64_SIM_fmls_D_D_D', 'AARCH64_SIM_fmsub_d', 'AARCH64_SIM_fmsub_s',
        'AARCH64_SIM_fnmadd_d', 'AARCH64_SIM_fnmadd_s', 'AARCH64_SIM_fnmsub_d',
        'AARCH64_SIM_fnmsub_s', 'AARCH64_SIM_frecps_2D',
        'AARCH64_SIM_frecps_D', 'AARCH64_SIM_frsqrts_2D',
        'AARCH64_SIM_frsqrts_D'
    }

    for t in sorted(known_valgrind_test_failures):
        print('Skipping ' + t + '...')

    return filter(lambda x: x not in known_valgrind_test_failures, tests)
Esempio n. 29
0
def FilterKnownValgrindTestFailures(tests):
    rc, output = util.getstatusoutput('valgrind --version')

    if rc != 0:
        util.abort('Failed to get the Valgrind version.')

    version = re.search('^valgrind-([0-9]+)\.([0-9]+)\.([0-9]+)', output)

    if not version:
        util.abort('Failed to get the Valgrind version.')

    major = int(version.group(1))
    minor = int(version.group(2))

    if major > 3 or (major == 3 and minor > 10):
        return tests

    reason = "Valgrind versions before 3.11 have issues with fused multiply-add, " \
             "so disable the affected tests."
    known_valgrind_test_failures = {
        'AARCH64_SIM_fmadd_d', 'AARCH64_SIM_fmadd_s', 'AARCH64_SIM_fmla_2D',
        'AARCH64_SIM_fmla_2D_2D_D', 'AARCH64_SIM_fmla_2S',
        'AARCH64_SIM_fmla_2S_2S_S', 'AARCH64_SIM_fmla_4S',
        'AARCH64_SIM_fmla_4S_4S_S', 'AARCH64_SIM_fmla_D_D_D',
        'AARCH64_SIM_fmls_2D', 'AARCH64_SIM_fmls_2D_2D_D',
        'AARCH64_SIM_fmls_2S', 'AARCH64_SIM_fmls_2S_2S_S',
        'AARCH64_SIM_fmls_4S', 'AARCH64_SIM_fmls_4S_4S_S',
        'AARCH64_SIM_fmls_D_D_D', 'AARCH64_SIM_fmsub_d', 'AARCH64_SIM_fmsub_s',
        'AARCH64_SIM_fnmadd_d', 'AARCH64_SIM_fnmadd_s', 'AARCH64_SIM_fnmsub_d',
        'AARCH64_SIM_fnmsub_s', 'AARCH64_SIM_frecps_2D',
        'AARCH64_SIM_frecps_D', 'AARCH64_SIM_frsqrts_2D',
        'AARCH64_SIM_frsqrts_D'
    }

    filtered_list = [x for x in tests if x not in known_valgrind_test_failures]
    return (filtered_list, len(tests) - len(filtered_list), reason)
Esempio n. 30
0
 def Run(self):
     if args.verbose: print('Running ' + self.name + '...')
     retcode, self.output = util.getstatusoutput(self.command)
     self.status = PASSED if retcode == 0 else FAILED
     self.summary = self.get_summary(self.output)
    line = f.readline()
    while line:
        if line.strip() == marker[matched]:
            matched = matched + 1
            if matched == len(marker):
                f.truncate()
                break
        else:
            matched = 0
        line = f.readline()

    if matched != len(marker):
        util.abort('Failed to find output section in ' + args.out + '.')

    # Find the simulator tests.
    status, output = util.getstatusoutput(args.cctest + ' --list')
    if status != 0: util.abort('Failed to list all tests')
    tests = filter(lambda t: 'SIM_' in t, output.split())
    tests.sort()

    # Run each test.
    for test in tests:
        cmd = ' '.join([args.cctest, '--sim_test_trace', test])
        status, output = util.getstatusoutput(cmd)
        if status != 0: util.abort('Failed to run ' + cmd + '.')

        f.write('\n\n' + output)

    f.write('\n\n')
    f.close()
  args = BuildOptions(root_dir)

  # Run each simulator test (SIM_*) with the --sim_test_trace option, and use
  # the output to create the traces header (from --out). In addition, the
  # test-simulator-traces-a64.h file, the master trace file, which includes all
  # other trace files is generated.

  # Create master trace file.
  master_trace_f = open(args.out, 'w')
  master_trace_f.write(copyright_header)
  master_trace_f.write(master_trace_header)
  master_trace_f.write('\n\n')

  # Find the simulator tests.
  status, output = util.getstatusoutput(args.runner + ' --list')
  if status != 0: util.abort('Failed to list all tests')
  tests = filter(lambda t: 'SIM_' in t, output.split())
  tests.sort()

  for test in tests:
    # Run each test.
    print 'Generating trace for ' + test;
    cmd = ' '.join([args.runner, '--sim_test_trace', test])
    status, output = util.getstatusoutput(cmd)
    if status != 0: util.abort('Failed to run ' + cmd + '.')

    # Create a new trace header file.
    trace_filename = test.lower().replace('_', '-') + "-trace-a64.h"
    trace_f =  open("test/traces/a64/" + trace_filename, 'w')
    trace_f.write(copyright_header)
Esempio n. 33
0
def CleanBuildSystem():
  status, output = util.getstatusoutput('scons mode=release --clean')
  if status != 0: util.abort('Failed to clean in release mode.')
  status, output = util.getstatusoutput('scons mode=debug --clean')
  if status != 0: util.abort('Failed to clean in debug mode.')
Esempio n. 34
0
def is_git_repository_root(path):
    command = 'git -C ' + quote(path) + ' rev-parse --show-toplevel'
    status, toplevel = util.getstatusoutput(command)
    if status != 0: return False
    return os.path.samefile(toplevel, path)
  line = f.readline();
  while line:
    if line.strip() == marker[matched]:
      matched = matched + 1
      if matched == len(marker):
        f.truncate()
        break
    else:
      matched = 0
    line = f.readline()

  if matched != len(marker):
    util.abort('Failed to find output section in ' + args.out + '.')

  # Find the simulator tests.
  status, output = util.getstatusoutput(args.cctest + ' --list')
  if status != 0: util.abort('Failed to list all tests')
  tests = filter(lambda t: 'SIM_' in t, output.split())
  tests.sort()

  # Run each test.
  for test in tests:
    cmd = ' '.join([args.cctest, '--sim_test_trace', test])
    status, output = util.getstatusoutput(cmd)
    if status != 0: util.abort('Failed to run ' + cmd + '.')

    f.write('\n\n' + output)

  f.write('\n\n')
  f.close()
Esempio n. 36
0
def IsCppLintAvailable():
    retcode, unused_output = util.getstatusoutput('which cpplint.py')
    return retcode == 0
Esempio n. 37
0
  # Parse the arguments.
  args = BuildOptions()

  # Find a valid path to args.cctest (in case it doesn't begin with './').
  args.cctest = os.path.join('.', args.cctest)

  if not os.access(args.cctest, os.X_OK):
    print "'" + args.cctest + "' is not executable or does not exist."
    sys.exit(1)

  # List all matching tests.
  manifest = ReadManifest(args.filters)

  # Delete coverage data files.
  if args.coverage:
    status, output = util.getstatusoutput('find obj/coverage -name "*.gcda" -exec rm {} \;')

  # Run the tests.
  status = RunTests(manifest)
  EnsureNewLine()

  # Print coverage information.
  if args.coverage:
    cmd = 'tggcov -R summary_all,untested_functions_per_file obj/coverage/src/a64'
    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    stdout, stderr = p.communicate()
    print(stdout)

  sys.exit(status)
Esempio n. 38
0
File: lint.py Progetto: armvixl/vixl
def IsCppLintAvailable():
    retcode, unused_output = util.getstatusoutput('which cpplint.py')
    return retcode == 0
Esempio n. 39
0
 def Run(self):
   retcode, self.output = util.getstatusoutput(self.command)
   self.status = 'PASS' if retcode == 0 else 'FAILED'
   self.summary = self.get_summary(self.output)