From patchwork Sat Mar 26 13:25:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 554379 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1248:0:0:0:0 with SMTP id z8csp6448062mag; Sat, 26 Mar 2022 07:04:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0dJ9+8bTaSkix6vGtD6dp5wdiCJQn7B16Cl5or+rxZr9owgvODSVvG4zfq4JVfmGn+rpc X-Received: by 2002:a0c:fe47:0:b0:42d:f798:3da5 with SMTP id u7-20020a0cfe47000000b0042df7983da5mr13786655qvs.77.1648303465514; Sat, 26 Mar 2022 07:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648303465; cv=none; d=google.com; s=arc-20160816; b=TJSAaMs1c/YK/1X2bf/jNaFCfqMLZwiUt7njeZqM1NQV/+ZiMZLcVWm3ssZw7zguI8 G8pEBfPJZz5QhDeNOJu/NPl8B2HVHG1ppILDiAaM9hLnnpfo8Yh1MxFtTMPXTmnbMgZg 16DytgdpPTd0cv0g6eRA2GG8lNzpemTV99xX2SUtra4ZUUa8LA7i0UnycXZsISDoTCSt pGRbfDBZXFRBJzIJPh6yGePx17A3tCzStkbx+WZaoYEDiOSPF1POOuWvhgEiXjcMRDhW GENNEckvvruJhBaEhXKgpMQ4YAzT89PEUN5rMjvbV/MO3go6g6UkVaPcMBviCfpuIZ6o 5T4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Xvpxj4nK9wpX7Z4tgHMyHFYd/y+hd6ZVPNnNHANWilg=; b=GEAndLGeSdxwGiDgOVj2w9RUNrEWkEaHg9dh5h6o3NpvdWF1qXrKQ2DySuQlaglOk3 23A7rKwWygWp9MGgzxqyJxBWlTlqjTC+VN4ZtJLq4IggwTkZGVVGA2ExPkSG5KhE53Om aa6FdvuS0buwk1wHvgxmNywM/Z4tF+b/NizpMRa0LC7qrHJ2V++vK/U3HBqNjgyjZzYP FRqNAFMsAAQ4VvcyUqwi2clc3zOSjbgNJnyuxNPEdHwhepBk9ePOI3mkyISccAEQOqD+ hRsxcM66pdnje2RmpKVw1fZghCDV3aoLhPjGzpvVOZcmkVcbn7yvTHSExfN2lqz0fpqq W33g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TgEJo57i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 98-20020a0c816b000000b00440e46a7d8dsi3838761qvc.555.2022.03.26.07.04.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 26 Mar 2022 07:04:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TgEJo57i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nY71l-0000Sn-3E for patch@linaro.org; Sat, 26 Mar 2022 10:04:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nY6R3-0007Zp-9B for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:30 -0400 Received: from [2607:f8b0:4864:20::234] (port=34583 helo=mail-oi1-x234.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nY6R1-0005X8-Og for qemu-devel@nongnu.org; Sat, 26 Mar 2022 09:26:29 -0400 Received: by mail-oi1-x234.google.com with SMTP id v75so11116308oie.1 for ; Sat, 26 Mar 2022 06:26:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Xvpxj4nK9wpX7Z4tgHMyHFYd/y+hd6ZVPNnNHANWilg=; b=TgEJo57iboti6CrVqfODuxx/cJ8iwhTI/hF+IObiEq38zwUhFdpf4IxOdTOIolQ4Ry 2MTO8/582lZkrfar8tv5ZYu8AtBQOUKrJjIFLnbWVvAIm3TGtIM15NhA9l2AC5ld2EI6 qmvPu16X/FzHK2xibb734uIJPPfNMftXmp7RB+V4zZdjyCqlg86m8i8aYzW8YugLr22Q nAzaPy67cZxD7veWqbioSTiF7Ex1ENdSJx29GQmt3sbFvbfm8bDdBCn0uPGl6jSbgA9r kV8MSbxsguMYsVWUULhPblC1Gc5mzjCcicZMtPOZboEhBLk+P4H9p6loDP9xqEAJPvq6 U+Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xvpxj4nK9wpX7Z4tgHMyHFYd/y+hd6ZVPNnNHANWilg=; b=ntsfXHxiyevs9KMeOlohCGtkw6XdJNa0nmIqDiOFNd6v8mx+9QkiIaqB7IF9ey2hPG qyEyllt/DhLpU0RGdB9C7tIdgylA97wLhxT4SwypGqNrJToO2ywj4XsAEDKwytWJUL9W /r9mYZKNwHe7asXL5pS4VVhbTbZFmxU5dCCfFtxYDLn8X6D58UyyAzTFycd/YHIRzpZ3 faVNNmL1sSNh9cC06XBbxi1UZ9nM7crmratQqIrXiVm0nXmPB9aURqkbD0VXRXj9801N +zAokjDVY1Uk/SVMv4mEMha6GyKTjl93JQfAUqvWYDBWQaVA2iwkqRDZnzfA9ere+hnu tLuQ== X-Gm-Message-State: AOAM532YWVN2DjMVQPB8iSXjZYBxngp2ewuIZW1FTNB0CYAni2OeIZIU vIOMumAOi0k8ULrKbDyVDideGpPgcsv99eSI X-Received: by 2002:aca:4b88:0:b0:2d9:f709:2c07 with SMTP id y130-20020aca4b88000000b002d9f7092c07mr7339543oia.212.1648301186044; Sat, 26 Mar 2022 06:26:26 -0700 (PDT) Received: from localhost.localdomain (168.189-204-159.bestelclientes.com.mx. [189.204.159.168]) by smtp.gmail.com with ESMTPSA id n62-20020acaef41000000b002ef646e6690sm4610331oih.53.2022.03.26.06.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Mar 2022 06:26:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 23/39] tests/unit: Do not reference QemuLogFile directly Date: Sat, 26 Mar 2022 07:25:18 -0600 Message-Id: <20220326132534.543738-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220326132534.543738-1-richard.henderson@linaro.org> References: <20220326132534.543738-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::234 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use qemu_log_lock/unlock instead of the raw rcu_read. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- 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 54d7e8e33b..dcb8ac70df 100644 --- a/tests/unit/test-logging.c +++ b/tests/unit/test-logging.c @@ -110,12 +110,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 @@ -124,29 +122,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)