power-management/bluetooth_detect_after_suspend hangs if bluetooth device is not present

Bug #836756 reported by Daniel Manrique
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Checkbox
Fix Released
High
Daniel Manrique

Bug Description

This shouldn't happen on a system where bluetooth was not detected but it does!

The command run for this test is:

grep -q `hcitool dev | tail -n+2 | awk '{print $2}'` $CHECKBOX_DATA/bluetooth_address

This compares the bluetooth address from hcitool dev with that obtained in the pre-suspend run.

However if there's no bluetooth device present, the command enclosed in backticks returns nothing, and the command run is:

grep -q /home/user/.cache/checkbox/bluetooth_address

This searches stdin for the string /home/user/.cache/checkbox/bluetooth_address. However, as nothing is coming into stdin, the command will hang there waiting for input.

I realized this happens when I disabled my laptop's bluetooth module and then tried to do a test run.

So steps to reproduce would be:

1- Take either a laptop without bluetooth or one with bluetooth disabled. Make sure bluez is installed, as it's also checked for as a dependency.
2- Start checkbox and do a run that includes the bluetooth_detect_after_suspend test.

Expected result:
- the test either passes or fails and the run continues.

Actual result:
- Checkbox hangs waiting for the command to complete, requiring manually killing the "stuck" grep process.

An easy solution is to quote that part of the command so as to ensure it will at least be an "empty string" giving a valid grep command that doesn't crash.

grep -q "`hcitool dev | tail -n+2 | awk '{print $2}'`" $CHECKBOX_DATA/bluetooth_address

Daniel Manrique (roadmr)
Changed in checkbox:
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → Daniel Manrique (roadmr)
Ara Pulido (ara)
Changed in checkbox:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers