diff --git a/tests/data/illegal-mode.data b/tests/data/illegal-mode.data new file mode 100644 index 0000000..d4ba344 --- /dev/null +++ b/tests/data/illegal-mode.data @@ -0,0 +1,7 @@ +# A non-compressing DAT (DDS-1) +# The manufacturer, model, and revision strings can be obtained, +# from the file /proc/scsi/scsi (cat /proc/scsi/scsi). +manufacturer=XYZ model = "UVW1" { +scsi2logical=1 can-bsr can-partitions auto-lock +mode1 blocksize=0 +modeABC blocksize=1024 } diff --git a/tests/mt-cli.test b/tests/mt-cli.test new file mode 100644 index 0000000..fc1dc6f --- /dev/null +++ b/tests/mt-cli.test @@ -0,0 +1,34 @@ +# Wrong argument +./mt -x +>>>2 /usage: / +>>>= 1 + +# Missing tape argument +./mt -f +>>>2 /usage: / +>>>= 1 + +# Unknown command +./mt to-the-moon +>>>2 /mt: unknown command "to-the-moon"/ +>>>= 1 + +# Too many arguments +./mt rewind 1 +>>>2 /mt: too many arguments for the command 'rewind'\./ +>>>= 1 + +# Ambigous command +./mt l +>>>2 /mt: ambiguous command "l"/ +>>>= 1 + +# Shortened but not ambiguous command. +./mt rewi 1 +>>>2 /mt: too many arguments for the command 'rewind'\./ +>>>= 1 + +# Densities command - the only one not requiring a tape. +./mt densities +>>> /LTO-6/ +>>>= 0 diff --git a/tests/mt-errors.test b/tests/mt-errors.test new file mode 100644 index 0000000..bef9437 --- /dev/null +++ b/tests/mt-errors.test @@ -0,0 +1,4 @@ +# Wrong tape argument +./mt -f /dev/no-such-tape rewind +>>>2 /no-such-tape: No such file or directory/ +>>>= 1 diff --git a/tests/stinit-errors.test b/tests/stinit-errors.test new file mode 100644 index 0000000..4fed36f --- /dev/null +++ b/tests/stinit-errors.test @@ -0,0 +1,51 @@ +# Check handling of missing file +./stinit -p -f no-such-database +>>>2 /Can't find SCSI tape database/ +>>>= 1 + +# No file passed +./stinit -p -f +>>>2 /Usage:/ +>>>= 1 + +# Wrong arguments +./stinit -x +>>>2 /Usage:/ +>>>= 1 + +# Illegal ordering of arguments +./stinit -f stinit.def.examples 1000 - +>>>2 /Usage:/ +>>>= 1 + +# Check bad mode +./stinit -v -v -p -f tests/data/illegal-mode.data +>>> /Errors found!/ +>>>2 /Illegal mode for/ +>>>= 1 + +# No modes defined +#./stinit -v -v -f tests/data/no-modes.data +#>>> /Errors found!/ +#>>>2 /Illegal mode for/ +#>>>= 1 + +# Wrong tape device +./stinit -f stinit.def.examples /dev/no-such-tape +>>>2 /Can't find tape number for name/ +>>>= 0 + +# Wrong tape number. Well, this is flaky, but let's hope nobody has +# 1000 tapes. +./stinit -f stinit.def.examples 1000 +>>>2 /Can't find any device files for tape 1000/ +>>>= 0 + +./stinit -f stinit.def.examples 1000 +>>>2 /Definition for '1000' failed/ +>>>= 0 + +# Wrong tape number (non-numeric). +./stinit -f stinit.def.examples 1000a +>>>2 /Invalid tape device index '1000a': don't know how to parse 'a'/ +>>>= 0 diff --git a/tests/stinit-parsing.test b/tests/stinit-parsing.test index 9827880..6636fc6 100644 --- a/tests/stinit-parsing.test +++ b/tests/stinit-parsing.test @@ -2,6 +2,11 @@ ./stinit -p -f stinit.def.examples >>>= 0 +# Extra arguments ignored while file parsing +./stinit -p -f stinit.def.examples abc +>>>2 /Extra arguments .* ignored/ +>>>= 0 + # Checking complete stinit parsing ./stinit -v -v -p -f stinit.def.examples >>> /No errors found./