annoying fake error message in Bluetooth obex test

Bug #1169488 reported by Jeffrey Chang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Checkbox
Fix Released
Medium
Jeff Lane 

Bug Description

checkbox 0.15.6~ppa+bzr1964+201303291110~precise1

All suspend/bluetooth_obex_XXXX will pass with below message
dpkg-query: error: error writing to '<standard output>': Broken pipe

This will confuse the tester if there's anything wrong.

a sample result on https://certification.canonical.com/hardware/201302-12847/submission/90515/test-results/pass/?page=3

Related branches

Revision history for this message
Daniel Manrique (roadmr) wrote :

Hi Jeffrey,

The script uses dpkg to check whether obexftp is installed. The only instance of this is calling:

dpkg -l

Could you please run the following command and tell me what it outputs?

if ! dpkg -l | grep -q obexftp; then echo "You must install obexftp to run this script"; fi

Also, please separately run these two commands and also tell me what it outputs:

dpkg -l
dpkg -l | grep -q obexftp

Changed in checkbox:
status: New → Incomplete
Revision history for this message
Jeffrey Chang (modern911) wrote :

both work as expected.
dpkg -l listed all my packages,
dpkg -l | grep -q obexftp, shows nothing, then echo $? will get 0, cause I have obexftp installed.

Revision history for this message
Daniel Manrique (roadmr) wrote :

OK, so that's covered, let's try running the command manually.

You need to know your bluetooth target's address (a hex number like 00:1B:B1:16:D2:40).

Then do:

/usr/share/checkbox/scripts/obex_send <bluetooth-target> /etc/hosts

this will try sending a small file, let me know what the tests output when run manually.

Thanks!

Revision history for this message
Jeffrey Chang (modern911) wrote :

The test is actually passing, I can see the file on another pc.
Just the error message is really annoying.

I saw this on multiple submissions, so I believe this should not caused by my environment.
Another example here https://certification.canonical.com/hardware/201304-13203/submission/90634/test-results/pass/?page=3

Revision history for this message
Jeff Lane  (bladernr) wrote :

Just a note, all the tests Jeffrey references use bluetooth_test, not obex_send.

Also, for reference, this is the sort of output that is confusing:

dpkg-query: error: error writing to '<standard output>': Broken pipe
Checking 00:02:72:DC:5E:38 for JPEG_Color_Image_Ubuntu.jpg
Will check for a filesize of 25770
Browsing 00:02:72:DC:5E:38 ...
Connecting..\done
Tried to connect for 9ms
Receiving "(null)"...|done
Disconnecting../done
<file name="JPEG_Color_Image_Ubuntu.jpg" size="25770" user-perm="RWD" modified="20130110T021952Z" created="20130110T021952Z" accessed="20130418T054757Z" />
PASS

Revision history for this message
Jeff Lane  (bladernr) wrote :

The bit in question seems innocuous enough:

if ! dpkg -l | grep -q obexftp; then
    echo "You must install obexftp to run this script"
    exit 1

Would it make a difference if run in a subshell like this:

if ( ! dpkg -l | grep -q obexftp ); then
    echo "You must install obexftp to run this script"
    exit 1

or better yet, is there a better way to determine if a package is installed?

Revision history for this message
Daniel Manrique (roadmr) wrote :

dpkg -s seems to output some text, but exit status 1 for a non-installed package, and 0 for an installed package.

This bears testing in all three possible scenarios:

- Package has never been installed
- Package is currently installed
- Package was installed, then removed

The other option I've frequently seen used is

dpkg -l packagename |grep ^ii

but this has the potential same problem of piping dpkg output to grep.

It'd be great to somehow reproduce Jeffrey's error message so we know what causes it, and we can test that any proposed solution does *not* exhibit that behavior.

Daniel Manrique (roadmr)
Changed in checkbox:
status: Incomplete → Confirmed
importance: Undecided → Medium
Revision history for this message
Jeff Lane  (bladernr) wrote :

Jeffrey, can you have someone do the following:

replace /usr/share/checkbox/scripts/bluetooth_test with the version attached here
re-run the bluetooth tests
check the resulting output for the error and verify that the test works.

Rather than muck about with subshells, let's try changing how we determine if obexftp is present.

Changed in checkbox:
status: Confirmed → Incomplete
Revision history for this message
Jeff Lane  (bladernr) wrote :

I should add that I am not able to test this locally as I don't have the hardware to do so.

Revision history for this message
Jeff Lane  (bladernr) wrote :

Hah, I didn't even realize Daniel had replied until after I posted all that.

So FWIW, my proposed fix is this:

dpkg-query -W obexftp >/dev/null 2>&1

which will give us a 0 if installed, or 1 otherwise, and no output at all. It also avoids any wonky subshell weirdness, which is what I think was happening here (dpkg maybe trying to write to stderr but getting the descriptor for the parent shell the script was running in instead of the local shell??) or some other madness.

So at the very least, eliminating the pipe and grep stuff should resolve it.

Revision history for this message
Jeff Lane  (bladernr) wrote :

Another suggestion would be to just remove that check from the script alltogether. The job descriptions all specify the requirement package.name == 'obexftp'

BUT that has a caveat:

it removes the bit that stops the script cleanly if obexftp isn't installed which makes the script brittle if run stand-alone.

I'd prefer, personally, to see if my suggested patch fixes the issue before taking more drastic measures.

Revision history for this message
Jeffrey Chang (modern911) wrote :
Revision history for this message
Jeff Lane  (bladernr) wrote :

Awesome. Thanks for verifying. I'll push that branch now and it should land in trunk shortly.

Changed in checkbox:
assignee: nobody → Jeff Lane (bladernr)
status: Incomplete → Triaged
status: Triaged → In Progress
Jeff Lane  (bladernr)
Changed in checkbox:
status: In Progress → Fix Committed
Changed in checkbox:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.