g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
} while (0)
-static const char *disk = "tests/acpi-test-disk.raw";
+static char disk[] = "tests/acpi-test-disk-XXXXXX";
static const char *data_dir = "tests/acpi-test-data";
#ifdef CONFIG_IASL
static const char *iasl = stringify(CONFIG_IASL);
};
/* Create boot disk file. */
-int boot_sector_init(const char *fname)
+int boot_sector_init(char *fname)
{
- FILE *f = fopen(fname, "w");
+ int fd, ret;
size_t len = sizeof boot_sector;
- if (!f) {
+ fd = mkstemp(fname);
+ if (fd < 0) {
fprintf(stderr, "Couldn't open \"%s\": %s", fname, strerror(errno));
return 1;
}
HIGH(SIGNATURE), BOOT_SECTOR_ADDRESS + SIGNATURE_OFFSET + 1);
}
- fwrite(boot_sector, 1, len, f);
- fclose(f);
+ ret = write(fd, boot_sector, len);
+ close(fd);
+
+ if (ret != len) {
+ fprintf(stderr, "Could not write \"%s\"", fname);
+ return 1;
+ }
+
return 0;
}
#ifndef TEST_BOOT_SECTOR_H
#define TEST_BOOT_SECTOR_H
-/* Create boot disk file. */
-int boot_sector_init(const char *fname);
+/* 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);
#define NETNAME "net0"
-static const char *disk = "tests/pxe-test-disk.raw";
+static char disk[] = "tests/pxe-test-disk-XXXXXX";
static void test_pxe_one(const char *params, bool ipv6)
{