Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC14FCEDDB1 for ; Thu, 10 Oct 2024 01:52:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 92F5089000; Thu, 10 Oct 2024 03:52:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="GbSYIi2h"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F07F88F2C; Thu, 10 Oct 2024 03:52:00 +0200 (CEST) Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F2E9788F2A for ; Thu, 10 Oct 2024 03:51:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd44.google.com with SMTP id ca18e2360f4ac-82ce603d8daso15569539f.0 for ; Wed, 09 Oct 2024 18:51:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728525116; x=1729129916; darn=lists.denx.de; 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=hEGPjS+y/Qg6y7lg6Pktas+2pPJQcCbyuxuButIfZnU=; b=GbSYIi2h64VAuhUUMLGskIGQzSXo/EV4ocSjE37iC8OTunHsgi7T4/OrvRFUwRdX4s BLVnmoqs80pE5y2HQywe2CdFTS6yVcCstgLxbO6AzR3hEEmZDeVgCSh4yl6b3wLTmS1I 7OmfmuCAJ8lS7B/OBu1Yzv7q50M7qbC2HYYlM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728525116; x=1729129916; 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=hEGPjS+y/Qg6y7lg6Pktas+2pPJQcCbyuxuButIfZnU=; b=AFQ19TqxNl4X62zWDRS75FJW+AtMN/M5EoUr9ytLXtVA09J7fSuG8R4WM8RtHTC+zn 5uNSTHGrVLd0Vz6vXshvDsNl/f9oApHRTl3niCGAHRozjKRKnpS+sZGNP7uUhQ3D/aaO hAC7B1MjMybDnfNIgevrYppqpCM1jdMYMWNYhTlgvAspcriHirU+OeIg81CFkQsjjpWB GHvd7s0abPK7s1+W5ISMceWx+udDx97+6Hy26GznA/k9SJFfmzu4Q9TGkK7j74EH0PIX NbgVzVUtvewBf4MwzBjgeuuC5e7ur3us1bXVI7zXeQz/PVfiWA3EHgs7IfNNxfaPUEzI I3PQ== X-Gm-Message-State: AOJu0YyAPat+NriNPoPtN1wyvBTFtjzapRpirtGamRVbQg7AkGEiOxoL 1U9dz8PAjk95OQHvv227C9xaz8DJQuynEKbAmGc2hioc2XCChdCyaf+fD6r8MFkrsg1rUri3Rl2 RrRMx X-Google-Smtp-Source: AGHT+IHAftiTwMA3yuOU8yX19zPGyPkYPfABPZm+LigAzhJrDmq7IYZWdeWRofQvov2X2I7MnDE+bQ== X-Received: by 2002:a05:6602:6424:b0:835:3957:4f7 with SMTP id ca18e2360f4ac-8353d5464d3mr504196639f.16.1728525116581; Wed, 09 Oct 2024 18:51:56 -0700 (PDT) Received: from chromium.org (c-107-2-138-191.hsd1.co.comcast.net. [107.2.138.191]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4dbadaa947fsm61870173.126.2024.10.09.18.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 18:51:56 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass Subject: [PATCH v7 06/11] test: Improve handling of sending commands Date: Wed, 9 Oct 2024 19:51:40 -0600 Message-Id: <20241010015145.1977999-7-sjg@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010015145.1977999-1-sjg@chromium.org> References: <20241010015145.1977999-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean We expect commands to be echoed and this should happen quite quickly, since U-Boot is sitting at the prompt waiting for a command. Reduce the timeout for this situation. Try to produce a more useful error message when something goes wrong. Also handle the case where the connection has gone away since the last command was issued. Signed-off-by: Simon Glass --- (no changes since v1) test/py/u_boot_console_base.py | 35 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index 573d76dd832..42c81b2d13f 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -31,6 +31,7 @@ PAT_RE = 1 # Timeout before expecting the console to be ready (in milliseconds) TIMEOUT_MS = 30000 # Standard timeout +TIMEOUT_CMD_MS = 10000 # Command-echo timeout # Timeout for board preparation in lab mode. This needs to be enough to build # U-Boot, write it to the board and then boot the board. Since this process is @@ -300,22 +301,28 @@ class ConsoleBase(object): try: self.at_prompt = False + if not self.p: + raise BootFail( + f"Lab failure: Connection lost when sending command '{cmd}'") + if send_nl: cmd += '\n' - while cmd: - # Limit max outstanding data, so UART FIFOs don't overflow - chunk = cmd[:self.max_fifo_fill] - cmd = cmd[self.max_fifo_fill:] - self.p.send(chunk) - if not wait_for_echo: - continue - chunk = re.escape(chunk) - chunk = chunk.replace('\\\n', '[\r\n]') - m = self.p.expect([chunk] + self.bad_patterns) - if m != 0: - self.at_prompt = False - raise BootFail('Bad pattern found on console: ' + - self.bad_pattern_ids[m - 1]) + rem = cmd # Remaining to be sent + with self.temporary_timeout(TIMEOUT_CMD_MS): + while rem: + # Limit max outstanding data, so UART FIFOs don't overflow + chunk = rem[:self.max_fifo_fill] + rem = rem[self.max_fifo_fill:] + self.p.send(chunk) + if not wait_for_echo: + continue + chunk = re.escape(chunk) + chunk = chunk.replace('\\\n', '[\r\n]') + m = self.p.expect([chunk] + self.bad_patterns) + if m != 0: + self.at_prompt = False + raise BootFail(f"Failed to get echo on console (cmd '{cmd}':rem '{rem}'): " + + self.bad_pattern_ids[m - 1]) if not wait_for_prompt: return if wait_for_reboot: -- 2.34.1