From patchwork Fri Jan 20 08:23:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 644628 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp658366pvb; Fri, 20 Jan 2023 00:25:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXuk7cvWh4gxCmzCP4wv0XcY1cJdnJqzw75J8xUKx2OD6i7eU+TU2fjDKDWzZpiBp9fErU1m X-Received: by 2002:ac8:718d:0:b0:3b5:5234:e895 with SMTP id w13-20020ac8718d000000b003b55234e895mr18789090qto.15.1674203136111; Fri, 20 Jan 2023 00:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674203136; cv=none; d=google.com; s=arc-20160816; b=WnPVdz0Q1lsZBaTAw5vFBMPD3hGKL86EbRt2HPDlSHDBLzrA5a2BArhvpDnUyx/cCS XAaYZRl9EoX7VsTruCHQYRJvkf895JxIOqLHRPuPq1EnS+FC1ag72VQnqarsGcxzF0oO uiQ4VmjU2mZ8oqW618NcssAfbIYQN6eYDSXTq2hN8HRb2gv4k21ya7DIYCpLgntosYFL y1Eq1QvojUEZmZxiueU4qNZneDMZX88aI/h393+w5J+FEDdO5+POZe9yy6CWJB4Y3EdV NjaNmg+G8VpsgWMjSH6aVhY9/sdiWIgj2iHF4IVKljVrcpz3ZoEdm//Q1DpOa9TjETYq uECg== 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=8eiWB2mgS5s8IODt1mSJBolF54HXrNWV0tPwSRIkLm8=; b=B5yqv+kj267KpFu6CYQ/OLwqVSB0wf7B8qFZ2y8qf7Nt1yzNuWjAgu61JOqVwUDTcS LN5Bszhu94WAjZyeh4diER20JeNvexOmZmP71yVyKLOtXu7MuCYDwIZjXmRFGejGpG0h HAAsuIpcY8UDwzJoHmuUfqqQ0RdUERZc88LPnUG0rxtMCPU9Fmj+SUcY1/6qpJ6/+Z0t WPnO1pMkKP3YN0684w0nwDxTqdauNo8fFErWKxRoy2UrRjJSPEozPbOrF61hr5AcQwGt Ci5GFathjglqR9Yuwq6iha1iAt3GP8jwXkdWG4rADB0OrVytPjJcjaYYfyGSGSNxK7du 5i5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T9fNlr7q; 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 i10-20020a05622a08ca00b003ac4b229ae1si548605qte.129.2023.01.20.00.25.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Jan 2023 00:25:36 -0800 (PST) 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=T9fNlr7q; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pImhX-0005O9-0R; Fri, 20 Jan 2023 03:24:43 -0500 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 1pImhS-0005Ia-QX for qemu-devel@nongnu.org; Fri, 20 Jan 2023 03:24:38 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pImhP-0004gJ-HP for qemu-devel@nongnu.org; Fri, 20 Jan 2023 03:24:37 -0500 Received: by mail-wm1-x332.google.com with SMTP id f12-20020a7bc8cc000000b003daf6b2f9b9so5273068wml.3 for ; Fri, 20 Jan 2023 00:24:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=8eiWB2mgS5s8IODt1mSJBolF54HXrNWV0tPwSRIkLm8=; b=T9fNlr7qdkM84eEPuX5uCJ76nlAtPpVEul0xug1Pz08e652KrE84UQWICNDZMBTEp7 If0+D41sb1wOoRWMMpmcG3Ab+JKEsBgY2q/ruawR0hNU3/U++QQc+uRklunMUUxHeyj1 /o9FbNoE2iSiLlW2WdqfMOGYsNe/r9RYgTMwmBh8S6G3V+Ngr8M55U4jM+pIx5lDH2CC RopvZgZ0ERsE0Z4U7m3pZLlyclIxTFdwDKLavsoz1HyTOm5SN2gDgS09QOm8275Ze7Ux cMuOdMbkKTi9h7XrwddtIb3AOmk/0iUmW9B8ifWc45hqvc03zmkANKHf6RpUUyDRyP44 CliQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=8eiWB2mgS5s8IODt1mSJBolF54HXrNWV0tPwSRIkLm8=; b=eXL7CCYF8lVLOdpMH4KYSP8uvSQd2AP6Kykuj1j2HuGwIxtjUwWfuvdpQCdl95kTd/ oWF1jOa8DEjER1HI0TMuc+d428q2afXXfcxiBu2Df+LXuer3gkGrsv9ZDwiFquxrnoMo PU/WnjFig1V19dmVu9sr6saTuz3g6q/L1Gi1xckUHCzCfn2P5nEc+muPqiQlT2I/nwr8 9CRS+AXr4ZAjTEyV5Dox45++lrJ9hZulT4lotNr19XPSKZfV2sUa2xkaFzm2UhIkzyIx OFyvxBL7SEb8oaVbY3zIJHvOOIxxdnEsiTwYKZ2o8aKB2yyzdGB6MDz9FrOaBOJxy5Bm AGdQ== X-Gm-Message-State: AFqh2krUg5WypVB++OvqqraiNeZN3V5z6ho7Fg1Ocz7gWmCNE6haIbXh RyzHVATboTpAFIs8Nc3Pxo0XdmEkyboX/UUf X-Received: by 2002:a05:600c:354e:b0:3db:331b:bd57 with SMTP id i14-20020a05600c354e00b003db331bbd57mr1073167wmq.23.1674203073952; Fri, 20 Jan 2023 00:24:33 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id hg8-20020a05600c538800b003d974076f13sm1552992wmb.3.2023.01.20.00.24.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Jan 2023 00:24:33 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , "Dr. David Alan Gilbert" , Thomas Huth , Fabiano Rosas , Juan Quintela , Laurent Vivier , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 10/11] tests/qtest/migration-test: Build command line using GString API (4/4) Date: Fri, 20 Jan 2023 09:23:40 +0100 Message-Id: <20230120082341.59913-11-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230120082341.59913-1-philmd@linaro.org> References: <20230120082341.59913-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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=unavailable 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 Part 4/4: Convert rest of options. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Juan Quintela --- tests/qtest/migration-test.c | 53 +++++++++++++++++------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 1ed3505c91..e7786bcbc5 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -585,8 +585,8 @@ static int test_migrate_start(QTestState **from, QTestState **to, g_autoptr(GString) cmd_common = NULL; g_autofree gchar *arch_source = NULL; g_autofree gchar *arch_target = NULL; - g_autofree gchar *cmd_target = NULL; - const gchar *ignore_stderr; + g_autoptr(GString) cmd_target = NULL; + const gchar *ignore_stderr = NULL; g_autofree char *bootpath = NULL; g_autofree char *shmem_path = NULL; const char *arch = qtest_get_arch(); @@ -666,12 +666,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, * IO redirection does not work, so don't bother adding IO redirection * to the command line. */ - ignore_stderr = ""; #else ignore_stderr = "2>/dev/null"; #endif - } else { - ignore_stderr = ""; } if (args->use_shmem) { @@ -683,31 +680,31 @@ static int test_migrate_start(QTestState **from, QTestState **to, } if (!args->only_target) { - g_autofree gchar *cmd_source = NULL; - - cmd_source = g_strdup_printf("%s " - "-name source,debug-threads=on " - "-serial file:%s/src_serial " - "%s %s %s", - cmd_common->str, - tmpfs, - arch_source, - args->opts_source ? args->opts_source : "", - ignore_stderr); - *from = qtest_init(cmd_source); + g_autoptr(GString) cmd_source = g_string_new(cmd_common->str); + g_string_append(cmd_source, "-name source,debug-threads=on "); + g_string_append_printf(cmd_source, "-serial file:%s/src_serial ", tmpfs); + g_string_append_printf(cmd_source, "%s ", arch_source); + if (args->opts_source) { + g_string_append_printf(cmd_source, "%s ", args->opts_source); + } + if (ignore_stderr) { + g_string_append(cmd_source, ignore_stderr); /* last string */ + } + *from = qtest_init(cmd_source->str); } - cmd_target = g_strdup_printf("%s " - "-name target,debug-threads=on " - "-serial file:%s/dest_serial " - "-incoming %s " - "%s %s %s", - cmd_common->str, - tmpfs, uri, - arch_target, - args->opts_target ? args->opts_target : "", - ignore_stderr); - *to = qtest_init(cmd_target); + cmd_target = g_string_new(cmd_common->str); + g_string_append(cmd_target, "-name target,debug-threads=on "); + g_string_append_printf(cmd_target, "-serial file:%s/dest_serial ", tmpfs); + g_string_append_printf(cmd_target, "-incoming %s ", uri); + g_string_append_printf(cmd_target, "%s ", arch_target); + if (args->opts_target) { + g_string_append_printf(cmd_target, "%s ", args->opts_target); + } + if (ignore_stderr) { + g_string_append(cmd_target, ignore_stderr); /* last string */ + } + *to = qtest_init(cmd_target->str); /* * Remove shmem file immediately to avoid memory leak in test failed case.