optical_drive test command works, but is incorrect
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.
Related branches
- Daniel Manrique (community): Approve
- Zygmunt Krynicki (community): Approve
-
Diff: 33 lines (+12/-1)2 files modifieddebian/changelog (+4/-0)
jobs/resource.txt.in (+8/-1)
Changed in checkbox: | |
assignee: | nobody → Daniel Manrique (roadmr) |
status: | Triaged → In Progress |
Changed in checkbox: | |
status: | In Progress → Fix Committed |
Changed in checkbox: | |
status: | Fix Committed → Fix Released |
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: 201010- 6646:~$ bash /tmp/test.sh 201010- 6646:~$
ubuntu@
ubuntu@