From patchwork Mon Jul 16 12:51:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 142015 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2386399ljj; Mon, 16 Jul 2018 05:51:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeUrKIb9Wj6s/oSbHvmaI58SqrSPiT1XNfvSCdZmh7K+0CPHfFkub9jLAfzPwu+K1MWN8AE X-Received: by 2002:a63:6949:: with SMTP id e70-v6mr15852242pgc.119.1531745495539; Mon, 16 Jul 2018 05:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531745495; cv=none; d=google.com; s=arc-20160816; b=z03KFPzUW/B84DpZHmksR7uYdADOraTpuB0y5SKPoq/ekpJZOWlVbAKCtbjDUamhAk sz7g3vOCMkQk7eVKfqsgyfouNEdJc4OScd7B2I5RrQjsUBYMVTlPSqnaKE1KjpmzEl/5 sH20siTk/WF9+NU/JXVcWPSkvtcZexn+NHVpqG93rpZITqkb4vhfpk6yp4fM1TN9eMje WXVTzctLacgyer+RANP6uXlIlmkl6D0aWQoXFBiedinavbSUOdPWCo0vb3OUZxgqVF/Y kPbB23PcXZk8qT6DS/73IOGBr0siGqSYejPYUjBpooyz54l3fmE/wLL2L07EmF1MLfDJ JF9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=xfXd7snrdIVHrO8i49B614wnXJqqewkRQBY81XNesh0=; b=mkJ9zubmvQNx+vHKadaqcV0LLpu8j7tHHDbrK1+4UPJRtIAM8nermcVGvvyntxe6ux OwGjrjTsjqHwDI7f7oybvts+t/6l2S/OtTAf0KCt0k2KfhfVgDSx5L2n/1bwx2RW5YVb 339AIsZbu+Tg/ADihpSlsqR+kHwmbJDJU6LHCJe0Q8A2amwofWgWA/WhBErfh2w9I2aD cFbYbYiNT3WGKFD5NW0vUUt69J940uIXodS7LOQmPa2xj3UsV5/dm4XAC2KNuWtozVpE UP5bMmq3Fe6wFKIY/qLiQjV6WjcMBbf3YMMcJECuaoySCQzEW1bPMjR/7+lpDQXVosWX JUYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=eBD1AOZF; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from mail.openembedded.org (mail.openembedded.org. [140.211.169.62]) by mx.google.com with ESMTP id y128-v6si30485947pfb.299.2018.07.16.05.51.35; Mon, 16 Jul 2018 05:51:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) client-ip=140.211.169.62; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=eBD1AOZF; spf=pass (google.com: best guess record for domain of openembedded-core-bounces@lists.openembedded.org designates 140.211.169.62 as permitted sender) smtp.mailfrom=openembedded-core-bounces@lists.openembedded.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from layers.openembedded.org (localhost [127.0.0.1]) by mail.openembedded.org (Postfix) with ESMTP id 8C7107550F; Mon, 16 Jul 2018 12:51:31 +0000 (UTC) X-Original-To: openembedded-core@lists.openembedded.org Delivered-To: openembedded-core@lists.openembedded.org Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mail.openembedded.org (Postfix) with ESMTP id 1E82E7609F for ; Mon, 16 Jul 2018 12:51:28 +0000 (UTC) Received: by mail-wr1-f43.google.com with SMTP id j5-v6so25263709wrr.8 for ; Mon, 16 Jul 2018 05:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=BZXiC9u+XA/LwdrZSPvyERDYQ8pfK5i1VoNlCOWe00E=; b=eBD1AOZFLbXMjTSjD3bwfjdq1uFysv3RR4zkRHD8GUU02c+2lRaCeRTmhDn9kfViT7 IcGd5VmQcmKwSevReRvDcdjfLabLoM/pwwtHJx8b1g2f05pUwPNdOMOqQiDTbI7oVovg hiOLAVLL4U11wIEpM5wEP1ZWnT0Ur2I9lfjJjIg+frDncyRHatKt2NcozgrualEUPIOC FOLKxixksoxCbcup8KXtAMjWSfXvvDzI02LfBhRTw8AnC8rkMwOEj3dvdqLl/tPfg1Dz 1TxZOL9SKMZkesckWry1Tv9taCoXHdyGPtgjwpJDV3FOTAh+6FP4raXnGmf7Bbp/rw3C oABA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=BZXiC9u+XA/LwdrZSPvyERDYQ8pfK5i1VoNlCOWe00E=; b=O8jAtYEMMzzXlF1KOo1tG8EbISfoT/yKAfivwq8ahSEhnvIAK0EyYPjno8M4a0DI5l VT2EWIIqyG9H3CsSTqPfu9HZKlDLnd68u+h4Jmh6Kq2tXg8ctesd0+SHe+x4c/WVWHjL EwpYXmDMHnCtJ4Lza1yF/4ItHiNA7Ovatktp7C4t+74oJNYXve7h/ZJa/eyldWXbCJy7 da9zRZaUsoJZgmfukP2abFW0NfPX2mlxa64znp8hvQ+xjuBiJJDmCCNVadc0UTPVblsm 6VCVv2KPs8AEq2BC2TtlePzdBmA/MPesWzGjcBkQFS1LgaHRjccM2JPfOIBKe6EhL64C KAzw== X-Gm-Message-State: AOUpUlFOcGqxv87qIcdqydao0CVZQwMYhijkq3fWc1ufpK5M8m7sIc0j ZXv/rMSc6KoqoPuiOp55LEOHsgxU X-Received: by 2002:adf:a541:: with SMTP id j1-v6mr13206489wrb.155.1531745488593; Mon, 16 Jul 2018 05:51:28 -0700 (PDT) Received: from flashheart.burtonini.com (35.106.2.81.in-addr.arpa. [81.2.106.35]) by smtp.gmail.com with ESMTPSA id a14-v6sm12502837wmb.44.2018.07.16.05.51.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 05:51:27 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Date: Mon, 16 Jul 2018 13:51:26 +0100 Message-Id: <20180716125126.12829-1-ross.burton@intel.com> X-Mailer: git-send-email 2.11.0 Subject: [OE-core] [PATCH] oeqa/runtime/python: clean up Python test X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: openembedded-core-bounces@lists.openembedded.org Errors-To: openembedded-core-bounces@lists.openembedded.org Currently this is three test cases: 1) test_python_exists. Fail if python3 isn't in PATH. 2) test_python_stdout. Run a Python script and check the output is as expected 3) test_python_testfile. Check that a file test_python_stdout wrote to exists. (1) should be a setup and skip the test module if it isn't present. (2) and (3) should be merged, there's no point copying over a two line Python file, and the test doesn't verify that the file doesn't exist in the first place. Rewrite the test to check that Python is present in a class setup so the entire test is skipped if it isn't and do some simple rot13 to verify that bytecode is being executed correctly. Signed-off-by: Ross Burton --- meta/lib/oeqa/runtime/cases/python.py | 38 ++++++++--------------------------- 1 file changed, 8 insertions(+), 30 deletions(-) -- 2.11.0 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core diff --git a/meta/lib/oeqa/runtime/cases/python.py b/meta/lib/oeqa/runtime/cases/python.py index 3d6eb088024..4419a9f6394 100644 --- a/meta/lib/oeqa/runtime/cases/python.py +++ b/meta/lib/oeqa/runtime/cases/python.py @@ -1,43 +1,21 @@ -import os - from oeqa.runtime.case import OERuntimeTestCase from oeqa.core.decorator.depends import OETestDepends from oeqa.core.decorator.oeid import OETestID -from oeqa.runtime.decorator.package import OEHasPackage class PythonTest(OERuntimeTestCase): - @classmethod def setUpClass(cls): - src = os.path.join(cls.tc.files_dir, 'test.py') - dst = '/tmp/test.py' - cls.tc.target.copyTo(src, dst) - - @classmethod - def tearDownClass(cls): - dst = '/tmp/test.py' - cls.tc.target.run('rm %s' % dst) - - @OETestID(1145) - @OETestDepends(['ssh.SSHTest.test_ssh']) - @OEHasPackage(['python3-core']) - def test_python_exists(self): - status, output = self.target.run('which python3') - msg = 'Python binary not in PATH or not on target.' - self.assertEqual(status, 0, msg=msg) + import unittest + if "python3-core" not in cls.tc.image_packages: + raise unittest.SkipTest("Python3 not on target") @OETestID(965) - @OETestDepends(['python.PythonTest.test_python_exists']) - def test_python_stdout(self): - status, output = self.target.run('python3 /tmp/test.py') + @OETestDepends(['ssh.SSHTest.test_ssh']) + def test_python3(self): + cmd = "python3 -c \"import codecs; print(codecs.encode('Uryyb, jbeyq', 'rot13'))\"" + status, output = self.target.run(cmd) msg = 'Exit status was not 0. Output: %s' % output self.assertEqual(status, 0, msg=msg) msg = 'Incorrect output: %s' % output - self.assertEqual(output, "the value of a is 0.01", msg=msg) - - @OETestID(1146) - @OETestDepends(['python.PythonTest.test_python_stdout']) - def test_python_testfile(self): - status, output = self.target.run('ls /tmp/testfile.python') - self.assertEqual(status, 0, msg='Python test file generate failed.') + self.assertEqual(output, "Hello, world", msg=msg)