Bug 10889

Summary: Zephyr kernel tests fail to start if python module pexpect is not installed
Product: [Build System, Metadata & Runtime] Other YP Layers Reporter: Henry Bruce <henry.bruce>
Component: meta-zephyrAssignee: Juro Bystricky <juro.bystricky>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: bluelightning, srifenbark
Version: 2.3   
Target Milestone: 2.3 M3   
Hardware: x86   
OS: Multiple   
Whiteboard: 24 Jan 2017: RESOLVED
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Done (doc changes complete)

Description Henry Bruce 2017-01-06 21:41:07 UTC
Observed behavior
=================
Kernel tests will not run if python module pexpect is not installed
$ bitbake zephyr-kernel-test-all -ctestimage

ERROR: zephyr-kernel-test-test-nano-work-1.6.0-r0 do_testimage: Failed to import QemuTargetZephyr from available controller modules:
Traceback (most recent call last):
  File "/path/to/poky/meta/lib/oeqa/targetcontrol.py", line 32, in get_target_controller
    controller = getattr(sys.modules[__name__], testtarget)
AttributeError: module 'oeqa.targetcontrol' has no attribute 'QemuTargetZephyr'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/to/poky/meta/lib/oeqa/targetcontrol.py", line 38, in get_target_controller
    controller = testtargetloader.get_controller_module(testtarget, bbpath)
  File "/path/to/poky/meta/lib/oeqa/controllers/testtargetloader.py", line 15, in get_controller_module
    controller = self.load_controller_from_name(target, controllerslist)
  File "path/to/poky/meta/lib/oeqa/controllers/testtargetloader.py", line 48, in load_controller_from_name
    obj = self.load_controller_from_module(target, name)
  File "/path/to/poky/meta/lib/oeqa/controllers/testtargetloader.py", line 57, in load_controller_from_module
    module = __import__(modulename, globals(), locals(), [target])
  File "/path/to/poky/meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py", line 25, in <module>
    import pexpect
ImportError: No module named 'pexpect'

ERROR: zephyr-kernel-test-test-nano-work-1.6.0-r0 do_testimage: Function failed: do_testimage
ERROR: Logfile of failure stored in: /path/to/build/tmp/work/i586-yocto-elf/zephyr-kernel-test-test-nano-work/1.6.0-r0/temp/log.do_testimage.27044

Expected behavior
=================
Documentation states that python module pexpect must be installed.
Comment 1 Juro Bystricky 2017-01-06 22:06:50 UTC
The bug has actually nothing to do with meta-zephyr.
It is the 

meta-yocto-bsp/lib/oeqa/controllers/beaglebonetarget.py

complaining about missing python module "pexpect". 
I could speculate the module was previously included with python2.7 by default
but it is not installed by python3, at least for some Linux distros. 
However, I suspect this problem has always been there.

Manual installation :

$ sudo pip3 install pexpect

should fix the problem.

So the most prudent fix is to update the documentation explicitly stating pexpect is required

http://www.yoctoproject.org/docs/1.8/ref-manual/ref-manual.html#required-packages-for-the-host-development-system
Comment 2 Juro Bystricky 2017-01-12 23:18:35 UTC
Punting this to Scott, as the need for "pexpect" should be documented.
Comment 3 Scott Rifenbark 2017-01-20 00:00:59 UTC
Juro, 

So installing the "pexpect" package for all supported distros.  I assume that it needs to be in the "Essentials" grouping (see http://www.yoctoproject.org/docs/2.3/ref-manual/ref-manual.html#required-packages-for-the-host-development-system)

Thanks, 
Scott
Comment 4 Juro Bystricky 2017-01-23 20:33:51 UTC
yes, I believe that is exactly what is needed.
Comment 5 Scott Rifenbark 2017-01-23 22:37:56 UTC
Juro, 

See http://www.yoctoproject.org/docs/2.3/ref-manual/ref-manual.html#required-packages-for-the-host-development-system for the changes in the ref-manual. 

See http://www.yoctoproject.org/docs/2.3/yocto-project-qs/yocto-project-qs.html#packages for the similar section in the YP Quick Start.

If this is ok - let me know. 

Thanks, 
Scott
Comment 6 Juro Bystricky 2017-01-23 23:36:09 UTC
Looks good to me. (And it should be probably back ported to previous Yocto
documentation as well, this is not a new requirement)
Comment 7 Scott Rifenbark 2017-01-24 00:35:05 UTC
Backported to top of yocto-docs/morty branch.  See ref-manual at http://www.yoctoproject.org/docs/2.2.1/ref-manual/ref-manual.html#required-packages-for-the-host-development-system

Backported to top of yocto-docs/morty branch.  see YP Quick Start at http://www.yoctoproject.org/docs/2.2.1/yocto-project-qs/yocto-project-qs.html#packages

Scott
Comment 8 Juro Bystricky 2017-01-24 17:40:52 UTC
Looks fine. Both pip3 and pexpect are always needed:
pip3 in order to run toaster and build Build Appliance
pexpect is (and has always been) needed by beaglbone testimage
Comment 9 Scott Rifenbark 2017-01-24 21:51:44 UTC
Thanks Juro, 

I am setting the bug to RESOLVED and putting the doc flag to "done."

Scott