quickemu-project / quicktest

Quickly and automatically test systems inside Quickemu virtual machines 🧑‍🔬
MIT License
16 stars 3 forks source link

bug: qt_send_key doesn't work with down, end, f10, probably others #38

Open ali1234 opened 1 month ago

ali1234 commented 1 month ago

Test case (put this in one of the ubuntu 24.04 tests):

function test_post_boot_grub() {
    # Wait a while for EUFI or BIOS to pass
    # We could skip having this function, but it's nice to have
    # So we have the opportunity to click that stupid dialog
    qt_wait_for_seconds 10
    # Wait for the grub menu
    qt_wait_for_text "$FUNCNAME" "$text_console_gnu_grub" 10 5

    qt_send_key "e"
    qt_wait_for_seconds 1
    qt_send_key "down"
    qt_wait_for_seconds 1
    qt_send_key "down"
    qt_wait_for_seconds 1
    qt_send_key "down"
    qt_wait_for_seconds 1
    qt_send_key "end"
    qt_wait_for_seconds 1
    qt_send_string " console=ttyS0,115200"
    qt_screenshot_ppm "$FUNCNAME"
    qt_send_key "f10"
}

What should happen:

What actually happens:

image

The "console=..." should be at the end of the line beginning with "linux".

ali1234 commented 1 month ago

According to https://en.wikibooks.org/wiki/QEMU/Monitor#sendkey_keys these are the correct key names so I don't know why they don't work. Performing these steps manually through the viewer does work (F10 seems to be grabbed by the viewer, but ctrl-x works instead).

popey commented 1 month ago

Have you tried qt_send_key_combo? Which does no translation/mapping? It's a bit horrid, but there's two functions in Quicktest for this reason. The qt_send_key_combo lets you send the raw ret, esc ctrl-alt-f1 combinations that Qemu recognises. Whereas the qt_send_key function does the whole mapping of # to shift-f3 or whatever it is for your keyboard layout.

ali1234 commented 1 month ago

qt_send_key_combo works.

In order to avoid confusion, I would make only qt_send_string handle remapping, then make qt_send_key do what qt_send_key_combo does, and remove the latter. Finally qt_send_key should display an error for invalid keys instead of silently doing nothing.