diff options
author | Akihiko Odaki <akihiko.odaki@daynix.com> | 2024-08-23 15:13:12 +0900 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2024-08-26 10:58:11 +0200 |
commit | aee07f2563d27167935ae3557a9f435937eb3f9f (patch) | |
tree | 4c05a7c8a9171f89a1baeae26a420206b11469e3 /tests | |
parent | 8f97deb99c8b48a34322b5e21e8dc061855551a4 (diff) |
tests/qtest: Delete previous boot file
A test run may create boot files several times. Delete the previous boot
file before creating a new one.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20240823-san-v4-7-a24c6dfa4ceb@daynix.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qtest/migration-test.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 70b606b888..6c06100d91 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -144,12 +144,23 @@ static char *bootpath; #include "tests/migration/ppc64/a-b-kernel.h" #include "tests/migration/s390x/a-b-bios.h" +static void bootfile_delete(void) +{ + unlink(bootpath); + g_free(bootpath); + bootpath = NULL; +} + static void bootfile_create(char *dir, bool suspend_me) { const char *arch = qtest_get_arch(); unsigned char *content; size_t len; + if (bootpath) { + bootfile_delete(); + } + bootpath = g_strdup_printf("%s/bootsect", dir); if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) { /* the assembled x86 boot sector should be exactly one sector large */ @@ -177,13 +188,6 @@ static void bootfile_create(char *dir, bool suspend_me) fclose(bootfile); } -static void bootfile_delete(void) -{ - unlink(bootpath); - g_free(bootpath); - bootpath = NULL; -} - /* * Wait for some output in the serial output file, * we get an 'A' followed by an endless string of 'B's |