diff mbox series

[v2,3/3] plugins: extend insn test for new convenience functions

Message ID 20250131175716.3218600-4-lacraig3@gmail.com (mailing list archive)
State New
Headers show
Series plugins: add tb convenience functions | expand

Commit Message

Luke Craig Jan. 31, 2025, 5:57 p.m. UTC
From: Luke Craig <luke.craig@mit.edu>

---
 tests/tcg/plugins/insn.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/tests/tcg/plugins/insn.c b/tests/tcg/plugins/insn.c
index 0c723cb9ed..5974e9d6e6 100644
--- a/tests/tcg/plugins/insn.c
+++ b/tests/tcg/plugins/insn.c
@@ -142,6 +142,8 @@  static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
 {
     size_t n = qemu_plugin_tb_n_insns(tb);
     size_t i;
+    size_t tb_size = 0;
+    struct qemu_plugin_insn *last;
 
     for (i = 0; i < n; i++) {
         struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
@@ -156,6 +158,7 @@  static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
 
         if (do_size) {
             size_t sz = qemu_plugin_insn_size(insn);
+            tb_size += sz;
             if (sz > sizes->len) {
                 g_array_set_size(sizes, sz);
             }
@@ -188,6 +191,13 @@  static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
             g_free(insn_disas);
         }
     }
+
+    last = qemu_plugin_tb_get_insn(tb, n - 1);
+    g_assert(qemu_plugin_tb_get_insn_by_vaddr(tb, qemu_plugin_insn_vaddr(last)) == last);
+
+    if (do_size){
+        g_assert(tb_size == qemu_plugin_tb_size(tb));
+    }
 }
 
 static void plugin_exit(qemu_plugin_id_t id, void *p)