Commit 8b19f2b7 authored by Eric Blake's avatar Eric Blake Committed by Thomas Huth
Browse files

tests/boot-sector: Drop dependence on global_qtest



As a general rule, we prefer avoiding implicit global state
because it makes code harder to safely copy and paste without
thinking about the global state.  Adjust the helper code to
use explicit state instead, and update all callers.

Fix some trailing whitespace while touching the file.

Signed-off-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
parent 6a5c88f5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -668,7 +668,7 @@ static void test_acpi_one(const char *params, test_data *data)

    qtest_start(args);

    boot_sector_test();
    boot_sector_test(global_qtest);

    data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
    test_acpi_rsdp_address(data);
+4 −4
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ int boot_sector_init(char *fname)
}

/* Loop until signature in memory is OK.  */
void boot_sector_test(void)
void boot_sector_test(QTestState *qts)
{
    uint8_t signature_low;
    uint8_t signature_high;
@@ -146,8 +146,8 @@ void boot_sector_test(void)
     * instruction.
     */
    for (i = 0; i < TEST_CYCLES; ++i) {
        signature_low = readb(SIGNATURE_ADDR);
        signature_high = readb(SIGNATURE_ADDR + 1);
        signature_low = qtest_readb(qts, SIGNATURE_ADDR);
        signature_high = qtest_readb(qts, SIGNATURE_ADDR + 1);
        signature = (signature_high << 8) | signature_low;
        if (signature == SIGNATURE) {
            break;
+4 −2
Original line number Diff line number Diff line
@@ -14,11 +14,13 @@
#ifndef TEST_BOOT_SECTOR_H
#define TEST_BOOT_SECTOR_H

#include "libqtest.h"

/* Create boot disk file. fname must be a suitable string for mkstemp() */
int boot_sector_init(char *fname);

/* Loop until signature in memory is OK.  */
void boot_sector_test(void);
void boot_sector_test(QTestState *qts);

/* unlink boot disk file.  */
void boot_sector_cleanup(const char *fname);
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ static void test_pxe_one(const testdef_t *test, bool ipv6)
        test->model);

    qtest_start(args);
    boot_sector_test();
    boot_sector_test(global_qtest);
    qtest_quit(global_qtest);
    g_free(args);
}
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static uint32_t acpi_find_vgia(void)
    int i;

    /* Wait for guest firmware to finish and start the payload. */
    boot_sector_test();
    boot_sector_test(global_qtest);

    /* Tables should be initialized now. */
    rsdp_offset = acpi_find_rsdp_address();