From patchwork Mon Jul 22 11:04:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 813713 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1811547wro; Mon, 22 Jul 2024 04:06:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVKx+PzEwiWbEqfbV/9cfIQfmZudSOnMqesDkHtuoCkWrQHJWK12L5Nfy3gvie9UtuB2w9Nu8aFjwrljZGj2Acz X-Google-Smtp-Source: AGHT+IERwkeTpIOXNpkmPm1QOPD5VAXvmRu1LBMWIZu0XFHHX9PADCnSHmFq37HEH077WOFSLiY1 X-Received: by 2002:a05:622a:1a9d:b0:447:f445:9291 with SMTP id d75a77b69052e-44fa536b33cmr85722621cf.59.1721646381247; Mon, 22 Jul 2024 04:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721646381; cv=none; d=google.com; s=arc-20160816; b=W4FtLggsJmMPlOYtzTJs/8w8atRIHouWjiimArX/+Ndraxm+Pq+Hf4kgrCHWkt5QNA MxVxwC/hNoiGyXTb2UAzXki8wJaJ0TisLhBbYMISoCXgHlmS0SeZvFcPda5Wafq707mD M/SwlYA5oGpGghXKVZCx/6QLSmanGGKu743U/iNs1n+nL7y0PYJDEgOLz65MbF07AFfE QnMQxi8oUVcq/e+U9ZgJ5Exas2UMJLByNmyu9DYNukIjSnqakj0o5UwPQUz081+l7ize MQ6smsk2EW5ax67SypaL96jT/8RjiOgQeEIbnxl6QVEyPhQ2LKz3S35lgfGIuTHSsA1/ aR6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=ve/EVDm+/avLGnI6H90trY1ZG2F2hzrIYhnNFlab21k=; fh=5VfksGkLSIfI8Y2mJuNvmJ0Yf7cc2crceeyE/6eCO1s=; b=o4p1bU/ShIbRzHY59wHt8f6+DUQiX89lYLRnfbinjpsJ+6g0bvVffw97dKmqz6O1cM ntpzX/yGGrOiCf1iE1Fd0zaLtDdbLoQOw3VvxqTJmJIftl24K8eHpsRlEMpvIYGs6A7S uyp1GCSA/uwtpXY1KFD+ydKz2eKqUlqQeNHyirFl/kSXAvsfkwFDF7Q4GSjxKGUcM3QF jKSqoIE7FN6eHbZ+Ee3gDgUv+hPYJVR3aXcWiZELPLNC+UDrSIow97GLgK7/arrujszd /zxQGHFFruuhjoSX93s5XghpXn+exjtqPVqqWQhZxKIXPN9N2FxaCaUNJfe01vNbDwCB vENw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Bxk5oYch; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9ccfd642si77824721cf.114.2024.07.22.04.06.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 04:06:21 -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=Bxk5oYch; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sVqqE-000651-Ns; Mon, 22 Jul 2024 07:04:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sVqq8-0005gu-P7 for qemu-devel@nongnu.org; Mon, 22 Jul 2024 07:04:24 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVqq6-0002SE-SY for qemu-devel@nongnu.org; Mon, 22 Jul 2024 07:04:24 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-a6fd513f18bso365876666b.3 for ; Mon, 22 Jul 2024 04:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721646261; x=1722251061; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ve/EVDm+/avLGnI6H90trY1ZG2F2hzrIYhnNFlab21k=; b=Bxk5oYchM6CL4kJsCkOfPOQJJmsH6lxbVkjj1WjOEc2OhPXvTob102FMTGFsPsHyBa D6nhJJoBnOwp7vcsLvxmW+j3fGxMEv+T0FxfXxQuJBr56xZeKxKQhw9bTXE9doTlI4Bd eFJX+bwsGGcsRQ6aE5lVQbQuF0ZVlnK36GU5IAL9trBLYvITX83iFJO9/fdJ3FBvn8Ja 4UvzeNQWpcz+JMoVrwDc14RhAHHaI3xbtkwhpFyn4hxp8E24o8dlY0S2ODjqSvDRbbC4 F3pnQnvT0d7mif93YDdgHtJTkRfMBv9NjDRnI/jWQ8UmpdGf9MHW0FFt2QPciY5Tmy/V NvnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721646261; x=1722251061; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ve/EVDm+/avLGnI6H90trY1ZG2F2hzrIYhnNFlab21k=; b=nSw2mXDJAIwu2Ri0Rnvw//J2oUwocu8nwYP6JyOBVXlo0up9HCsbZV4FMIRZPQE+7P uDhbu/RAq5ZYppoi4qR2ONrcSoP4CXw2fkRUKQ4NdtT1xKR6wcGWsxv7Wp4sps28rF6A PsMsaqFEwVKzZKaRI4dIrK4yBefgluZB6V9uolOYIasRjvhHH7CT8tFOPx8XJxfA883r 3rUNNIsh1KKlFcnMLpY0a4ACX9mSRXdyF1E3fD6oza/6ytDb2ymzO1F8IyFNnrAs0Apz NcOo9FTQfoUEzTty2ygaTQh7c78yBfPnzc43k3UYIbQMsNnQO5LgqgfiG7+3k0ya7av8 7+ow== X-Gm-Message-State: AOJu0Yydh3V+c/1Jys7tuzbojyYJvlbE0sv+ntilGdmMa0WEzwkTFakz zr1xz+m5UzXQlzF8GUe26QfBgGJQeEU2oe4ceUnq7W5LjESbUnZ7py/gSvUIIlg= X-Received: by 2002:a17:906:aa55:b0:a77:e1fb:7df6 with SMTP id a640c23a62f3a-a7a011177a7mr901431066b.7.1721646260996; Mon, 22 Jul 2024 04:04:20 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c785c6csm407394666b.20.2024.07.22.04.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 04:04:18 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2BC305F9FB; Mon, 22 Jul 2024 12:04:14 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 06/16] tests/plugins: use qemu_plugin_outs for inline stats Date: Mon, 22 Jul 2024 12:04:03 +0100 Message-Id: <20240722110413.118418-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240722110413.118418-1-alex.bennee@linaro.org> References: <20240722110413.118418-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x633.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 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Using bare printf's in plugins is perfectly acceptable but they do rather mess up the output of "make check-tcg". Convert the printfs to use g_string and then output with the plugin output helper which will already be captured to .pout files by the test harness. Reviewed-by: Pierrick Bouvier Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20240718094523.1198645-7-alex.bennee@linaro.org> diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c index cd63827b7d..73dde99578 100644 --- a/tests/plugin/inline.c +++ b/tests/plugin/inline.c @@ -71,10 +71,12 @@ static void stats_insn(void) const uint64_t cond_track_left = qemu_plugin_u64_sum(insn_cond_track_count); const uint64_t conditional = cond_num_trigger * cond_trigger_limit + cond_track_left; - printf("insn: %" PRIu64 "\n", expected); - printf("insn: %" PRIu64 " (per vcpu)\n", per_vcpu); - printf("insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); - printf("insn: %" PRIu64 " (cond cb)\n", conditional); + g_autoptr(GString) stats = g_string_new(""); + g_string_append_printf(stats, "insn: %" PRIu64 "\n", expected); + g_string_append_printf(stats, "insn: %" PRIu64 " (per vcpu)\n", per_vcpu); + g_string_append_printf(stats, "insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_string_append_printf(stats, "insn: %" PRIu64 " (cond cb)\n", conditional); + qemu_plugin_outs(stats->str); g_assert(expected > 0); g_assert(per_vcpu == expected); g_assert(inl_per_vcpu == expected); @@ -91,10 +93,12 @@ static void stats_tb(void) const uint64_t cond_track_left = qemu_plugin_u64_sum(tb_cond_track_count); const uint64_t conditional = cond_num_trigger * cond_trigger_limit + cond_track_left; - printf("tb: %" PRIu64 "\n", expected); - printf("tb: %" PRIu64 " (per vcpu)\n", per_vcpu); - printf("tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); - printf("tb: %" PRIu64 " (conditional cb)\n", conditional); + g_autoptr(GString) stats = g_string_new(""); + g_string_append_printf(stats, "tb: %" PRIu64 "\n", expected); + g_string_append_printf(stats, "tb: %" PRIu64 " (per vcpu)\n", per_vcpu); + g_string_append_printf(stats, "tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_string_append_printf(stats, "tb: %" PRIu64 " (conditional cb)\n", conditional); + qemu_plugin_outs(stats->str); g_assert(expected > 0); g_assert(per_vcpu == expected); g_assert(inl_per_vcpu == expected); @@ -107,9 +111,11 @@ static void stats_mem(void) const uint64_t per_vcpu = qemu_plugin_u64_sum(count_mem); const uint64_t inl_per_vcpu = qemu_plugin_u64_sum(count_mem_inline); - printf("mem: %" PRIu64 "\n", expected); - printf("mem: %" PRIu64 " (per vcpu)\n", per_vcpu); - printf("mem: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + g_autoptr(GString) stats = g_string_new(""); + g_string_append_printf(stats, "mem: %" PRIu64 "\n", expected); + g_string_append_printf(stats, "mem: %" PRIu64 " (per vcpu)\n", per_vcpu); + g_string_append_printf(stats, "mem: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + qemu_plugin_outs(stats->str); g_assert(expected > 0); g_assert(per_vcpu == expected); g_assert(inl_per_vcpu == expected); @@ -118,6 +124,7 @@ static void stats_mem(void) static void plugin_exit(qemu_plugin_id_t id, void *udata) { const unsigned int num_cpus = qemu_plugin_num_vcpus(); + g_autoptr(GString) stats = g_string_new(""); g_assert(num_cpus == max_cpu_index + 1); for (int i = 0; i < num_cpus ; ++i) { @@ -135,20 +142,21 @@ static void plugin_exit(qemu_plugin_id_t id, void *udata) qemu_plugin_u64_get(insn_cond_num_trigger, i); const uint64_t insn_cond_left = qemu_plugin_u64_get(insn_cond_track_count, i); - printf("cpu %d: tb (%" PRIu64 ", %" PRIu64 - ", %" PRIu64 " * %" PRIu64 " + %" PRIu64 - ") | " - "insn (%" PRIu64 ", %" PRIu64 - ", %" PRIu64 " * %" PRIu64 " + %" PRIu64 - ") | " - "mem (%" PRIu64 ", %" PRIu64 ")" - "\n", - i, - tb, tb_inline, - tb_cond_trigger, cond_trigger_limit, tb_cond_left, - insn, insn_inline, - insn_cond_trigger, cond_trigger_limit, insn_cond_left, - mem, mem_inline); + g_string_printf(stats, "cpu %d: tb (%" PRIu64 ", %" PRIu64 + ", %" PRIu64 " * %" PRIu64 " + %" PRIu64 + ") | " + "insn (%" PRIu64 ", %" PRIu64 + ", %" PRIu64 " * %" PRIu64 " + %" PRIu64 + ") | " + "mem (%" PRIu64 ", %" PRIu64 ")" + "\n", + i, + tb, tb_inline, + tb_cond_trigger, cond_trigger_limit, tb_cond_left, + insn, insn_inline, + insn_cond_trigger, cond_trigger_limit, insn_cond_left, + mem, mem_inline); + qemu_plugin_outs(stats->str); g_assert(tb == tb_inline); g_assert(insn == insn_inline); g_assert(mem == mem_inline);