Bug 16600 - Yitems are hard to manage in perl bindings
Summary: Yitems are hard to manage in perl bindings
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 5
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: QA Team
QA Contact:
URL: https://github.com/libyui/libyui-bind...
Whiteboard: MGA5-64-OK has_procedure advisory
Keywords: validated_update
Depends on:
Blocks:
 
Reported: 2015-08-18 16:45 CEST by Angelo Naselli
Modified: 2015-09-08 19:57 CEST (History)
3 users (show)

See Also:
Source RPM: libyui-bindings-1.0.4-0.git20140418.10
CVE:
Status comment:


Attachments
Perl test of selection from menu. (36.98 KB, image/png)
2015-08-31 13:57 CEST, Len Lawrence
Details
Perl test of menu example (36.94 KB, image/png)
2015-08-31 13:59 CEST, Len Lawrence
Details
Comparison test for perl (959 bytes, application/x-perl)
2015-08-31 20:56 CEST, Len Lawrence
Details
Comparison test for python binding (848 bytes, text/x-python)
2015-08-31 20:58 CEST, Len Lawrence
Details
Comparison test for ruby binding (897 bytes, application/x-ruby)
2015-08-31 20:59 CEST, Len Lawrence
Details

Description Angelo Naselli 2015-08-18 16:45:03 CEST
YItem references in swig perl binding are not univocally retrieved, 
and that have some bad side effects:

1) to be sure an item is selected only label or index are available, first is not univocal since it is often translated and different worlds can have identical translation in different context and meaning. Latter is univocal only for widget instance (YTree, Ytable, YMenu, etc.) but there is no reference to the widget items belong to, so an index is not univocal for the whole application.

2) finding an item is not easy as well, think to iterators item-collection->begin() and end() they provide a different reference value every time so end() comparison condition will always fail and the cycle will never stop, well it will really since the at iterator end, the got item access will crash the application.

See the attached URL to get info and file to test the problem.

Reproducible: 

Steps to Reproduce:
Comment 1 Angelo Naselli 2015-08-18 16:52:34 CEST
I have uploaded a patched package for Mageia 5.

You can test this by using the scripts linked in the attached URL. 
I tested it on x86_64.

Suggested advisory:
========================

Updated libyui-bindings packages fix the comparison of YItem objects, 
to compare YItem objects now you can use references, while before the
only way was to use labels or index, e.g. not an uinivocal way.

References:
https://github.com/libyui/libyui-bindings/issues/15

========================

Updated packages in core/updates_testing:
========================
python3-yui-1.0.4-0.git20140418.10.1.mga5.x86_64.rpm  
ruby-yui-1.0.4-0.git20140418.10.1.mga5.x86_64.rpm
perl-yui-1.0.4-0.git20140418.10.1.mga5.x86_64.rpm                   
python-yui-1.0.4-0.git20140418.10.1.mga5.x86_64.rpm

Source RPMs: 
libyui-bindings-1.0.4-0.git20140418.10.1.mga5.src.rpm

Status: NEW => ASSIGNED

Angelo Naselli 2015-08-18 16:53:08 CEST

CC: (none) => anaselli
Assignee: anaselli => qa-bugs

Comment 2 Len Lawrence 2015-08-31 13:12:10 CEST
Trying this on mga5 x86_64.

Installed

python3-yui-1.0.4-0  
ruby-yui-1.0.4-0
perl-yui-1.0.4-0                   
python-yui-1.0.4-0
pre-update.

Downloaded the test_items.pl and test_items_and_collections.pl scripts from the link referenced in comment 1.

Installed 
python3-yui-1.0.4-0.git20140418.10.1  
ruby-yui-1.0.4-0.git20140418.10.1
perl-yui-1.0.4-0.git20140418.10.1                   
python-yui-1.0.4-0.git20140418.10.1
from Updates Testing.

Ran
$ perl test_items.pl to run the gui against the items and collections.
Gui launched fine and responded to selections.  Shall attach screenshots to show the results.

I shall have to do some research now to figure out how to test ruby and python so this could take a while.

CC: (none) => tarazed25

Comment 3 Angelo Naselli 2015-08-31 13:29:03 CEST
I'll try to provide scripts for those language also... give me some more time...
Comment 4 Len Lawrence 2015-08-31 13:57:40 CEST
Created attachment 6983 [details]
Perl test of selection from menu.
Comment 5 Len Lawrence 2015-08-31 13:59:36 CEST
Created attachment 6984 [details]
Perl test of menu example
Comment 6 Len Lawrence 2015-08-31 14:02:43 CEST
I should be able to transcribe the perl script to ruby-tk given a day or two.
Comment 7 Len Lawrence 2015-08-31 15:28:23 CEST
Forgot to mention that lib64yui-{curses,qt,gtk} needed to be installed before the interface came up.  Have just now tried a POC by installing the pre-update versions of the RPMs on another machine and could detect no difference in behaviour, which means I have probably misinterpreted the values.  This was the terminal log for the pre-update session.
$ perl test_items.pl
<_M_> [ui] YPath.cc:49 YPath(): Given filename: libyui-qt.so.6
<_M_> [ui] YSettings.cc:73 progDir(): progDir: ""
<_M_> [ui] YPath.cc:65 YPath(): Preferring subdir: 
<_M_> [ui] YPath.cc:66 YPath(): Subdir given with filename: 
<_M_> [ui] YPath.cc:67 YPath(): Looking for: libyui-qt.so.6
<_M_> [ui] YPath.cc:138 lsDir(): Looking in /usr/lib64/yui
<_M_> [ui] YPath.cc:118 YPath(): Found libyui-qt.so.6 in /usr/lib64/yui
<_M_> [ui] YPath.cc:49 YPath(): Given filename: libyui-gtk.so.6
<_M_> [ui] YSettings.cc:73 progDir(): progDir: ""
<_M_> [ui] YPath.cc:65 YPath(): Preferring subdir: 
<_M_> [ui] YPath.cc:66 YPath(): Subdir given with filename: 
<_M_> [ui] YPath.cc:67 YPath(): Looking for: libyui-gtk.so.6
<_M_> [ui] YPath.cc:138 lsDir(): Looking in /usr/lib64/yui
<_M_> [ui] YPath.cc:118 YPath(): Found libyui-gtk.so.6 in /usr/lib64/yui
<_M_> [ui] YPath.cc:49 YPath(): Given filename: libyui-qt.so.6
<_M_> [ui] YSettings.cc:73 progDir(): progDir: ""
<_M_> [ui] YPath.cc:65 YPath(): Preferring subdir: 
<_M_> [ui] YPath.cc:66 YPath(): Subdir given with filename: 
<_M_> [ui] YPath.cc:67 YPath(): Looking for: libyui-qt.so.6
<_M_> [ui] YPath.cc:138 lsDir(): Looking in /usr/lib64/yui
<_M_> [ui] YPath.cc:118 YPath(): Found libyui-qt.so.6 in /usr/lib64/yui
<_M_> [ui] YUI.cc:76 YUI(): This is libyui 3.1.4
<_M_> [ui] YUI.cc:77 YUI(): Creating UI without threads
<_M_> [qt-ui] YQUI.cc:100 YQUI(): This is libyui-qt 2.46.13
<_M_> [ui] YUI.cc:230 topmostConstructorHasFinished(): Running without threads
<_M_> [qt-styler] QY2Styler.cc:97 loadStyleSheet(): Couldn't open style sheet "/usr/share/libyui/theme/current/wizard/style.qss"
<_M_> [qt-ui] YQUI.cc:298 processCommandLineArgs(): Qt argument: perl
<_M_> [qt-ui] YQUI.cc:298 processCommandLineArgs(): Qt argument: test_items.pl
<_M_> [qt-ui] YQUI.cc:441 calcDefaultSize(): Default size: 1792 x 985
<ERR> [qt-ui] YQUI.cc:264 initUI(): Forcing /libQtGui.so.5 open failed
<_M_> [qt-ui] YQApplication.cc:133 loadPredefinedQtTranslations(): Selected language: en_GB
<WRN> [qt-ui] YQApplication.cc:137 loadPredefinedQtTranslations(): Qt locale directory not set - no translations for predefined Qt dialogs
<_M_> [qt-ui] YQUI.cc:275 initUI(): YQUI initialized. Thread ID: 0x0x7f320cdf1700
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
<_M_> [ui] YUILoader.cc:104 deleteUI(): Shutting down UI
Comment 8 Angelo Naselli 2015-08-31 16:16:27 CEST
I added three simple test cases into https://github.com/libyui/libyui-bindings/issues/15

If you run it before installing the update they should print on console

item comparison does not work

after 

item comparison works and you chose [chosen item label]

The test cannot be run with libyui-ncurses because output is not shown on console,
qt and gtk are ok instead.

(you probably found a dep issue on package if you had to install them by hands,
but it's not easy to fix because ncurses is the minimum, but i cannot decide
which other UIs has to be required)
Comment 9 Len Lawrence 2015-08-31 20:33:33 CEST
Thanks Angelo.  The pre-update tests with those scripts work precisely as you said.
Comment 10 Len Lawrence 2015-08-31 20:51:40 CEST
l@vega ~/test]$ ruby test_yitems.rb
<_M_> [ui] YPath.cc:49 YPath(): Given filename: libyui-qt.so.6
<_M_> [ui] YSettings.cc:73 progDir(): progDir: ""
<_M_> [ui] YPath.cc:65 YPath(): Preferring subdir: 
<_M_> [ui] YPath.cc:66 YPath(): Subdir given with filename: 
<_M_> [ui] YPath.cc:67 YPath(): Looking for: libyui-qt.so.6
<_M_> [ui] YPath.cc:138 lsDir(): Looking in /usr/lib64/yui
<_M_> [ui] YPath.cc:118 YPath(): Found libyui-qt.so.6 in /usr/lib64/yui
<_M_> [ui] YPath.cc:49 YPath(): Given filename: libyui-gtk.so.6
<_M_> [ui] YSettings.cc:73 progDir(): progDir: ""
<_M_> [ui] YPath.cc:65 YPath(): Preferring subdir: 
<_M_> [ui] YPath.cc:66 YPath(): Subdir given with filename: 
<_M_> [ui] YPath.cc:67 YPath(): Looking for: libyui-gtk.so.6
<_M_> [ui] YPath.cc:138 lsDir(): Looking in /usr/lib64/yui
<_M_> [ui] YPath.cc:118 YPath(): Found libyui-gtk.so.6 in /usr/lib64/yui
<_M_> [ui] YPath.cc:49 YPath(): Given filename: libyui-qt.so.6
<_M_> [ui] YSettings.cc:73 progDir(): progDir: ""
<_M_> [ui] YPath.cc:65 YPath(): Preferring subdir: 
<_M_> [ui] YPath.cc:66 YPath(): Subdir given with filename: 
<_M_> [ui] YPath.cc:67 YPath(): Looking for: libyui-qt.so.6
<_M_> [ui] YPath.cc:138 lsDir(): Looking in /usr/lib64/yui
<_M_> [ui] YPath.cc:118 YPath(): Found libyui-qt.so.6 in /usr/lib64/yui
<_M_> [ui] YUI.cc:76 YUI(): This is libyui 3.1.4
<_M_> [ui] YUI.cc:77 YUI(): Creating UI without threads
<_M_> [qt-ui] YQUI.cc:100 YQUI(): This is libyui-qt 2.46.13
<_M_> [ui] YUI.cc:230 topmostConstructorHasFinished(): Running without threads
Xlib:  extension "RANDR" missing on display ":0".
<_M_> [qt-styler] QY2Styler.cc:97 loadStyleSheet(): Couldn't open style sheet "/usr/share/libyui/theme/current/wizard/style.qss"
<_M_> [qt-ui] YQUI.cc:298 processCommandLineArgs(): Qt argument: ruby
<_M_> [qt-ui] YQUI.cc:298 processCommandLineArgs(): Qt argument: test_yitems.rb
<_M_> [qt-ui] YQUI.cc:441 calcDefaultSize(): Default size: 2508 x 1007
<ERR> [qt-ui] YQUI.cc:264 initUI(): Forcing /libQtGui.so.5 open failed
<_M_> [qt-ui] YQApplication.cc:133 loadPredefinedQtTranslations(): Selected language: en_GB
<WRN> [qt-ui] YQApplication.cc:137 loadPredefinedQtTranslations(): Qt locale directory not set - no translations for predefined Qt dialogs
<_M_> [qt-ui] YQUI.cc:275 initUI(): YQUI initialized. Thread ID: 0x0x7fc53d3da700
item comparison works and you chose bar
item comparison works and you chose foo
<_M_> [ui] YUILoader.cc:104 deleteUI(): Shutting down UI


Perl and python produced the same results.

So this is good to go.  Adding tokens to whiteboard.
Len Lawrence 2015-08-31 20:53:23 CEST

Whiteboard: (none) => MGA5-64-OK has_procedure

Comment 11 Len Lawrence 2015-08-31 20:56:49 CEST
Created attachment 6985 [details]
Comparison test for perl

by Angelo Naselli
Console reports failure before update and success afterwards.
Comment 12 Len Lawrence 2015-08-31 20:58:55 CEST
Created attachment 6986 [details]
Comparison test for python binding

by Angelo Naselli
Console report of failure or success before and after updates.
Comment 13 Len Lawrence 2015-08-31 20:59:56 CEST
Created attachment 6987 [details]
Comparison test for ruby binding

by Angelo Naselli
Comment 14 claire robinson 2015-09-08 15:55:43 CEST
Well done Len

Validating. Advisory uploaded.

Please push to 5 updates

Thanks

Keywords: (none) => validated_update
Whiteboard: MGA5-64-OK has_procedure => MGA5-64-OK has_procedure advisory
CC: (none) => sysadmin-bugs

Comment 15 Mageia Robot 2015-09-08 19:57:16 CEST
An update for this issue has been pushed to Mageia Updates repository.

http://advisories.mageia.org/MGAA-2015-0119.html

Status: ASSIGNED => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.