From patchwork Sun May 31 16:38:41 2020 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: 187343 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp2340791ilb; Sun, 31 May 2020 09:49:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeZogtuJ1OK216E2WjrMy4UboI7ivAhRYIPFbDr4RD7ezcJz8d/eXxEvUxip9X559JD0Pp X-Received: by 2002:a05:6902:102d:: with SMTP id x13mr9064920ybt.112.1590943771125; Sun, 31 May 2020 09:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590943771; cv=none; d=google.com; s=arc-20160816; b=etym7DtMXBWKWdv7Td00j9p0YCpg/E7z/jNGqtNJYtTeCOcXWEo35DtnCzJEZ+lzLx lcjDFzggh0HTeF8V3WEGnr/YYyhmtlcRnh1ZrVAMqdtDn2Xd8i+aKMuqbFpDnt1g6UAc 3W6vsxiVC+8D4afW+jn8ZqTT6ybQvKdkLR05EuZa36la2J4UhFKCgVpCjmtFBBVYxb7Y Xe15jNV6kibu+QAGZ6hU9fI5ZwFgBHMun9EnE3qP2DgT4iL8Do7pTjj6mHd2SZLCJBBo /GblFueZyXobzjCwiQV4VCOjOQFzn2t7NhzxMY5wUN9DcayBwrc15K9iWHYaFyjFJLNf MLHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=NeYhFc6juZkPrqvPgAt2uIQTGjMzeewfSJodiqWwwkw=; b=jeeifFjF5z406eRPc0drgeeQwnVC7ZTsRhor639y2BQJ3zsuA0G78nFuFRxHJVxAl5 IQ+uEOSImRcXG6gZmu6Vi0/Ce/GBIP7HPxkUML3C8RBBC5SOd0nEJ6pFu22IP3BY2hOD 99eQS12Xkw7XqgVxy0VfYCD4dl9utxKx55SbC6R0UvrLWzsWU3HlrOpS8IDhhejnhvxZ gHXmh4A1XeSXGRsuivFn6EtTvmRPGGFmfqEVkhlXdp4Hf5UESLneyTmVKu20QRg/V2oQ FN1et9kX3q6pxlpACbHc4EnHtPECZeeFGPa366Bp/TnQnlPx4e7otCayeDzDAXveuTR2 STYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=M6krOIEy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r22si13114529ybc.110.2020.05.31.09.49.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 31 May 2020 09:49:31 -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=fail header.i=@redhat.com header.s=mimecast20190719 header.b=M6krOIEy; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:55674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfR9O-0000La-KM for patch@linaro.org; Sun, 31 May 2020 12:49:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfR0m-0003fY-AT for qemu-devel@nongnu.org; Sun, 31 May 2020 12:40:36 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:47003 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jfR0k-00075g-Vv for qemu-devel@nongnu.org; Sun, 31 May 2020 12:40:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590943234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NeYhFc6juZkPrqvPgAt2uIQTGjMzeewfSJodiqWwwkw=; b=M6krOIEyp+NONDO30S7ZKr5lEfDMnujgBDcVgt3KSk5kdovvN84KQtLMPQd85iiCCyHsP1 nLT9sn0+xUm4f01nvBdcwBQ61pNKpsmxX7UI4u9zszOVGpLZuHR/Ex1XSgV+FyxlWrHFL0 yBKjjaqSFmWm54gTEly8w+vMClwWadM= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-GlhV1XoaO8aiRkjSiqQ3jQ-1; Sun, 31 May 2020 12:40:32 -0400 X-MC-Unique: GlhV1XoaO8aiRkjSiqQ3jQ-1 Received: by mail-wr1-f72.google.com with SMTP id l18so3650913wrm.0 for ; Sun, 31 May 2020 09:40:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NeYhFc6juZkPrqvPgAt2uIQTGjMzeewfSJodiqWwwkw=; b=pg6Q5/BJlc6i/iURgYsDx9L28Lu/PW0YRE/gA07kw2ShcK+97YnQ90tWStXjusw3en 6EaRUp4LNRgr3RM9LfPPus+XCnlMpBjLP4L0mE3O+Hj0RRF3rqOZZmSzvNnOGga326yJ UYq8tIsDpINTEl01a5KXi9FRBRQf5Ah3F5H7EZpcWsjOIP/zpVPeASLlnkt3WpmswyOk kkS8oTM6HtGbpX0HJ0/audRX3D0xeUa9rYwZzvHAz/UuRJ30dFjRi75kf2SAHrQArj1I PQH8HgS5qMAKa8yqwNc4EyNuGJurNrPkfo792/jwI51RxWs+ZfNXpsyc9f0EU3BnMxuZ JYFQ== X-Gm-Message-State: AOAM533RqkghEYKWLWHtIDSYoWogTg9l95IVkBV3rYRxQDrUR+VMrRD/ Hq5xTZIgJPPq3Dl1ZNSM26gQfLD3mt/qrqDeizjLk2QaGTv4JgkcpAFsP6TfBOowACc6/GBnQ8b t5qv0zV73zVJhgW0= X-Received: by 2002:a5d:628c:: with SMTP id k12mr17814523wru.211.1590943231326; Sun, 31 May 2020 09:40:31 -0700 (PDT) X-Received: by 2002:a5d:628c:: with SMTP id k12mr17814494wru.211.1590943231095; Sun, 31 May 2020 09:40:31 -0700 (PDT) Received: from localhost.localdomain (43.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.43]) by smtp.gmail.com with ESMTPSA id q4sm9026212wma.47.2020.05.31.09.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 May 2020 09:40:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 20/25] tests/vm: allow wait_ssh() to specify command Date: Sun, 31 May 2020 18:38:41 +0200 Message-Id: <20200531163846.25363-21-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200531163846.25363-1-philmd@redhat.com> References: <20200531163846.25363-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/31 12:39:08 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , Robert Foley , Eduardo Habkost , kvm@vger.kernel.org, Peter Puhov , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Marcelo Tosatti , Markus Armbruster , Max Reitz , Stefan Hajnoczi , Cleber Rosa , Paolo Bonzini , qemu-block@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Robert Foley This allows for waiting for completion of arbitrary commands. Signed-off-by: Robert Foley Reviewed-by: Peter Puhov Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-Id: <20200529203458.1038-7-robert.foley@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- tests/vm/basevm.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.21.3 diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 5a3ce42281..a80b616a08 100644 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -320,24 +320,24 @@ def console_sshd_config(self, prompt): def print_step(self, text): sys.stderr.write("### %s ...\n" % text) - def wait_ssh(self, wait_root=False, seconds=300): + def wait_ssh(self, wait_root=False, seconds=300, cmd="exit 0"): # Allow more time for VM to boot under TCG. if not kvm_available(self.arch): seconds *= self.tcg_ssh_timeout_multiplier starttime = datetime.datetime.now() endtime = starttime + datetime.timedelta(seconds=seconds) - guest_up = False + cmd_success = False while datetime.datetime.now() < endtime: - if wait_root and self.ssh_root("exit 0") == 0: - guest_up = True + if wait_root and self.ssh_root(cmd) == 0: + cmd_success = True break - elif self.ssh("exit 0") == 0: - guest_up = True + elif self.ssh(cmd) == 0: + cmd_success = True break seconds = (endtime - datetime.datetime.now()).total_seconds() logging.debug("%ds before timeout", seconds) time.sleep(1) - if not guest_up: + if not cmd_success: raise Exception("Timeout while waiting for guest ssh") def shutdown(self):