virshtest: Adapt numeric option arg handling tests from 'virsh-optparse'

Move the argument parsing tests excercising various numeric options
(except 'virsh event') from 'virsh-optparse' to 'virshtest'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa committed 2024-04-02 14:24:30 +02:00
1 parent 6a2712262e
commit 2aec9b399b
4 files changed
+85 -105

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
echo Test a regular numeric option
echo Non-numeric value
cpu-stats test --start abc
echo Numeric value with invalid suffix
cpu-stats test --start 42WB
echo Numeric value with valid suffix. Suffixes are not supported for
echo regular numeric options, so this value is rejected
cpu-stats test --start 42MB
echo Numeric value bigger than INT_MAX
cpu-stats test --start 2147483648
echo Negative numeric value. The value is not valid for the command
echo we are testing, but it has been parsed correctly
cpu-stats test --start -1
echo Test a scaled numeric option
echo Non-numeric value
setmaxmem test abc
echo Numeric value with invalid suffix
setmaxmem test 42WB
echo Numeric value with valid suffix
setmaxmem test 42MB --config
echo Numeric value bigger than INT_MAX. No failure here because
echo scaled numeric values are unsigned long long
setmaxmem test 2147483648 --config
echo Negative numeric value
setmaxmem test -1
echo Zero. The value is not valid for the command were testing, but
echo it has been parsed correctly
setmaxmem test 0
echo Numeric value
setmaxmem test 42 --config
+41
View File
@@ -0,0 +1,41 @@
Test a regular numeric option
Non-numeric value
error: Numeric value 'abc' for <start> option is malformed or out of range
Numeric value with invalid suffix
error: Numeric value '42WB' for <start> option is malformed or out of range
Numeric value with valid suffix. Suffixes are not supported for
regular numeric options, so this value is rejected
error: Numeric value '42MB' for <start> option is malformed or out of range
Numeric value bigger than INT_MAX
error: Numeric value '2147483648' for <start> option is malformed or out of range
Negative numeric value. The value is not valid for the command
we are testing, but it has been parsed correctly
error: Invalid value for start CPU
Test a scaled numeric option
Non-numeric value
error: Scaled numeric value 'abc' for <size> option is malformed or out of range
Numeric value with invalid suffix
error: Scaled numeric value '42WB' for <size> option is malformed or out of range
error: invalid argument: unknown suffix 'WB'
Numeric value with valid suffix
Numeric value bigger than INT_MAX. No failure here because
scaled numeric values are unsigned long long
Negative numeric value
error: Scaled numeric value '-1' for <size> option is malformed or out of range
Zero. The value is not valid for the command were testing, but
it has been parsed correctly
error: Unable to change MaxMemorySize
error: memory in virDomainSetMemoryFlags must not be zero
Numeric value