[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 23/39] tests/unit: Do not reference QemuLogFile directly
From: |
Richard Henderson |
Subject: |
[PULL 23/39] tests/unit: Do not reference QemuLogFile directly |
Date: |
Wed, 20 Apr 2022 11:06:02 -0700 |
Use qemu_log_lock/unlock instead of the raw rcu_read.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220417183019.755276-24-richard.henderson@linaro.org>
---
tests/unit/test-logging.c | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/tests/unit/test-logging.c b/tests/unit/test-logging.c
index 4c595356ae..87db7fe04a 100644
--- a/tests/unit/test-logging.c
+++ b/tests/unit/test-logging.c
@@ -109,12 +109,10 @@ static void test_parse_path(gconstpointer data)
static void test_logfile_write(gconstpointer data)
{
- QemuLogFile *logfile;
- QemuLogFile *logfile2;
+ FILE *logfile0, *logfile1;
gchar const *dir = data;
- g_autofree gchar *file_path = NULL;
+ g_autofree gchar *file_path0 = NULL;
g_autofree gchar *file_path1 = NULL;
- FILE *orig_fd;
/*
* Before starting test, set log flags, to ensure the file gets
@@ -123,29 +121,28 @@ static void test_logfile_write(gconstpointer data)
* this is needed.
*/
qemu_set_log(CPU_LOG_TB_OUT_ASM, &error_abort);
- file_path = g_build_filename(dir, "qemu_test_log_write0.log", NULL);
+ file_path0 = g_build_filename(dir, "qemu_test_log_write0.log", NULL);
file_path1 = g_build_filename(dir, "qemu_test_log_write1.log", NULL);
/*
* Test that even if an open file handle is changed,
* our handle remains valid due to RCU.
*/
- qemu_set_log_filename(file_path, &error_abort);
- rcu_read_lock();
- logfile = qatomic_rcu_read(&qemu_logfile);
- orig_fd = logfile->fd;
- g_assert(logfile && logfile->fd);
- fprintf(logfile->fd, "%s 1st write to file\n", __func__);
- fflush(logfile->fd);
+ qemu_set_log_filename(file_path0, &error_abort);
+ logfile0 = qemu_log_trylock();
+ g_assert(logfile0);
+ fprintf(logfile0, "%s 1st write to file\n", __func__);
+ fflush(logfile0);
/* Change the logfile and ensure that the handle is still valid. */
qemu_set_log_filename(file_path1, &error_abort);
- logfile2 = qatomic_rcu_read(&qemu_logfile);
- g_assert(logfile->fd == orig_fd);
- g_assert(logfile2->fd != logfile->fd);
- fprintf(logfile->fd, "%s 2nd write to file\n", __func__);
- fflush(logfile->fd);
- rcu_read_unlock();
+ logfile1 = qemu_log_trylock();
+ g_assert(logfile1);
+ g_assert(logfile0 != logfile1);
+ fprintf(logfile0, "%s 2nd write to file\n", __func__);
+ fflush(logfile0);
+ qemu_log_unlock(logfile0);
+ qemu_log_unlock(logfile1);
}
static void test_logfile_lock(gconstpointer data)
--
2.34.1
- [PULL 10/39] util/log: Remove qemu_log_vprintf, (continued)
- [PULL 10/39] util/log: Remove qemu_log_vprintf, Richard Henderson, 2022/04/20
- [PULL 11/39] tcg: Pass the locked filepointer to tcg_dump_ops, Richard Henderson, 2022/04/20
- [PULL 14/39] accel/tcg: Use cpu_dump_state between qemu_log_trylock/unlock, Richard Henderson, 2022/04/20
- [PULL 15/39] target/nios2: Remove log_cpu_state from reset, Richard Henderson, 2022/04/20
- [PULL 16/39] util/log: Use qemu_log_trylock/unlock in qemu_log, Richard Henderson, 2022/04/20
- [PULL 19/39] util/log: Remove qemu_log_flush, Richard Henderson, 2022/04/20
- [PULL 18/39] util/log: Mark qemu_log_trylock as G_GNUC_WARN_UNUSED_RESULT, Richard Henderson, 2022/04/20
- [PULL 20/39] util/log: Drop call to setvbuf, Richard Henderson, 2022/04/20
- [PULL 17/39] util/log: Drop return value from qemu_log, Richard Henderson, 2022/04/20
- [PULL 24/39] include/exec/log: Do not reference QemuLogFile directly, Richard Henderson, 2022/04/20
- [PULL 23/39] tests/unit: Do not reference QemuLogFile directly,
Richard Henderson <=
- [PULL 21/39] bsd-user: Expand log_page_dump inline, Richard Henderson, 2022/04/20
- [PULL 25/39] include/qemu/log: Move entire implementation out-of-line, Richard Henderson, 2022/04/20
- [PULL 22/39] linux-user: Expand log_page_dump inline, Richard Henderson, 2022/04/20
- [PULL 27/39] util/log: Introduce qemu_set_log_filename_flags, Richard Henderson, 2022/04/20
- [PULL 26/39] sysemu/os-win32: Test for and use _lock_file/_unlock_file, Richard Henderson, 2022/04/20
- [PULL 29/39] linux-user: Use qemu_set_log_filename_flags, Richard Henderson, 2022/04/20
- [PULL 30/39] softmmu: Use qemu_set_log_filename_flags, Richard Henderson, 2022/04/20
- [PULL 31/39] util/log: Remove qemu_log_close, Richard Henderson, 2022/04/20
- [PULL 32/39] util/log: Rename logfilename to global_filename, Richard Henderson, 2022/04/20
- [PULL 35/39] util/log: Hoist the eval of is_daemonized in qemu_set_log_internal, Richard Henderson, 2022/04/20