Esempio n. 1
0
def driver():
    yield timeout(1000)
    als = GPS.LanguageServer.get_by_language_name("Ada")

    b = GPS.EditorBuffer.get(GPS.File("main.adb"))
    b.current_view().goto(b.at(4, 5))
    yield hook('language_server_response_processed')

    GPS.execute_action("Entity called by")
    yield hook('language_server_response_processed')
    yield timeout(1000)

    call_tree = get_widget_by_name("Call Graph Tree")
    selection = call_tree.get_selection()
    selection.unselect_all()
    model = call_tree.get_model()
    selection.select_iter(model.iter_nth_child(model.get_iter_first(), 0))

    GPS.execute_action("calltree expand selected")
    yield hook('language_server_response_processed')

    expected = [
        'Foo is called by ',
        [
            'Foo', ['Foo', ['computing...'], 'Main', ['computing...']], 'Main',
            ['computing...']
        ]
    ]

    yield timeout(1000)
    gps_assert(expected, dump_tree_model(model, 0),
               "The model didn't contain the expected text")

    # Now verify that double-clicking on the row that lists 'Main'
    # correctly open its editor and selects it.

    GPS.execute_action("close all editors")
    yield wait_tasks(other_than=known_tasks)

    click_in_tree(call_tree,
                  path=Gtk.TreePath("0:0:1"),
                  button=1,
                  events=double_click_events)
    yield wait_idle()

    buffer = GPS.EditorBuffer.get()
    gps_assert(
        buffer.file(), GPS.File("main.adb"),
        "double-clicking on a Call Trees row should open an " +
        "editor for the clicked entity")
    gps_assert((buffer.selection_start(), buffer.selection_end()),
               (buffer.at(2, 11), buffer.at(2, 15)),
               "Main should be selected in main.adb after double-clicking " +
               "on its row in the Call Trees")
Esempio n. 2
0
def driver():
    # Launch a fuzzing session
    yield idle_modal_dialog(
        lambda: GPS.execute_action("gnatfuzz fuzz workflow"))
    yield wait_for_mdi_child("gnatfuzz fuzz")
    dialog = get_window_by_title("gnatfuzz fuzz")
    get_button_from_label("Execute", dialog).clicked()

    yield wait_for_mdi_child("Fuzz Crashes")

    view = get_widget_by_name("fuzz_crash_list_view")
    model = view.get_model()

    # Wait 20 seconds at most, until messages appear in the "Fuzz crashes" view

    time_waited = 0

    while time_waited < MAX_TIME_MS:
        if len(model) > 0:
            break
        yield timeout(INCREMENTS_MS)
        time_waited += INCREMENTS_MS

    # Test the contents of the model: presence of the crash...
    gps_assert(model[0][0], "1 (Crash)", "wrong contents in the first row")

    # ... and the fact that the faulty parameter (causing integer overflow)
    # is properly found by the fuzzer and displayed in the view.
    gps_assert(
        int(model[0, 0][1]),
        2**31 - 1,
        "wrong value for the parameter which causes the crash",
    )

    # We can stop fuzzing now that we've had one crash
    GPS.execute_action("gnatfuzz fuzz workflow")

    # Click in the view to launch a debug workflow
    click_in_tree(view, path="0", events=double_click_events)

    # Wait 20 seconds at most, until we have the right data in the debugger view

    debugger_text = None

    time_waited = 0

    expected_text = "Y := X + 1"

    while time_waited < MAX_TIME_MS:
        yield timeout(INCREMENTS_MS)
        time_waited += INCREMENTS_MS
        d = None
        try:
            d = GPS.Debugger.get()
        except GPS.Exception:
            pass
        if d is None:
            continue
        debugger_text = d.get_console().get_text()

        # The debugger console should contain this
        if expected_text in debugger_text:
            break

    gps_assert(expected_text in debugger_text, True,
               f"{expected_text} didn't appear in output:\n{debugger_text}")

    # Quit the debugger
    GPS.execute_action("terminate all debuggers")
    yield wait_idle()

    # Restart a fuzz session...
    yield idle_modal_dialog(
        lambda: GPS.execute_action("gnatfuzz fuzz workflow"))
    yield wait_for_mdi_child("gnatfuzz fuzz")
    dialog = get_window_by_title("gnatfuzz fuzz")
    get_button_from_label("Execute", dialog).clicked()

    # ... and kill it immediately
    yield timeout(100)
    GPS.execute_action("gnatfuzz fuzz workflow")

    # And verify that the Fuzz crashes view is empty
    gps_assert(len(model), 0,
               "The Fuzz crashes view should clear when starting a session")