コード例 #1
0
    def test_symbolize_log_pid_from_deadly_signal(self):
        mock_device = MockDevice()
        base_dir = tempfile.mkdtemp()
        fuzzer = Fuzzer(mock_device,
                        u'mock-package1',
                        u'mock-target2',
                        output=base_dir)
        os.mkdir(fuzzer.results())
        with tempfile.TemporaryFile() as tmp_out:
            with tempfile.TemporaryFile() as tmp_in:
                tmp_in.write("""
A line
Another line
==67890== ERROR: libFuzzer: deadly signal
MS: 1 SomeMutation; base unit: foo
Yet another line
artifact_prefix='data/'; Test unit written to data/crash-cccc
""")
                tmp_in.flush()
                tmp_in.seek(0)
                fuzzer.symbolize_log(tmp_in, tmp_out)
            tmp_out.flush()
            tmp_out.seek(0)
            self.assertIn(
                ' '.join(
                    mock_device.get_ssh_cmd([
                        'scp', '[::1]:' + fuzzer.data_path('crash-cccc'),
                        fuzzer.results()
                    ])), mock_device.host.history)
            self.assertEqual(
                tmp_out.read(), """
A line
Another line
==67890== ERROR: libFuzzer: deadly signal
Symbolized line 1
Symbolized line 2
Symbolized line 3
MS: 1 SomeMutation; base unit: foo
Yet another line
artifact_prefix='data/'; Test unit written to data/crash-cccc
""")
コード例 #2
0
ファイル: check_fuzzer.py プロジェクト: yanyushr/fuchsia
def main():
    parser = Args.make_parser(
        description='Reports status for the fuzzer matching NAME if provided, '
        +
        'or for all running fuzzers.  Status includes execution state, corpus '
        + 'size, and number of artifacts.',
        name_required=False)
    args = parser.parse_args()

    host = Host()
    device = Device.from_args(host, args)
    fuzzers = Fuzzer.filter(host.fuzzers, args.name)

    pids = device.getpids()
    silent = True
    for pkg, tgt in fuzzers:
        fuzzer = Fuzzer(device, pkg, tgt)
        if not args.name and tgt not in pids:
            continue
        silent = False
        if tgt in pids:
            print(str(fuzzer) + ': RUNNING')
        else:
            print(str(fuzzer) + ': STOPPED')
        print('    Output path:  ' + fuzzer.data_path())
        print('    Corpus size:  %d inputs / %d bytes' %
              fuzzer.measure_corpus())
        artifacts = fuzzer.list_artifacts()
        if len(artifacts) == 0:
            print('    Artifacts:    None')
        else:
            print('    Artifacts:    ' + artifacts[0])
            for artifact in artifacts[1:]:
                print('                  ' + artifact)
    if silent:
        print(
            'No fuzzers are running.  Include \'name\' to check specific fuzzers.'
        )
        return 1
    return 0