From patchwork Tue Nov 12 14:50:22 2019 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: 179200 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp7850304ocf; Tue, 12 Nov 2019 06:53:23 -0800 (PST) X-Google-Smtp-Source: APXvYqzz5yr7TTPObp0Kw2wDIsEPuVIM7E+lUIcll5/FukZrGMwzg2uB26SIV2H7X7LvSY+wCabk X-Received: by 2002:a05:620a:158b:: with SMTP id d11mr5939040qkk.452.1573570403065; Tue, 12 Nov 2019 06:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573570403; cv=none; d=google.com; s=arc-20160816; b=oWSXzH4AebNgCDJFTCu4yW+mYagoDBqxiILL8mr1tpgTh2wlAd3ze/Qtb1xJBWdtp8 mCqCmENPqRKfa8nQUnJDrtIN8eyewPu/64/e8qrjpA5axsie4qyTIbte4fbqDGkR0Pl2 N6iKbUMHLzfHn71az/OMdbzbe52ncnnUeZqEnqhdUPSv5MPq9I4uE90hIKtohGnNPXNP /IFTAGNamoLLy9Ii3BqjenGG5xDe4ewOryr4UhA9Wt9MZUFXw7SENc/s6c171bDeVBjn KgBlZyh7Z4+HHV77TMDitDflmf953eEeR55rqypj/2x0hCsKKVecCL9VBpx+/tiBXVe6 vZFg== 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=SGYCyiXxj6y3DiaxBTG3xzzW6T9viHeKAsigKYTsu2c=; b=0m7B+HvWyWhP6qWYZg8u7Om/4b+N1LA4y1phVobvHsEn5Ql1Qwe3cQTK+TCe1AyHdr Nebzxl4YvWO/GGTkqUTkZYIv1MjMp4i3e/96rc4G0PgHFQOK1FFgJ7nvUrPCZB+ZFGy+ clQtq9gcfH2xssd2bril6IYkRRpWVkjbKxTBv1rnBcebXHWzb18teCCXFdPwKI2b6Mia auS65a/O13Xz9rOmXXHaISt9k4pYKGdkm9zw2dkQI5aiDtBF096TEjEeLV+o5XNZ43HH hlCh/76PezjQ1f+A4tANRR8vyjtcom5rpADLlqrHAlAlAkWj8EYH43ZtzBwl5teMfnoz U/Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=By6FVuPA; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y19si5577130qka.120.2019.11.12.06.53.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Nov 2019 06:53:23 -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=fail header.i=@linaro.org header.s=google header.b=By6FVuPA; 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=linaro.org Received: from localhost ([::1]:35904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUXXm-0006dJ-9k for patch@linaro.org; Tue, 12 Nov 2019 09:53:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59688) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUXV5-0003P4-NN for qemu-devel@nongnu.org; Tue, 12 Nov 2019 09:50:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUXV4-00033l-O2 for qemu-devel@nongnu.org; Tue, 12 Nov 2019 09:50:35 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:38033) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUXV4-00033H-Hr for qemu-devel@nongnu.org; Tue, 12 Nov 2019 09:50:34 -0500 Received: by mail-wm1-x333.google.com with SMTP id z19so3253715wmk.3 for ; Tue, 12 Nov 2019 06:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SGYCyiXxj6y3DiaxBTG3xzzW6T9viHeKAsigKYTsu2c=; b=By6FVuPAO3hW+33sD4y/FG/PozqoAeSCi2REuBa0rN+OhK2Aft9JA9EaxNpeAx9DHF q8RmGMD6BATwI80V56nvsOyTSlyTmW0WoNekzf9kP1q3Y+Lh+JvJ6x6A9+dLHc3V9kzO uj5NBC1P2gE3kgNHrwmqfRQS77jzCZYmprt5MXt2risz0SohRlxyyO5/wRV7yi38MuUW OwQhynYrZzFxbC5Guw5ewvU2beIvYSym0LBOYDLja/fh1BOlZqyI90JeAZzmgjlE3utw o8m6fCp6SUHfMg8M/f1wNb6VfPIYt2SCaQl+/CraeZ4e9kN0gX/7tKGVKLoYd5rLYv9r rl3w== 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=SGYCyiXxj6y3DiaxBTG3xzzW6T9viHeKAsigKYTsu2c=; b=mTJ+mWGyy9AjRUSHWvMDvbhAlv4aPuB46cyuS66txRhE9pzfJ6AxC1Rkt65NbzmghC JAFwYqykJEbWsQipfJCA67+afoFJoBlj2C0o0e+c7+oza2DZ2f0NxmEWi4r47/Bm8ial P+4LXrYfQD0z1emk86tE2b+A1+YwPDVpNagu9iLiUPUzW1Hy/9oWVT+znrY/1J6wnRcv y+9XZrA5bLdK9fo+SMw/a/Wv/qlt4J+CF+tze21D++KOqEEIOMQLNxlsquSl7YoqFNBE 6NcyRmFaIMObY/qDJwG4bW4U7WHJnPKjpCDRJEQttvBvKT6PcYm/V86HQ/0dcKQWmfbx xfFg== X-Gm-Message-State: APjAAAVWrN40xwRGpfFj2kkkK78Oj9FJbBZcT5zuO6nMbtlG0LFP97lG BiL3pEScm+deu0RnhYY3BpkW7A== X-Received: by 2002:a1c:810d:: with SMTP id c13mr4674846wmd.154.1573570233426; Tue, 12 Nov 2019 06:50:33 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 16sm3669610wmf.0.2019.11.12.06.50.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2019 06:50:30 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 385061FF8F; Tue, 12 Nov 2019 14:50:29 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 2/8] tests/vm: add console_consume helper Date: Tue, 12 Nov 2019 14:50:22 +0000 Message-Id: <20191112145028.26386-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191112145028.26386-1-alex.bennee@linaro.org> References: <20191112145028.26386-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::333 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: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann Helper function to read all console output. Signed-off-by: Gerd Hoffmann Message-Id: <20191031085306.28888-3-kraxel@redhat.com> Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé -- 2.20.1 diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 2929de23aa7..086bfb2c66d 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -242,6 +242,25 @@ class BaseVM(object): return False return True + def console_consume(self): + vm = self._guest + output = "" + vm.console_socket.setblocking(0) + while True: + try: + chars = vm.console_socket.recv(1) + except: + break + output += chars.decode("latin1") + if "\r" in output or "\n" in output: + lines = re.split("[\r\n]", output) + output = lines.pop() + if self.debug: + self.console_log("\n".join(lines)) + if self.debug: + self.console_log(output) + vm.console_socket.setblocking(1) + def console_send(self, command): vm = self._guest if self.debug: