def _ParseOutputForSamples(output):
    """Parses the output from running Coremark to get performance samples.

  Args:
    output: The output from running Coremark.

  Returns:
    A list of sample.Sample objects.

  Raises:
    Benchmarks.RunError: If correct operation is not validated.
  """
    if 'Correct operation validated' not in output:
        raise errors.Benchmarks.RunError('Correct operation not validated.')
    value = regex_util.ExtractFloat(r'CoreMark 1.0 : ([0-9]*\.[0-9]*)', output)
    metadata = {
        'summary':
        output.splitlines()[-1],  # Last line of output is a summary.
        'size':
        regex_util.ExtractInt(r'CoreMark Size\s*:\s*([0-9]*)', output),
        'total_ticks':
        regex_util.ExtractInt(r'Total ticks\s*:\s*([0-9]*)', output),
        'total_time_sec':
        regex_util.ExtractFloat(r'Total time \(secs\)\s*:\s*([0-9]*\.[0-9]*)',
                                output),
        'iterations':
        regex_util.ExtractInt(r'Iterations\s*:\s*([0-9]*)', output),
        'iterations_per_cpu':
        ITERATIONS_PER_CPU,
        'parallelism_method':
        FLAGS.coremark_parallelism_method,
    }
    return [sample.Sample('Coremark Score', value, '', metadata)]
 def testParsesSuccessfully(self):
   regex = r'test (\d+) string'
   string = 'test 12435 string'
   self.assertEqual(12435, regex_util.ExtractInt(regex, string, group=1))