From patchwork Tue Oct 10 07:49:49 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: 731421 Delivered-To: patch@linaro.org Received: by 2002:a5d:574c:0:b0:31d:da82:a3b4 with SMTP id q12csp1606675wrw; Tue, 10 Oct 2023 00:52:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgM+YgcmdmuO6NWyBu8Q4ecl3vdhNSPfnaHXBnqiqu/uIgbJpdzfu2FjWlquVlJ5EPGhbw X-Received: by 2002:a05:620a:4008:b0:775:92ac:a0af with SMTP id h8-20020a05620a400800b0077592aca0afmr21769280qko.13.1696924339740; Tue, 10 Oct 2023 00:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696924339; cv=none; d=google.com; s=arc-20160816; b=GkFB16seJEuvoLYxI4yoE3HDtkDHkcWFGyAqJu2XDAKH5VYgq1E+EdqV2Q3xlxOp7L 1jfjhHtC+d66mWpv4Po83hNnyFddGfSynQ7WavCrAuObj1JOYvugdF9vMqgHNO+d0sFd ZPU76EDs/XH6eLTV+B5LKTlFD+MvzyTtarmLeoqmmz3DCdfhVldtM2suTW4wn8JIIcQY fd8WavsogaDWkgu6XvydaefqFuyVUNPExnZYGbrpAJwA0XE4kX92k5TlrxpRKTIhlzHh eWz+KDJ8Ylall7Zj+0uixDDrgRIdI2bLpKGJiPsVoYQzJT7xPoLzx5tYFHBwYHEdM0vc CaWQ== 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=xBzDwZo1XeWt7ItIGhOXUN3QV+md3tt2cNhSMxgmiwU=; fh=fvH34tHwViUOu98hGoeGCIVUhAkw1BzDAuMB2MXJND8=; b=gHbDP+DfO3otwC88OWxW6oNciHKYcDDwt+4iOXAE3smeMq4t+gRjBn5p+3E83cTHs2 oEFeH9zB0vL2zjo7FcTWnMXucWXplMMKMt16qU1EAxtGTGuut6c2vuV8ll6x+SE9Lkmi WHvUaSLAovxNrmU1sekO9UAd4bQeG25PWY4uSm1DBGtaOzn/kY9jn6ixROp4soRh5efx HrqAiThap1prbV52AhB4HnXQ8x08G7LqX/+Gtlyo/eGthKXGZCiWNOncBXX0T5MeUkeW SowBcCfBhGSujcQAYtqLm8zIGPmMyi2x4EefH02F3blvPwejjQTvYrlC57thEyHNMbmU zoIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GYfFz5Kz; 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 x19-20020a05620a099300b00767f86fc1f5si6914220qkx.474.2023.10.10.00.52.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Oct 2023 00:52:19 -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=GYfFz5Kz; 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 1qq7VI-0008ME-2P; Tue, 10 Oct 2023 03:50:08 -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 1qq7VF-0008KG-Sn for qemu-devel@nongnu.org; Tue, 10 Oct 2023 03:50:05 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qq7VD-0004b5-CB for qemu-devel@nongnu.org; Tue, 10 Oct 2023 03:50:05 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-9a6190af24aso926271466b.0 for ; Tue, 10 Oct 2023 00:50:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696924202; x=1697529002; 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=xBzDwZo1XeWt7ItIGhOXUN3QV+md3tt2cNhSMxgmiwU=; b=GYfFz5KzggGrfArSJY6N1EwatuHdkl8siUccOQeAkJ9tbk3lenbRt2fkvO2SYwWUF3 BAVcQ/AHYyIIVOzF2sSnFOT53rqYa/bEJPV0UL/AH4X/1R/ZkaBQdOmnjzTzr2wdv1Yg GrY+hdTlqFEKd9xPua/yJJqZf2Csz+KJmvonZpqyG/MqLXItbrWSVJxEMqy+VEIZ+lts 195qtfbBFHuTFyFavkxUtjsIXF3SeGrayJ0Wx7NTojcZzM+psQMcS77f9iKQUEgefIrU 0hD6Gf19yXcZPTitZCUJnxtWHq7B0CE4lneLA3I492crdA9TJrLIFRfZAwCo6Xg6DIpo 64oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696924202; x=1697529002; 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=xBzDwZo1XeWt7ItIGhOXUN3QV+md3tt2cNhSMxgmiwU=; b=rHKu4HUyD/rwzXUQF8+sxR94ypRxMy6Moz9xxbjV6A/CdKOqxYruxxAgMPdwZpHhKk Qsa6lIIs7SDuwe7YMfcfeddu0vxOmufTfl2eb5YnCqzPZNp37xaYpeSYQ7X210YbvMfa 7LLO/EkymCX1Lwd1fGldv3iRZ9T/3voEZDd6a2TOfB2eRBCv4RMxs07b4OUGsAS76UOX 192l+Ug8HEyalryoKgPYUwx85bsSEYM9dlI5IOS/SvLazuiSMiY3h5yIBOdqZCpnRRWN Y1EdvEpgvMdQv1h5lnhhvRVPZeNAyrthJyTJ9OYPfKgWzqZf9hI9NWFUux9VhEIuSxIt drTg== X-Gm-Message-State: AOJu0YzVJVLXtVEqcAEJhdZzu9gigm/IqJOBZysxCp6D/YcukqG7oUNN IRXTQfAvNynX778VLpzZ5Hgntf8tbbECf5Am7B8ZUA== X-Received: by 2002:a17:906:8455:b0:9ae:62ec:e897 with SMTP id e21-20020a170906845500b009ae62ece897mr15259871ejy.4.1696924201747; Tue, 10 Oct 2023 00:50:01 -0700 (PDT) Received: from m1x-phil.lan (aif79-h01-176-172-113-148.dsl.sta.abo.bbox.fr. [176.172.113.148]) by smtp.gmail.com with ESMTPSA id a14-20020a17090680ce00b0099cb1a2cab0sm8012503ejx.28.2023.10.10.00.50.00 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 10 Oct 2023 00:50:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Paolo Bonzini , qemu-ppc@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Laurent Vivier Subject: [PATCH 1/4] tests/libqtest: Introduce qtest_get_arch_bits() Date: Tue, 10 Oct 2023 09:49:49 +0200 Message-ID: <20231010074952.79165-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231010074952.79165-1-philmd@linaro.org> References: <20231010074952.79165-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=philmd@linaro.org; helo=mail-ej1-x62b.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 Add a method to return the architecture bits (currently 8/32/64). Signed-off-by: Philippe Mathieu-Daudé --- tests/qtest/libqtest.h | 8 ++++++++ tests/qtest/libqtest.c | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index e53e350e3a..1e1b42241d 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -654,6 +654,14 @@ bool qtest_big_endian(QTestState *s); */ const char *qtest_get_arch(void); +/** + * qtest_get_arch_bits: + * + * Returns: The architecture bits (a.k.a. word size) for the QEMU executable + * under test. + */ +unsigned qtest_get_arch_bits(void); + /** * qtest_has_accel: * @accel_name: Accelerator name to check for. diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index b1eba71ffe..a643a6309c 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -925,6 +925,27 @@ const char *qtest_get_arch(void) return end + 1; } +unsigned qtest_get_arch_bits(void) +{ + static const char *const arch64[] = { + "aarch64", "hppa", "x86_64", "loongarch64", "mips64", + "mips64el", "ppc64", "riscv64", "s390x", "sparc64", + }; + const char *arch = qtest_get_arch(); + + if (!strcmp(arch, "avr")) { + return 8; + } + + for (unsigned i = 0; i < ARRAY_SIZE(arch64); i++) { + if (!strcmp(arch, arch64[i])) { + return 64; + } + } + + return 32; +} + bool qtest_has_accel(const char *accel_name) { if (g_str_equal(accel_name, "tcg")) {