diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2024-02-27 14:43:30 +0000 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2024-02-28 09:11:42 +0000 |
commit | 6036b9cfde74f45af7ef449d7c034fb8a9cf2901 (patch) | |
tree | 4452845680a7fd23acece1f14b56257b2aca07f9 | |
parent | 8df5e27cf71c727a3e1bc9172819ec69eca32ff4 (diff) | |
download | qemu-6036b9cfde74f45af7ef449d7c034fb8a9cf2901.zip qemu-6036b9cfde74f45af7ef449d7c034fb8a9cf2901.tar.gz qemu-6036b9cfde74f45af7ef449d7c034fb8a9cf2901.tar.bz2 |
tests/tcg: expand insn test case to exercise register API
This ensure we at least read every register the plugin API reports at
least once during the check-tcg checks.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20240227144335.1196131-25-alex.bennee@linaro.org>
-rw-r--r-- | tests/plugin/insn.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/plugin/insn.c b/tests/plugin/insn.c index 5fd3017..54da06f 100644 --- a/tests/plugin/insn.c +++ b/tests/plugin/insn.c @@ -46,6 +46,25 @@ typedef struct { char *disas; } Instruction; +/* + * Initialise a new vcpu with reading the register list + */ +static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + g_autoptr(GArray) reg_list = qemu_plugin_get_registers(); + g_autoptr(GByteArray) reg_value = g_byte_array_new(); + + if (reg_list) { + for (int i = 0; i < reg_list->len; i++) { + qemu_plugin_reg_descriptor *rd = &g_array_index( + reg_list, qemu_plugin_reg_descriptor, i); + int count = qemu_plugin_read_register(rd->handle, reg_value); + g_assert(count > 0); + } + } +} + + static void vcpu_insn_exec_before(unsigned int cpu_index, void *udata) { unsigned int i = cpu_index % MAX_CPUS; @@ -212,6 +231,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, sizes = g_array_new(true, true, sizeof(unsigned long)); } + /* Register init, translation block and exit callbacks */ + qemu_plugin_register_vcpu_init_cb(id, vcpu_init); qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); return 0; |