From patchwork Thu Nov 21 16:57:41 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: 844712 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:8b:b0:382:43a8:7b94 with SMTP id m11csp2393287wrx; Thu, 21 Nov 2024 09:13:55 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWDJCTqBZFEq2HzU9VTHdAlWPwW1IXr/LxoCPaCxX3GxhXBHW1uy/t61Am9f6le765Qvzn9tQ==@linaro.org X-Google-Smtp-Source: AGHT+IH6EX7237n44Oj78jlKgUTfhsdw7fLn9GcuCaTLc9OdhE0snNn9yVkZvTX1TsT2wf2pG/7i X-Received: by 2002:a5d:5985:0:b0:37d:4d3f:51e6 with SMTP id ffacd0b85a97d-38254ae5bb8mr7035761f8f.14.1732209235449; Thu, 21 Nov 2024 09:13:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732209235; cv=none; d=google.com; s=arc-20240605; b=G8N5R4fg2OA0sImcfHfqXB7YmF7Ra4Ajjv7gRGyOxQYvxl30+VBciq82+euonY11CU e7HMgpbO8SA5WT+ixeGfxDgZ0nYcJWavlJYMNCn2UV1gORTbX8FpIqk/nWDpd6i7RBG/ S259zRbZf8RUFK5Bng4mpivC6BoCY/GZfFBR0Uz/Qbhwqvto75EQdasmCKcxTO9eWQff ipWUrc06u2ZZSVXS0nF/8zLquJg++MbtQTcy8AglKFo5JLBevjiz06SGqYMwnPg5HVjc fhWfdc0PN72bAA/UPzm0ek+zp3vQKoQsaCAVExSxOimVrGgtf32EtKhk0pH5+hevNVPg YR+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=nvB0S+SuI5gT8c9EFIym95gTJAjNroOOQ4+Yq08R388=; fh=kD8gGl3e3ra3edo6fHRuv01yNgMQ5IRvVhUmLIIG5FM=; b=cqXNf2usO7Q1ubtEgfAK50MVZUfG9PnDet4J2slZt43C/BaB2a34l1lj4uhl+Ao+Yv EWDtgQKDRHSSOeoMVOabkYB3nM2Wpvid4jYWZKhsukR6sE2LTtehuB/uy1e59Wkuw4ZD m9dX8q7W1rQTnPA4I5NF22TK+bMNozzM5FDWP088toi0Kc7TlZ03ibda0DkEcv+WtHIS wCmpyg3jZ/wG51JnN5aTI3L3wLMI8ocfcF7IV2InzLG2FZGO7wRjT8rRvQ1xNsXPgLcz Jr8H/zQNTmsuwEdF8/7TR4c6Qw1CvsRUtO2fTF8LEGKAJYOpZtT2lEnm/Gvv5GcIE+hb BZjA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xo9Kdtkt; 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 ffacd0b85a97d-3825fd70a66si29011f8f.652.2024.11.21.09.13.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Nov 2024 09:13:55 -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=xo9Kdtkt; 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 1tEAWP-0005YU-EV; Thu, 21 Nov 2024 11:59:13 -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 1tEAVs-0004qq-2S for qemu-devel@nongnu.org; Thu, 21 Nov 2024 11:58:41 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tEAVX-00085S-8H for qemu-devel@nongnu.org; Thu, 21 Nov 2024 11:58:39 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-38231f84dccso794580f8f.1 for ; Thu, 21 Nov 2024 08:58:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732208297; x=1732813097; 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=nvB0S+SuI5gT8c9EFIym95gTJAjNroOOQ4+Yq08R388=; b=xo9Kdtktd9NXpw6xO/IyMs45YoVfmkzxkTq3+0KmHFOV62FEJ/XaWtM02xCvNFFBTL 8Kdt7rxrW2UsfCUzJ7uUvAcAXJkAc9YKlToGVXooqnTZlVzc2hefYpNrDa3gUKU3pT7N BGUNoaSsRuUQ/ONp4t6fCNlvtWSHoECFegrScaaZDxNhqRTdZKvz3I+6B0Kf7fwXbnte iE3sg4OfVDAMOP0rpchUwuD1LbZzSY+mXaFagJz1mLZYtP9/Dv1/eEJdMlCrgBi9u3mI ox79p4phw9Is1OLsJEx48sOu8IP9bB6PBjmtZtnbDRmRaNiEyRVgvd1aFzdSu52uZuiy Iysw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732208297; x=1732813097; 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=nvB0S+SuI5gT8c9EFIym95gTJAjNroOOQ4+Yq08R388=; b=YeDEQ7GiOcCz7pHqnxNS4OJEZsJ5JpdhKRrrcyIeAH9KwPceANZ+/VOA/b+UheIoJm rr3sM+ZbSd6a/FutDuqEAhYg0GOoVKYOILWs418uMd8YXKG8VBJQ1RYUAkP0blq3tq4a C2dwUVywzLelw7VTNFULj9RyQfC0L64nffFrjzwZZxHK03zvDx6e6H4mo/Yp4vDUPHVn 5L0GoNoKLrBkkg6Nt9Vi5YkcEt8rkrTbiIORBs8smoUaVXdWee2GeHNoO/AaBHYhLIji C/rKLGLqA1Os4BsnddU2HVK4HmGnVxAm0uCY/ViA+Bfu9UouRbyhnFozKmvIQCAIg5yT my+w== X-Gm-Message-State: AOJu0YzeN9vli/gPwLly2Py1v188Hf21UPALuQueK6xPHZYhs3th6IvB sacZ9e2jHD37z83GbbFya16xQUWf1bvkTi+xyPTWqWq0e9Ig3a/QKtuOpxBcZrI= X-Gm-Gg: ASbGncvnJd/sjJRyCrR8twz6mF2mdVMhbMaQBKWrWVJRfJGiiqDREMS0w/9DZyJsUFI wO/2flsG68KMwMUV8u4go5jZPl0Dj8I+PM121PsV1gmuxFdTwoWz5iFZsoXk8wl9Vm0sKif7w2f umKkq0RRAXxOJmNQgJFx44yvcmXXhs5d96CtxZDV1L5S7k0Le/nnaL0eEYAVMemvsgdiNA9cZ2c 86eMeWI7U8yy4XiDGcXQua0frCwOs6HkKhcKFhcdeHyRxMX X-Received: by 2002:a05:6000:178e:b0:382:424:94fe with SMTP id ffacd0b85a97d-38254b15734mr6840684f8f.36.1732208297548; Thu, 21 Nov 2024 08:58:17 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fbedfccsm14917f8f.101.2024.11.21.08.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2024 08:58:14 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id B718F603D3; Thu, 21 Nov 2024 16:58:07 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , "Michael S. Tsirkin" , Daniel Henrique Barboza , Pierrick Bouvier , Harsh Prateek Bora , Marcel Apfelbaum , Jiaxun Yang , Halil Pasic , Christian Borntraeger , qemu-ppc@nongnu.org, Daniel Henrique Barboza , Alexandre Iooss , qemu-riscv@nongnu.org, Thomas Huth , Bernhard Beschow , Thomas Huth , Eric Farman , Bin Meng , qemu-s390x@nongnu.org, Niek Linnenbank , qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , John Snow , Wainer dos Santos Moschetta , Cleber Rosa , qemu-rust@nongnu.org, Nicholas Piggin , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Palmer Dabbelt , Markus Armbruster , Weiwei Li , Mahmoud Mandour , Mark Cave-Ayland , Liu Zhiwei , Aurelien Jarno , Ani Sinha , Alistair Francis Subject: [PATCH 14/39] tests/functional: require non-NULL success_message for console wait Date: Thu, 21 Nov 2024 16:57:41 +0000 Message-Id: <20241121165806.476008-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241121165806.476008-1-alex.bennee@linaro.org> References: <20241121165806.476008-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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 From: Daniel P. Berrangé When waiting for expected output, the 'success_message' is a mandatory parameter, with 'failure_message' defaulting to None. The code has logic which indicates it was trying to cope with 'success_message' being None and 'failure_message' being non-None but it does not appear able to actually do anything useful. The check for 'success_message is None' will break out of the loop before any check for 'failure_message' has been performed. IOW, for practcal purposes 'success_message' must be non-None unless 'send_string' is set. Assert this expectation and simplify the loop logic. Signed-off-by: Daniel P. Berrangé Message-Id: <20241121154218.1423005-15-berrange@redhat.com> Signed-off-by: Alex Bennée Reviewed-by: Thomas Huth --- tests/functional/qemu_test/cmd.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/functional/qemu_test/cmd.py b/tests/functional/qemu_test/cmd.py index 98722a9cf6..f6c4e4dda1 100644 --- a/tests/functional/qemu_test/cmd.py +++ b/tests/functional/qemu_test/cmd.py @@ -81,6 +81,8 @@ def is_readable_executable_file(path): def _console_interaction(test, success_message, failure_message, send_string, keep_sending=False, vm=None): assert not keep_sending or send_string + assert success_message or send_string + if vm is None: vm = test.vm console = vm.console_file @@ -95,7 +97,7 @@ def _console_interaction(test, success_message, failure_message, send_string = None # send only once # Only consume console output if waiting for something - if success_message is None and failure_message is None: + if success_message is None: if send_string is None: break continue @@ -107,7 +109,7 @@ def _console_interaction(test, success_message, failure_message, if not msg: continue console_logger.debug(msg) - if success_message is None or success_message in msg: + if success_message in msg: break if failure_message and failure_message in msg: console.close() @@ -138,6 +140,7 @@ def interrupt_interactive_console_until_pattern(test, success_message, :param interrupt_string: a string to send to the console before trying to read a new line """ + assert success_message _console_interaction(test, success_message, failure_message, interrupt_string, True) @@ -152,6 +155,7 @@ def wait_for_console_pattern(test, success_message, failure_message=None, :param success_message: if this message appears, test succeeds :param failure_message: if this message appears, test fails """ + assert success_message _console_interaction(test, success_message, failure_message, None, vm=vm) def exec_command(test, command): @@ -180,6 +184,7 @@ def exec_command_and_wait_for_pattern(test, command, :param success_message: if this message appears, test succeeds :param failure_message: if this message appears, test fails """ + assert success_message _console_interaction(test, success_message, failure_message, command + '\r') def get_qemu_img(test):