diff options
author | Ben Gardon <bgardon@google.com> | 2022-06-13 21:25:18 +0000 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-06-24 04:51:47 -0400 |
commit | ed6b53ec9090133cd744705a09811cf627f3e9cb (patch) | |
tree | e5f65a1520b02f8b2cea0dc792c65a527edfcf2a /tools/testing/selftests/kvm/kvm_binary_stats_test.c | |
parent | 143e7eea3d66737c73cc3aa3538123ea3bb1f640 (diff) | |
download | linux-ed6b53ec9090133cd744705a09811cf627f3e9cb.tar.bz2 |
KVM: selftests: Read binary stat data in lib
Move the code to read the binary stats data to the KVM selftests
library. It will be re-used by other tests to check KVM behavior.
Also opportunistically remove an unnecessary calculation with
"size_data" in stats_test.
Reviewed-by: David Matlack <dmatlack@google.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Ben Gardon <bgardon@google.com>
Message-Id: <20220613212523.3436117-6-bgardon@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/kvm_binary_stats_test.c')
-rw-r--r-- | tools/testing/selftests/kvm/kvm_binary_stats_test.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/tools/testing/selftests/kvm/kvm_binary_stats_test.c b/tools/testing/selftests/kvm/kvm_binary_stats_test.c index a904873b2b86..b01e8b0851e7 100644 --- a/tools/testing/selftests/kvm/kvm_binary_stats_test.c +++ b/tools/testing/selftests/kvm/kvm_binary_stats_test.c @@ -147,15 +147,10 @@ static void stats_test(int stats_fd) ret = pread(stats_fd, stats_data, size_data, header.data_offset); TEST_ASSERT(ret == size_data, "Read KVM stats data"); /* Read kvm stats data one by one */ - size_data = 0; for (i = 0; i < header.num_desc; ++i) { pdesc = get_stats_descriptor(stats_desc, i, &header); - ret = pread(stats_fd, stats_data, - pdesc->size * sizeof(*stats_data), - header.data_offset + size_data); - TEST_ASSERT(ret == pdesc->size * sizeof(*stats_data), - "Read data of KVM stats: %s", pdesc->name); - size_data += pdesc->size * sizeof(*stats_data); + read_stat_data(stats_fd, &header, pdesc, stats_data, + pdesc->size); } free(stats_data); |