xref: /OK3568_Linux_fs/yocto/poky/meta/lib/oeqa/selftest/cases/pseudo.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#
2*4882a593Smuzhiyun# SPDX-License-Identifier: MIT
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun
5*4882a593Smuzhiyunimport glob
6*4882a593Smuzhiyunimport os
7*4882a593Smuzhiyunimport shutil
8*4882a593Smuzhiyunfrom oeqa.utils.commands import bitbake, get_test_layer
9*4882a593Smuzhiyunfrom oeqa.selftest.case import OESelftestTestCase
10*4882a593Smuzhiyun
11*4882a593Smuzhiyunclass Pseudo(OESelftestTestCase):
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun    def test_pseudo_pyc_creation(self):
14*4882a593Smuzhiyun        self.write_config("")
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun        metaselftestpath = get_test_layer()
17*4882a593Smuzhiyun        pycache_path = os.path.join(metaselftestpath, 'lib/__pycache__')
18*4882a593Smuzhiyun        if os.path.exists(pycache_path):
19*4882a593Smuzhiyun            shutil.rmtree(pycache_path)
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun        bitbake('pseudo-pyc-test -c install')
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun        test1_pyc_present = len(glob.glob(os.path.join(pycache_path, 'pseudo_pyc_test1.*.pyc')))
24*4882a593Smuzhiyun        self.assertTrue(test1_pyc_present, 'test1 pyc file missing, should be created outside of pseudo context.')
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun        test2_pyc_present = len(glob.glob(os.path.join(pycache_path, 'pseudo_pyc_test2.*.pyc')))
27*4882a593Smuzhiyun        self.assertFalse(test2_pyc_present, 'test2 pyc file present, should not be created in pseudo context.')
28