aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite-clopts.sh
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-02-15 12:17:26 -0800
committerGuy Harris <guy@alum.mit.edu>2016-02-15 20:17:54 +0000
commit4e85b62ae5c623cca8dc38bc3ab6a556b3d5db15 (patch)
treee9cbd470c0c39b3ce2e22a85c1394bd6729147e0 /test/suite-clopts.sh
parent44f74e7b2657fb8691e59aa86910f818ece31c4d (diff)
Allow test of the -D and -L options to succeed or fail with a permissions error.
We cannot easily predict what will happen, given the configuration of the OS, the permissions on files, the availability of extcap devices, the version of libpcap/WinPcap/NPcap (present or future), etc., etc., etc.. Allow those tests to succeed (as would be the case if you have the necessary permissions) or fail with a non-command-line-syntax error (as would be the case if you don't have the necessary permissions), but not to fail with a command-line syntax error. Change-Id: I76af898d5f146fcf3507c06f101acb578085e6fa Reviewed-on: https://code.wireshark.org/review/13957 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'test/suite-clopts.sh')
-rwxr-xr-xtest/suite-clopts.sh42
1 files changed, 28 insertions, 14 deletions
diff --git a/test/suite-clopts.sh b/test/suite-clopts.sh
index da3d9bcf82..3a0b7eda68 100755
--- a/test/suite-clopts.sh
+++ b/test/suite-clopts.sh
@@ -43,6 +43,22 @@ test_single_char_options()
rm ./testout.txt
}
+# check against $EXIT_OK or $EXIT_ERROR with a single char option
+# $1 command: tshark or dumpcap
+# $2 option: a
+test_D_or_L_option()
+{
+ #echo "command: "$1" opt1: "$2" opt2: "$3" opt3: "$4" opt4: "$5" opt5: "$6
+ $1 -$2 > ./testout.txt 2>&1
+ RETURNVALUE=$?
+ if [ ! $RETURNVALUE -eq $EXIT_OK -a ! $RETURNVALUE -eq $EXIT_ERROR ]; then
+ test_step_failed "exit status: $RETURNVALUE"
+ else
+ test_step_ok
+ fi
+ rm ./testout.txt
+}
+
# dumpcap
# Only with remote capture: A:ru
@@ -69,16 +85,15 @@ clopts_suite_dumpcap_valid_chars() {
done
}
-# special case: interface-specific opts should work under Windows and fail as
-# a regular user on other systems.
+# special case: interface-specific opts might work as a regular user
+# (exit code 0) or might fail due to lack of permissions (exit code 2)
+# but shouldn't fail due to a syntax error (exit code 1). We cannot
+# predict whether it'll be a success or failure based on the machine,
+# so allow either one.
clopts_suite_dumpcap_interface_chars() {
for index in D L
do
- if [ "$SKIP_CAPTURE" -eq 0 ] ; then
- test_step_add "Valid dumpcap parameter -$index, exit status must be $EXIT_OK" "test_single_char_options $DUMPCAP $index $EXIT_OK"
- else
- test_step_add "Invalid permissions for dumpcap parameter -$index, exit status must be $EXIT_ERROR" "test_single_char_options $DUMPCAP $index $EXIT_ERROR"
- fi
+ test_step_add "Valid dumpcap parameter -$index requiring capture permissions, exit status must be $EXIT_OK or $EXIT_ERROR" "test_D_or_L_option $DUMPCAP $index"
done
}
@@ -186,16 +201,15 @@ clopts_suite_tshark_valid_chars() {
done
}
-# special case: interface-specific opts should work under Windows and fail as
-# a regular user on other systems.
+# special case: interface-specific opts might work as a regular user
+# (exit code 0) or might fail due to lack of permissions (exit code 2)
+# but shouldn't fail due to a syntax error (exit code 1). We cannot
+# predict whether it'll be a success or failure based on the machine,
+# so allow either one.
clopts_suite_tshark_interface_chars() {
for index in D L
do
- if [ "$SKIP_CAPTURE" -eq 0 ] ; then
- test_step_add "Valid TShark parameter -$index, exit status must be $EXIT_OK" "test_single_char_options $TSHARK $index $EXIT_OK"
- else
- test_step_add "Invalid permissions for TShark parameter -$index, exit status must be $EXIT_ERROR" "test_single_char_options $TSHARK $index $EXIT_ERROR"
- fi
+ test_step_add "Valid TShark parameter -$index requiring capture permissions, exit status must be $EXIT_OK or $EXIT_ERROR" "test_D_or_L_option $TSHARK $index"
done
}