Skip to content

Commit de35244

Browse files
ani-sinhamstsirkin
authored andcommitted
tests/acpi/bios-tables-test: do not write new blobs unless there are changes
When dumping table blobs using rebuild-expected-aml.sh, table blobs from all test variants are dumped regardless of whether there are any actual changes to the tables or not. This creates lot of new files for various test variants that are not part of the git repository. This is because we do not check in all table blobs for all test variants into the repository. Only those blobs for those variants that are different from the generic test-variant agnostic blob are checked in. This change makes the test smarter by checking if at all there are any changes in the tables from the checked-in gold master blobs and take actions accordingly. When there are no changes: - No new table blobs would be written. - Existing table blobs will be refreshed (git diff will show no changes). When there are changes: - New table blob files will be dumped. - Existing table blobs will be refreshed (git diff will show that the files changed, asl diff will show the actual changes). When new tables are introduced: - Zero byte empty file blobs for new tables as instructed in the header of bios-tables-test.c will be regenerated to actual table blobs. This would make analyzing changes to tables less confusing and there would be no need to clean useless untracked files when there are no table changes. CC: peter.maydell@linaro.org Signed-off-by: Ani Sinha <anisinha@redhat.com> Message-Id: <20231107044952.5461-1-anisinha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Acked-by: Igor Mammedov <imammedo@redhat.com>
1 parent cadfc72 commit de35244

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/qtest/bios-tables-test.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static const char *iasl;
112112
#endif
113113

114114
static int verbosity_level;
115+
static GArray *load_expected_aml(test_data *data);
115116

116117
static bool compare_signature(const AcpiSdtTable *sdt, const char *signature)
117118
{
@@ -244,21 +245,32 @@ static void test_acpi_fadt_table(test_data *data)
244245

245246
static void dump_aml_files(test_data *data, bool rebuild)
246247
{
247-
AcpiSdtTable *sdt;
248+
AcpiSdtTable *sdt, *exp_sdt;
248249
GError *error = NULL;
249250
gchar *aml_file = NULL;
251+
test_data exp_data = {};
250252
gint fd;
251253
ssize_t ret;
252254
int i;
253255

256+
exp_data.tables = load_expected_aml(data);
254257
for (i = 0; i < data->tables->len; ++i) {
255258
const char *ext = data->variant ? data->variant : "";
256259
sdt = &g_array_index(data->tables, AcpiSdtTable, i);
260+
exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, i);
257261
g_assert(sdt->aml);
262+
g_assert(exp_sdt->aml);
258263

259264
if (rebuild) {
260265
aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
261266
sdt->aml, ext);
267+
if (!g_file_test(aml_file, G_FILE_TEST_EXISTS) &&
268+
sdt->aml_len == exp_sdt->aml_len &&
269+
!memcmp(sdt->aml, exp_sdt->aml, sdt->aml_len)) {
270+
/* identical tables, no need to write new files */
271+
g_free(aml_file);
272+
continue;
273+
}
262274
fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
263275
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
264276
if (fd < 0) {

0 commit comments

Comments
 (0)