From patchwork Wed Dec 13 21:35:56 2017 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: 10110959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB596602B3 for ; Wed, 13 Dec 2017 21:42:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCACD28FB8 for ; Wed, 13 Dec 2017 21:42:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFC1B28FE3; Wed, 13 Dec 2017 21:42:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB0A228FB8 for ; Wed, 13 Dec 2017 21:42:28 +0000 (UTC) Received: from localhost ([::1]:37857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePEnL-0005JZ-KA for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Dec 2017 16:42:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePEha-0000wE-Kh for qemu-devel@nongnu.org; Wed, 13 Dec 2017 16:36:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePEhZ-0002A4-Lx for qemu-devel@nongnu.org; Wed, 13 Dec 2017 16:36:30 -0500 Received: from mail-qt0-x242.google.com ([2607:f8b0:400d:c0d::242]:36838) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePEhZ-00029c-Hp for qemu-devel@nongnu.org; Wed, 13 Dec 2017 16:36:29 -0500 Received: by mail-qt0-x242.google.com with SMTP id a16so5587469qtj.3 for ; Wed, 13 Dec 2017 13:36:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xlnNPUzEVA1lpnK1rmKktcHZctoU+0YTz97tIsFeJvQ=; b=Li7VWMNSXd+Bw5GixxYshvycEXkxW/tynMqQTpUKmTONzZFhxd4vfgIB/bWHd6/HZ1 mE7zGUQGzbJzeBv+dKUlP4SjlmdqJ52liXa5IAcGENVtvEWANX+VrvwN+KWwLV2e1wbM KO/khvX2gFpQNgI3HBdpt73je8jZUvGOgIiXOSA8jesfkU/r0a4UJ2H14TpPQMg2yig/ 3oNJlpZ1QQLxPKTt+/9Slil6IwvNGPJlnUsPhWib2FJj4qS1kFPSxxBtyoda/UTHdzDk WhVoouebEURUtj2J9QYCt6C2OTu8AEgRRG1BhcIgVhnLLrwk4EkRBKBC8voogqlCEr+m 12Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xlnNPUzEVA1lpnK1rmKktcHZctoU+0YTz97tIsFeJvQ=; b=RIVD42taLJNQdL5D/beZaQ4wHU93aZ0EESL/Wh81rHlTaWRntPG9gk6m9tmyynM+ai 1dTc1djgkpUpaLQpslRbsNNUitrmO9GjuheLwQM1pSE0i8bRCXEGNOxMT//puCLa8EFy EV51QjjDr8Q4wdDWL8NqeQjhC+gact0GHWfdZNkHCdJ8R3aABDR/zXZD9e74VVlcHxmF dd8f/4s7IglxzA0LJ5e7CIgBXbcBU7eZ1x8O2ZqjO6A6oRMca2OQs9KWXQhm2lfYVuzF JIIp90VDsJ+iLDijlPfMhbT9cps28ranNtEMVPYPT4L+pfYYq5OUzMOACfG75rOiIO4j LaIw== X-Gm-Message-State: AKGB3mIdLvcZGqUBFZOJhwlftlFBuPZC+S6OaE7wjes8BiI2K6RPdyji 0HmcJNgCnliepprRcuFd224= X-Google-Smtp-Source: ACJfBot32VNwP88b51DvFIUCUDaOnd4H+sXTqRWVTsKvViO01ZCrhz28K8Z+v/megrWUnKphGOj+vw== X-Received: by 10.200.58.67 with SMTP id w61mr12944060qte.296.1513200989007; Wed, 13 Dec 2017 13:36:29 -0800 (PST) Received: from x1.local ([138.117.48.211]) by smtp.gmail.com with ESMTPSA id x23sm1617150qkb.4.2017.12.13.13.36.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 13:36:28 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Alistair Francis , "Edgar E . Iglesias" , Cleber Rosa , Kevin Wolf , Max Reitz , John Snow , Eduardo Habkost , =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , "Daniel P . Berrange" , Eric Blake , Stefan Hajnoczi , Fam Zheng Date: Wed, 13 Dec 2017 18:35:56 -0300 Message-Id: <20171213213557.26561-6-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171213213557.26561-1-f4bug@amsat.org> References: <20171213213557.26561-1-f4bug@amsat.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::242 Subject: [Qemu-devel] [PATCH 5/6] qtest.py: add a simple main() which calls unittest.main() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We can now write complex qtests with a high-level language (Python). (partly copied from iotests::main) Signed-off-by: Philippe Mathieu-Daudé --- scripts/qtest.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/scripts/qtest.py b/scripts/qtest.py index 429eb67c2a..581451836c 100644 --- a/scripts/qtest.py +++ b/scripts/qtest.py @@ -226,3 +226,36 @@ def verify_machine(supported_machines): if True not in [x in machines for x in supported_machines]: notrun('not machine suitable for this test') + +def main(supported_oses=['linux'], supported_machines=['any']): + '''Run tests''' + + global debug + + verify_platform(supported_oses) + verify_machine(supported_machines) + + verbosity = 0 + level = logging.WARN + if '-d' in sys.argv: + verbosity = 2 + level = logging.DEBUG + if '-v' in sys.argv: + verbosity = 1 + level = logging.INFO + if '-q' in sys.argv: + level = logging.NOTSET + + import StringIO + output = sys.stdout if verbosity else StringIO.StringIO() + + logging.basicConfig(level=level) + + class MyTestRunner(unittest.TextTestRunner): + def __init__(self, stream=output, descriptions=True, + verbosity=verbosity): + unittest.TextTestRunner.__init__(self, stream, descriptions, + verbosity) + + # unittest.main() will use sys.exit() so expect a SystemExit exception + unittest.main(testRunner=MyTestRunner)