| 1 |
# -*- shell-script -*- |
| 2 |
|
| 3 |
FUNCTIONS_DIR="debian/tests/functions.d" |
| 4 |
|
| 5 |
error_exit () { |
| 6 |
echo "ERROR: $1" |
| 7 |
exit 1 |
| 8 |
} |
| 9 |
|
| 10 |
line_count () { |
| 11 |
wc -l $1 | cut -d' ' -f1 |
| 12 |
} |
| 13 |
|
| 14 |
match_or_exit () { |
| 15 |
file_to_match="$1" |
| 16 |
pattern_file="$2" |
| 17 |
|
| 18 |
if [ $(line_count "${file_to_match}") -ne $(line_count "${pattern_file}") ]; then |
| 19 |
error_exit "line count of ${file_to_match} ($(line_count "${file_to_match}")) and pattern ($(line_count "${pattern_file}")) do not match" |
| 20 |
fi |
| 21 |
while read line_to_match <&3 && read pattern_line <&4 ; do |
| 22 |
if [ "${line_to_match##$pattern_line}" ]; then |
| 23 |
echo '!!! MISMATCH !!!' >&2 |
| 24 |
echo "Line: ${line_to_match}" >&2 |
| 25 |
echo "Pattern: ${pattern_line}" >&2 |
| 26 |
exit 1 |
| 27 |
fi; |
| 28 |
done 3<"${file_to_match}" 4<"${pattern_file}" |
| 29 |
} |
| 30 |
|
| 31 |
check_cdrdao_version_string () { |
| 32 |
echo ~~~ Checking cdrdao version string ... |
| 33 |
cdrdao version 2>&1 | tee version.out |
| 34 |
match_or_exit version.out $FUNCTIONS_DIR/cdrdao-version.patterns |
| 35 |
} |
| 36 |
|
| 37 |
check_cdrdao_help_page () { |
| 38 |
echo ~~~ Checking cdrdao help page ... |
| 39 |
cdrdao 2>&1 | tee help.out |
| 40 |
match_or_exit help.out $FUNCTIONS_DIR/cdrdao-help.patterns |
| 41 |
} |
| 42 |
|
| 43 |
check_toc2cue_version_string () { |
| 44 |
echo ~~~ Checking toc2cue version string ... |
| 45 |
toc2cue -V 2>&1 | tee version.out |
| 46 |
match_or_exit version.out $FUNCTIONS_DIR/toc2cue-version.patterns |
| 47 |
} |
| 48 |
|
| 49 |
check_toc2cddb_version_string () { |
| 50 |
echo ~~~ Checking toc2cddb version string ... |
| 51 |
toc2cddb -V 2>&1 | tee version.out |
| 52 |
match_or_exit version.out $FUNCTIONS_DIR/toc2cddb-version.patterns |
| 53 |
} |
| 54 |
|
| 55 |
is_drive_available () { |
| 56 |
echo ~~~ Reading Drive Info ... |
| 57 |
cdrdao drive-info 2>&1 |
| 58 |
return $? |
| 59 |
} |
| 60 |
|
| 61 |
get_disk_info () { |
| 62 |
echo ~~~ Reading Disk Info ... |
| 63 |
cdrdao disk-info 2>&1 |
| 64 |
} |