From nobody Mon Nov 25 12:36:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1715600172; cv=none; d=zohomail.com; s=zohoarc; b=GVyVJ5HS/pPga3qq1lQPqhfvHplLYQZ8POJ76Mino27oEIS0lkPvPT4W0MvacCpBy68R3VIH96SYJ4toahUGP7MtK7FNcLsMnydZxdpH34mnObNidgtWCx/5GRQiTRM2rI08DWNC8RH4aPKg9IT879GhssH+3L/XV+zkxm8nOPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715600172; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=FwAfCWJvmUAGzEmOykyRdNZT3QAGaq1DLOi5VTUI8GE=; b=Vz5zp42xg9pY/ORVYrxrC0mMyXvuS86iEPPvvgrIVC8tOMvQzm7lVHZy6ZDbEEvkeAwz7JLVeHKR7Y3s1XYH7GoERwmSOHpgXIqUdOt9kw39Xdyi7/r5cjtxoaWEYU2fCqP9YS3agZP/bKau8uEjuvk8MkIyGeT8Im82DM/bPY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715600172841135.838330250529; Mon, 13 May 2024 04:36:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s6Ty3-0005U6-Ip; Mon, 13 May 2024 07:35:43 -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 1s6Txp-0005JQ-Cx for qemu-devel@nongnu.org; Mon, 13 May 2024 07:35:30 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6Txk-0001RE-CL for qemu-devel@nongnu.org; Mon, 13 May 2024 07:35:29 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-51f1bf83f06so5162319e87.1 for ; Mon, 13 May 2024 04:35:23 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502baad0absm10869226f8f.69.2024.05.13.04.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 04:35:14 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 77DE85FA17; Mon, 13 May 2024 12:35:13 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715600121; x=1716204921; 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=FwAfCWJvmUAGzEmOykyRdNZT3QAGaq1DLOi5VTUI8GE=; b=m5TcLArgU2T4dvBGN9dtSV1kQK7WjzjpLuWMN83RW5WOkYqvX17qwYkjn/On3+8ZH3 0IPnJghfzIqbayOupD/ZOTWUKn1r/7R26O7SqodM/PWw6lfjwp85CjpACW2zR5SDTykx fGBUy3WkhZVi1liD9tr78h116LHeDBhBv8Jt1WjEaBjdN/tTlH7QwskBXZtND3hcHrbJ YENX3nSGhl8md12wvaGrxmJL6A4nzdXg21KSW4/m1pJCplzzar7BJdQ65likDri1nFEA Ho/f85BTnmioWXmbeSWLe+c+1vhNI+QHxJB+/SHd1Rx3+tCLdpR8sMThgioHLOJyFuuR VSgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715600121; x=1716204921; 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=FwAfCWJvmUAGzEmOykyRdNZT3QAGaq1DLOi5VTUI8GE=; b=F7pfIZRPPnMf2DtpSj+fSZ1yjDfwkq0dWIzAyiGnPuUXnoRDiNtbQax4EK00o7YOUe nsK/XcfU3WlohX9db5v2lhDu7ZSahPahDtx1IyAxbTXDc9Fnx+Zu6wir6i9ku+6qmJVT cEDKKGcTC/Echku0d8rlvjS9T6cOpNWgwnVA2OY4I0gvpExHu0G8862l+r2+kq6sGdlU 0aJMAlIOiOQSb93BrA/fn/BKMDO3wyQCwDbeGOSYjuFPP6I855HNAARzwHGY3WyE9f9g CUd1FgXVnw6F2nYS8zd3HlAT+7Owrxfl9kzjfyMy4iagcfotw1dw+DhvlntBR3Do6z25 lRVA== X-Gm-Message-State: AOJu0YxrtsqJueaDDuRGwGKVgL+0oszc/wkaXH2+bMpEAmzp56Qc9hxL 8XlBRd2scpUuog8tajqFJOIl9XoufDAICasheFY1sJ3LJWWa2D6+9uWzG1XGo1+55shzMVd6njg Y X-Google-Smtp-Source: AGHT+IG1G1Jwhq3akS3T006hNy2cNaNyrvZX978MOX935dxLmtmGazSb0zO4fIiXGNS0dtlLqzhKRg== X-Received: by 2002:a05:6512:158e:b0:51d:68fb:5d73 with SMTP id 2adb3069b0e04-5220fb768fcmr8585591e87.8.1715600119547; Mon, 13 May 2024 04:35:19 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: Peter Maydell Cc: qemu-devel@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [Semihosting Tests PATCH 3/3] add SYS_GET_CMDLINE test Date: Mon, 13 May 2024 12:35:13 +0100 Message-Id: <20240513113513.640007-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240513113513.640007-1-alex.bennee@linaro.org> References: <20240513113513.640007-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x134.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, T_SPF_TEMPERROR=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1715600174088100001 We actually had the stubs to implement this. The main pain is getting the binary name into the program so we can validate the result. Signed-off-by: Alex Benn=C3=A9e --- Makefile | 22 +++++++++++----------- usertest.c | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 59fd831..f77665f 100644 --- a/Makefile +++ b/Makefile @@ -85,37 +85,37 @@ systest-srcs =3D start.S string.c $(usertest-srcs) microbit-systest-srcs =3D start-microbit.S string.c $(usertest-srcs) =20 usertest-a32: $(usertest-srcs) - $(A32GCC) --static -o $@ $^ + $(A32GCC) -DBINARY_NAME=3D"\"$@\"" --static -o $@ $^ =20 usertest-t32: $(usertest-srcs) - $(T32GCC) --static -o $@ $^ + $(T32GCC) -DBINARY_NAME=3D"\"$@\"" --static -o $@ $^ =20 usertest-a32-hlt: $(usertest-srcs) - $(A32GCC) -DUSE_HLT --static -o $@ $^ + $(A32GCC) -DBINARY_NAME=3D"\"$@\"" -DUSE_HLT --static -o $@ $^ =20 usertest-t32-hlt: $(usertest-srcs) - $(T32GCC) -DUSE_HLT --static -o $@ $^ + $(T32GCC) -DBINARY_NAME=3D"\"$@\"" -DUSE_HLT --static -o $@ $^ =20 usertest-a64: $(usertest-srcs) - $(A64GCC) --static -o $@ $^ + $(A64GCC) -DBINARY_NAME=3D"\"$@\"" --static -o $@ $^ =20 systest-a32.axf: $(systest-srcs) - $(A32GCC) -o $@ $^ $(A32LINKOPTS) + $(A32GCC) -DBINARY_NAME=3D"\"$@\"" -o $@ $^ $(A32LINKOPTS) =20 systest-t32.axf: $(systest-srcs) - $(T32GCC) -o $@ $^ $(A32LINKOPTS) + $(T32GCC) -DBINARY_NAME=3D"\"$@\"" -o $@ $^ $(A32LINKOPTS) =20 systest-a32-hlt.axf: $(systest-srcs) - $(A32GCC) -DUSE_HLT -o $@ $^ $(A32LINKOPTS) + $(A32GCC) -DBINARY_NAME=3D"\"$@\"" -DUSE_HLT -o $@ $^ $(A32LINKOPTS) =20 systest-t32-hlt.axf: $(systest-srcs) - $(T32GCC) -DUSE_HLT -o $@ $^ $(A32LINKOPTS) + $(T32GCC) -DBINARY_NAME=3D"\"$@\"" -DUSE_HLT -o $@ $^ $(A32LINKOPTS) =20 systest-t32-bkpt.axf: $(microbit-systest-srcs) - $(V7MGCC) -DUSE_BKPT -o $@ $^ $(AV7MLINKOPTS) + $(V7MGCC) -DBINARY_NAME=3D"\"$@\"" -DUSE_BKPT -o $@ $^ $(AV7MLINKOPTS) =20 systest-a64.axf: $(systest-srcs) - $(A64GCC) -nostdlib -o $@ $^ $(A64LINKOPTS) + $(A64GCC) -DBINARY_NAME=3D"\"$@\"" -nostdlib -o $@ $^ $(A64LINKOPTS) =20 run-usertest-a32: usertest-a32 $(QEMU_ARM) usertest-a32 diff --git a/usertest.c b/usertest.c index 5df95f3..268a9d9 100644 --- a/usertest.c +++ b/usertest.c @@ -315,6 +315,26 @@ static int test_feature_detect(void) return 0; } =20 +static int test_cmdline(void) +{ + char cmdline[256]; + int actual; + const char *s, *c; + + if (semi_get_cmdline(&cmdline[0], sizeof(cmdline), &actual)) { + semi_write0("FAIL could recover command line\n"); + return 1; + } + + if (strcmp(&cmdline[0], BINARY_NAME) !=3D 0) { + semi_write0("FAIL unexpected command line:"); + semi_write0(&cmdline[0]); + } + + semi_write0("PASS command line test\n"); + return 0; +} + int main(void) { void *bufp; @@ -366,6 +386,10 @@ int main(void) return 1; } =20 + if (test_cmdline()) { + return 1; + } + semi_write0("ALL TESTS PASSED\n"); =20 /* If we have EXIT_EXTENDED then use it */ --=20 2.39.2