From patchwork Wed Jul 12 02:40:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 786934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x6jr857Zdz9s7C for ; Wed, 12 Jul 2017 12:41:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Nnpbd4uB"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C2A67871A1; Wed, 12 Jul 2017 02:41:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WLwnDf4DbmoE; Wed, 12 Jul 2017 02:41:04 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id B7EA5871AC; Wed, 12 Jul 2017 02:41:03 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 3DF7F1CEACD for ; Wed, 12 Jul 2017 02:41:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 3475B87CBC for ; Wed, 12 Jul 2017 02:41:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Rcx-LZfMHqpS for ; Wed, 12 Jul 2017 02:41:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by whitealder.osuosl.org (Postfix) with ESMTPS id BA84E87CBD for ; Wed, 12 Jul 2017 02:41:00 +0000 (UTC) Received: by mail-pf0-f194.google.com with SMTP id e199so1300939pfh.0 for ; Tue, 11 Jul 2017 19:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wLOLoVR33xTfk6QovxROM+5JgjbPldl+lQ04OS/YJPg=; b=Nnpbd4uBzjs5rIDjoMCr0byLFopGQfy8R9LLzfTNx8EgnSlb6RArD9X4D/4kSufZaI fZ56jRx7RReO/BE3ee1BfbRJ0oGF8ZAjpcg9/UAnK16a8QipiI0tFo+oqwIzaXLnD66j GMde1hwlXSICopIfliDehjUUP755oLEMl1ZaBLkt6yZFUjJFPWmKYXAR54N+qvzVJkmd FVlBOt3d23kwbb5l21psd9lhL4QiFtoooZl7anv0AVwPPxVsrB3Na8BTWi3PBYXldT2r xXnM4C8mcvLusXa8w67H1dMKFV30NMLB+hi1HzY7BYjN0kb/fYvKCC9AXw69xDDuWm2B N9xw== 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; bh=wLOLoVR33xTfk6QovxROM+5JgjbPldl+lQ04OS/YJPg=; b=BCGbJLlUp11OCxq4tI125TMwbTbRJF5itd5913fGr/+Dz6NzBowv1aRGe3ruZy29kA lI1YBWg8Qk6ggZ8JPPK4YYlTdHIwSRoLbZPvtvgRAN88H4rjn5z9ZrxEMYKVaVYP824S Ze1vtGZ9qSiyGuaDjP2blxKoEwP8HnWyZJw+HrKjG9+ba0XHRae9JSToZf1qNsxYYUpS QloW9E277ODmqKY5QSyME7CM7iQqZhBPjWco7PnJCwj+7sORI/MlGMPw2zdiqX6xU6SD 420quFrRbytsh9gmnDNFChmQ5p3qGGqBTeYOml7AV2QPq8Fnh8ZjU1BqvuMvpEIoMJ/e k6zg== X-Gm-Message-State: AIVw113bYhsr4GPEgmqLT9cpbNKO1khpc0mY4JdQRUaE62/SY7v3IBkd BEjjJpMnSNi0rkIfylg= X-Received: by 10.84.217.220 with SMTP id d28mr1667826plj.218.1499827260128; Tue, 11 Jul 2017 19:41:00 -0700 (PDT) Received: from squirtle.westlake.spaceflightindustries.com ([173.226.206.194]) by smtp.gmail.com with ESMTPSA id h27sm1239640pfd.34.2017.07.11.19.40.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jul 2017 19:40:59 -0700 (PDT) From: Andrey Smirnov To: buildroot@buildroot.org Date: Tue, 11 Jul 2017 19:40:05 -0700 Message-Id: <20170712024009.2366-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170712024009.2366-1-andrew.smirnov@gmail.com> References: <20170712024009.2366-1-andrew.smirnov@gmail.com> Cc: Andrey Smirnov Subject: [Buildroot] [PATCH v2 2/6] testing/tests/package/test_python: refactor TestPythonBase X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Convert TestPythonBase to a true base class that only provides code implementing various tests without definig tests themselves in a "discoverable" form. To retain correct testing functionality, add TestPython2 derived class that uses code from TestPythonBase to define actual runnable test. Signed-off-by: Andrey Smirnov Reviewed-by: Ricardo Martincoski Tested-by: Ricardo Martincoski --- support/testing/tests/package/test_python.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/support/testing/tests/package/test_python.py b/support/testing/tests/package/test_python.py index 5532fb5..250827e 100644 --- a/support/testing/tests/package/test_python.py +++ b/support/testing/tests/package/test_python.py @@ -5,31 +5,46 @@ import infra.basetest class TestPythonBase(infra.basetest.BRTest): config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ """ -BR2_PACKAGE_PYTHON=y BR2_TARGET_ROOTFS_CPIO=y # BR2_TARGET_ROOTFS_TAR is not set """ - - def test_run(self): + def login(self): cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") self.emulator.boot(arch="armv5", kernel="builtin", options=["-initrd", cpio_file]) self.emulator.login() - cmd = "python --version 2>&1 | grep '^Python 2'" + + def version_test(self, version): + cmd = "python --version 2>&1 | grep '^{}'".format(version) _, exit_code = self.emulator.run(cmd) self.assertEqual(exit_code, 0) + def math_floor_test(self): cmd = "python -c 'import math; math.floor(12.3)'" _, exit_code = self.emulator.run(cmd) self.assertEqual(exit_code, 0) + def libc_time_test(self): cmd = "python -c 'import ctypes;" cmd += "libc = ctypes.cdll.LoadLibrary(\"libc.so.1\");" cmd += "print libc.time(None)'" _, exit_code = self.emulator.run(cmd) self.assertEqual(exit_code, 0) + def zlib_test(self): cmd = "python -c 'import zlib'" _, exit_code = self.emulator.run(cmd) self.assertEqual(exit_code, 1) + +class TestPython2(TestPythonBase): + config = TestPythonBase.config + \ +""" +BR2_PACKAGE_PYTHON=y +""" + def test_run(self): + self.login() + self.version_test("Python 2") + self.math_floor_test() + self.libc_time_test() + self.zlib_test()