From patchwork Sun Apr 17 18:30:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 562897 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp1889204map; Sun, 17 Apr 2022 12:09:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmWdOIycqS7TM7XlvwwWcJvjeOLAGTS6aUkOe3wqd2Z4XnUADQWgRKfa2kxg6EGi2Egsn6 X-Received: by 2002:a05:622a:124f:b0:2f1:64a2:3054 with SMTP id z15-20020a05622a124f00b002f164a23054mr5225466qtx.10.1650222575298; Sun, 17 Apr 2022 12:09:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650222575; cv=none; d=google.com; s=arc-20160816; b=GgLYFuxIma1Lj7CHNof01Uv9P9PRpL5dwRP+exT/ezww42/0H4SFtMMrholyqQQ7Fa d+B2/K/ow7ae04S3J0Phxnn+wy71G10HZ+YvUV2DmLBDCgSGtCne+qX5sFQw9xsRVot3 jdFdl1WA73sHNDRdOylwlv5glr1C1t71zVcRy+V5ML4fdtUQyxOl+Lzo1NQbwuK4eZ3+ poVE4SHL9YGY2bnvzleS7+YtPNfBcHvtyau5YDbfReVhYGkoYUXJ7puFxkEKwFeOM+EG 49WQKiO+E1PYrNGM4jRUbKnb/vSnNrkEC6nnVpkA76pQOxW97IbLma0D/6LuU8BgHcPs FE/A== 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=MFS05VM+1nmIS90ffHb9z5k4YW8IB7HF8idrdJvOqhE=; b=OXpuW0/c3Usm+p/JMfYkNk4zrhQoNVGrXCfGoog7rK4NJZkY0VBNXPi4KIWjzG1WWB 1VCx6peiOnvquW+FPlLruaXbPFxXZM/rvZLitskbOSTgGQy8XNAzb0uoymtus/kh9B/m NCaVHDMHagMjDanAj+hW8Ogd5IzhTLJrhPAd/wabxTkTLRz1SswZL0VVheS/gLy5Imfe F2IukUkRHzLbf2cFF6jFIsg18FNYwTkXB2kUkyNTqkpvMG9cfqVs6Wb34MBUIDSEC9Q7 VyWlTRl7pvApKZ9VnM3PYjfGJ2Yq0Bn8DbdaqzFyi2OXJN4E23gMdqzP0MxAlfgH04Nr kqDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yJG2L9DL; 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 bs23-20020ac86f17000000b002e20db39ca2si2595801qtb.39.2022.04.17.12.09.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 17 Apr 2022 12:09:35 -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=yJG2L9DL; 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]:41970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ngAH8-0001zy-T9 for patch@linaro.org; Sun, 17 Apr 2022 15:09:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ng9fY-0000U4-Sk for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:49 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:45835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ng9fW-0001oU-E8 for qemu-devel@nongnu.org; Sun, 17 Apr 2022 14:30:44 -0400 Received: by mail-pj1-x102d.google.com with SMTP id n33-20020a17090a5aa400b001d28f5ee3f9so785720pji.4 for ; Sun, 17 Apr 2022 11:30:41 -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=MFS05VM+1nmIS90ffHb9z5k4YW8IB7HF8idrdJvOqhE=; b=yJG2L9DL/hSy/pDCG7gUd9iaqRZjHV8pMMOiyIj4y8L9ilHJLGqKCidTFTqbl6YPmx HPYCbcwcuK3UwESKx4SqtSH5LV49+IKF8TFo+boRCl7kMvlP1AJq3L7xi3zSeN2XD4Eo vExwFNFF7RYOq1aVlv780G0yFaitiuyuz6EB9ZmRbnWvS2nd5oSSbzk8kP0dDHKbNqJN Dn68ZU/xNdvnEzl8+mAMCBrS6HjRR3DBzC2OSkrdvMhh+51MvvxPQz9x6LqFetwodq7I +lLyMDyWKMQmHrvcQtEGbhEn1ySLv9fv9+xiEWmBzIbHQsk35chWJc1/WCK6DpIs1XQW tNEQ== 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=MFS05VM+1nmIS90ffHb9z5k4YW8IB7HF8idrdJvOqhE=; b=NhRYnvpF4BYk1LiYkUFVQEgn1kRnUdYLPVs19b12lnCMgp6sJCYeTw6MPzPNhcu5n5 1H3nd1Gai3ncmovQ/cWZUG6LuIxN2e8wBmmCmK/xyxtKtmFxeaqGXVrKQGJTlWEH7cwb JlX/FF0N1TuOF84jWutDU7bHO2nq3qVZ8SpsUf4MIp37fKGdD6gIDPOS0/ahIth0QqDQ WiwkAXfm3WpUTpDaKlKBELtEdR5uaYjWdsMk7pExEVWUJsLN6qT+UTdNdixd1kSe9cr8 MUEw1H+pS1YsMcn/3lRCjoa4yM2FDdVWiDenF3d2/RLdQbnZZ0lCqCj81nBoJWE0FN27 cdsA== X-Gm-Message-State: AOAM533k82w7A9IE14KlGnglWJ+og4ThQ/G6eNQBRCxz5q9lx8/p/DcM HJY1RoNxUpG6wQKMol2d1ATEH6dKiUvfGQ== X-Received: by 2002:a17:903:2343:b0:158:d9e2:8049 with SMTP id c3-20020a170903234300b00158d9e28049mr7565243plh.3.1650220240365; Sun, 17 Apr 2022 11:30:40 -0700 (PDT) Received: from localhost.localdomain (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id on10-20020a17090b1d0a00b001d08a7d569csm8154011pjb.56.2022.04.17.11.30.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 11:30:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/39] tests/unit: Do not reference QemuLogFile directly Date: Sun, 17 Apr 2022 11:30:03 -0700 Message-Id: <20220417183019.755276-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220417183019.755276-1-richard.henderson@linaro.org> References: <20220417183019.755276-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- 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)