From patchwork Mon Mar 20 20:36:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 741169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vn7766Js1z9rvt for ; Tue, 21 Mar 2017 07:37:54 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4629088E59; Mon, 20 Mar 2017 20:37:53 +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 tjqT0Ceuy+uS; Mon, 20 Mar 2017 20:37:49 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id AADD988F3C; Mon, 20 Mar 2017 20:37:26 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id A8D561C0CF8 for ; Mon, 20 Mar 2017 20:37:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A38B289ACC for ; Mon, 20 Mar 2017 20:37:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NB0iU1z8-8yc for ; Mon, 20 Mar 2017 20:37:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.free-electrons.com (mail.free-electrons.com [62.4.15.54]) by hemlock.osuosl.org (Postfix) with ESMTP id 6AE9489A4C for ; Mon, 20 Mar 2017 20:37:17 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 156892081F; Mon, 20 Mar 2017 21:37:17 +0100 (CET) Received: from localhost (LFbn-1-6691-76.w90-120.abo.wanadoo.fr [90.120.129.76]) by mail.free-electrons.com (Postfix) with ESMTPSA id 8DDEF207DC; Mon, 20 Mar 2017 21:36:57 +0100 (CET) From: Thomas Petazzoni To: Buildroot List Date: Mon, 20 Mar 2017 21:36:53 +0100 Message-Id: <1490042214-6762-5-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490042214-6762-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1490042214-6762-1-git-send-email-thomas.petazzoni@free-electrons.com> Cc: Thomas Petazzoni , Luca Ceresoli , "Yann E. MORIN" , Ricardo Martincoski Subject: [Buildroot] [PATCH v3 4/5] support/testing: add package tests 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" This commit adds some basic tests for two Buildroot packages: python and dropbear. These tests are by no mean meant to be exhaustive, but mainly to serve as initial examples for other tests. Signed-off-by: Thomas Petazzoni --- support/testing/tests/package/__init__.py | 0 support/testing/tests/package/test_dropbear.py | 28 +++++++++++++++++++++ support/testing/tests/package/test_python.py | 35 ++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 support/testing/tests/package/__init__.py create mode 100644 support/testing/tests/package/test_dropbear.py create mode 100644 support/testing/tests/package/test_python.py diff --git a/support/testing/tests/package/__init__.py b/support/testing/tests/package/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/support/testing/tests/package/test_dropbear.py b/support/testing/tests/package/test_dropbear.py new file mode 100644 index 0000000..a64b782 --- /dev/null +++ b/support/testing/tests/package/test_dropbear.py @@ -0,0 +1,28 @@ +import os + +import infra.basetest + +class TestDropbear(infra.basetest.BRTest): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ +""" +BR2_TARGET_GENERIC_ROOT_PASSWD="testpwd" +BR2_SYSTEM_DHCP="eth0" +BR2_PACKAGE_DROPBEAR=y +BR2_TARGET_ROOTFS_CPIO=y +# BR2_TARGET_ROOTFS_TAR is not set +""" + + def test_run(self): + img = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", img, + "-net", "nic", + "-net", "user,hostfwd=tcp::2222-:22"]) + self.emulator.login("testpwd") + cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:22" + _, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 0) + # Would be useful to try to login through SSH here, through + # localhost:2222, though it is not easy to pass the ssh + # password on the command line. diff --git a/support/testing/tests/package/test_python.py b/support/testing/tests/package/test_python.py new file mode 100644 index 0000000..5532fb5 --- /dev/null +++ b/support/testing/tests/package/test_python.py @@ -0,0 +1,35 @@ +import os + +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): + 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'" + _, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 0) + + cmd = "python -c 'import math; math.floor(12.3)'" + _, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 0) + + 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) + + cmd = "python -c 'import zlib'" + _, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 1)