optical_drive test command works, but is incorrect

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

Bug Description

this is the command for optical_drive in the resources.txt.in file:

name: optical_drive
plugin: resource
command: for media in CD DVD; do wodim -prcap 2>/dev/null | grep -q -i "Does write $media" && echo "$media: writable" || echo "$media: readonly"; done
requires: package.name == "wodim"
description: Create resource info for supported optical actions

This is the output of that command on an ARM server:
ubuntu@c18:~$ for media in CD DVD; do wodim -prcap 2>/dev/null | grep -q -i "Does write $media" && echo "$media: writable" || echo "$media: readonly"; done
CD: readonly
DVD: readonly

I get the same output on my laptop. The problem is that neither system has an optical drive.

Here is the basic wodim -prcap output:
ubuntu@c18:~$ wodim -prcap
wodim: Operation not permitted. Warning: Cannot raise RLIMIT_MEMLOCK limits.
Device was not specified. Trying to find an appropriate drive...
wodim: No such file or directory.
Cannot open SCSI driver!
For possible targets try 'wodim --devices' or 'wodim -scanbus'.
For possible transport specifiers try 'wodim dev=help'.
For IDE/ATAPI devices configuration, see the file README.ATAPI.setup from
the wodim documentation.

I don't know that this actually affects any testing as the optical tests only run if there's a drive found, however, it seems wrong to have this script telling me that my drive is readonly when it doesn't actually exist.

Tags: scripts

Related branches

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

Looks like the resource logic is a bit naive: if I don't see "Does write DVD media", then I blindly assume the requested drive exists and can't write.

The resource is expressed as a one-liner:

for media in CD DVD; do wodim -prcap 2>/dev/null | grep -q -i "Does write $media" && echo "$media: writable" || echo "$media: readonly"; done

This could be expanded to:

for media in CD DVD; do
    if wodim -prcap 2>/dev/null | grep -q -i "Does write $media"; then
            echo "$media: writable"
       else
            echo "$media: readonly"
    fi
done

And then amended to be:

for media in CD DVD; do
    if wodim -prcap 2>/dev/null | grep -q -i "Does write $media"; then
            echo "$media: writable"
    elif wodim -prcap 2>/dev/null | grep -q -i "Does not write $media"; then
            echo "$media: readonly"
    fi
done

I checked this against a non-writable DVD device and I get:

CD: readonly
DVD: readonly

Then I tested on a driveless (netbook) system:
ubuntu@201010-6646:~$ bash /tmp/test.sh
ubuntu@201010-6646:~$

Changed in checkbox:
status: New → Triaged
importance: Undecided → High
Daniel Manrique (roadmr)
Changed in checkbox:
assignee: nobody → Daniel Manrique (roadmr)
status: Triaged → In Progress
Daniel Manrique (roadmr)
Changed in checkbox:
status: In Progress → Fix Committed
Revision history for this message
Zygmunt Krynicki (zyga) wrote : Re: [Bug 1182489] [NEW] optical_drive test command works, but is incorrect

We should drop wodim and use udisks for that
21 maj 2013 16:10, "Jeff Lane" <email address hidden> napisał(a):

> Public bug reported:
>
> this is the command for optical_drive in the resources.txt.in file:
>
> name: optical_drive
> plugin: resource
> command: for media in CD DVD; do wodim -prcap 2>/dev/null | grep -q -i
> "Does write $media" && echo "$media: writable" || echo "$media: readonly";
> done
> requires: package.name == "wodim"
> description: Create resource info for supported optical actions
>
> This is the output of that command on an ARM server:
> ubuntu@c18:~$ for media in CD DVD; do wodim -prcap 2>/dev/null | grep -q
> -i "Does write $media" && echo "$media: writable" || echo "$media:
> readonly"; done
> CD: readonly
> DVD: readonly
>
> I get the same output on my laptop. The problem is that neither system
> has an optical drive.
>
> Here is the basic wodim -prcap output:
> ubuntu@c18:~$ wodim -prcap
> wodim: Operation not permitted. Warning: Cannot raise RLIMIT_MEMLOCK
> limits.
> Device was not specified. Trying to find an appropriate drive...
> wodim: No such file or directory.
> Cannot open SCSI driver!
> For possible targets try 'wodim --devices' or 'wodim -scanbus'.
> For possible transport specifiers try 'wodim dev=help'.
> For IDE/ATAPI devices configuration, see the file README.ATAPI.setup from
> the wodim documentation.
>
> I don't know that this actually affects any testing as the optical tests
> only run if there's a drive found, however, it seems wrong to have this
> script telling me that my drive is readonly when it doesn't actually
> exist.
>
> ** Affects: checkbox
> Importance: Undecided
> Status: New
>
>
> ** Tags: scripts
>
> --
> You received this bug notification because you are a member of Checkbox
> Bug Wranglers, which is subscribed to checkbox.
> https://bugs.launchpad.net/bugs/1182489
>
> Title:
> optical_drive test command works, but is incorrect
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/checkbox/+bug/1182489/+subscriptions
>

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.