aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2014-10-01 12:44:14 -0700
committerGerald Combs <gerald@wireshark.org>2014-10-01 22:30:33 +0000
commit58cde5c74accbb7ad843e4b97e64c2b9f74b8854 (patch)
tree52808e0e80d4c7c7621960d392f4dc0b1e049464
parentb5aa0d2a4f6b70c16323e5ea69412c3cc861379e (diff)
Add tests for the Qt UI.
Make sure the Qt UI quits if WIRESHARK_QUIT_AFTER_CAPTURE is set. Make sure Bourne shell scripts (*.sh) have UNIX/POSIX line endings. Reduce some time values so that the tests run faster. Change-Id: I81df7c6f72d7d807d1856863cbea1bb6326ca711 Reviewed-on: https://code.wireshark.org/review/4407 Tested-by: Gerald Combs <gerald@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--.gitattributes1
-rwxr-xr-xtest/config.sh5
-rwxr-xr-xtest/suite-capture.sh34
-rwxr-xr-xtest/suite-io.sh6
-rwxr-xr-xtest/test.sh2
-rw-r--r--ui/qt/main.cpp2
-rw-r--r--ui/qt/main_window_slots.cpp18
7 files changed, 63 insertions, 5 deletions
diff --git a/.gitattributes b/.gitattributes
index e797a0d476..610cc900be 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,4 +1,5 @@
* text=auto
+*.sh eol=lf
/test export-ignore
.bzrignore export-ignore
.gitattributes export-ignore
diff --git a/test/config.sh b/test/config.sh
index a33cbd9e4f..e7306668eb 100755
--- a/test/config.sh
+++ b/test/config.sh
@@ -50,13 +50,16 @@ SKIP_CAPTURE=${SKIP_CAPTURE:-1}
# Override the last two items if we're running Windows
if [ "$WS_SYSTEM" = "Windows" ] ; then
WS_BIN_PATH=${WS_BIN_PATH:-$SOURCE_DIR/wireshark-gtk2}
+ WS_QT_BIN_PATH=${WS_QT_BIN_PATH:-$SOURCE_DIR/wireshark-qt-release}
SKIP_CAPTURE=0
fi
# Path to the Wireshark binaries, default to source dir if unset
WS_BIN_PATH=${WS_BIN_PATH:-$SOURCE_DIR}
+WS_QT_BIN_PATH=${WS_QT_BIN_PATH:-$SOURCE_DIR}
# Tweak the following to your liking.
+WIRESHARK=$WS_QT_BIN_PATH/wireshark
WIRESHARK_GTK=$WS_BIN_PATH/wireshark-gtk
TSHARK=$WS_BIN_PATH/tshark
RAWSHARK=$WS_BIN_PATH/rawshark
@@ -76,7 +79,7 @@ TRAFFIC_CAPTURE_IFACE=${TRAFFIC_CAPTURE_IFACE:-1}
# time to capture some traffic (in seconds)
# (you may increase this if you get errors caused by very low traffic)
-TRAFFIC_CAPTURE_DURATION=15
+TRAFFIC_CAPTURE_DURATION=10
# the default is to not capture in promiscuous mode
# (this makes known trouble with some Windows WLAN adapters)
diff --git a/test/suite-capture.sh b/test/suite-capture.sh
index 71dec1a26e..c92a957162 100755
--- a/test/suite-capture.sh
+++ b/test/suite-capture.sh
@@ -27,6 +27,7 @@ EXIT_OK=0
EXIT_COMMAND_LINE=1
EXIT_ERROR=2
+WIRESHARK_CMD="$WIRESHARK -o gui.update.enabled:FALSE -k"
WIRESHARK_GTK_CMD="$WIRESHARK_GTK -o gui.update.enabled:FALSE -k"
capture_test_output_print() {
@@ -58,7 +59,7 @@ traffic_gen_ping() {
*) # *BSD, Linux
ping -c 1 -s $x www.wireshark.org ;;
esac
- sleep 1
+ sleep 0.1
done
date
} > ./testout_ping.txt 2>&1 &
@@ -202,7 +203,7 @@ capture_step_fifo() {
# capture packets via a fifo
capture_step_stdin() {
CONSOLE_LOG_ARGS=""
- if [ "$DUT" == "$WIRESHARK_GTK_CMD" -a "$WS_SYSTEM" == "Windows" ] ; then
+ if [[ ( "$DUT" == "$WIRESHARK_CMD" || "$DUT" == "$WIRESHARK_GTK_CMD" ) && "$WS_SYSTEM" == "Windows" ]] ; then
CONSOLE_LOG_ARGS="-o console.log.level:127"
fi
@@ -413,6 +414,34 @@ wireshark_capture_suite() {
# WIRESHARK_QUIT_AFTER_CAPTURE needs to be set.
#
+ # NOTE: This may not do the right thing if we use toolkits
+ # that use Wayland or Mir directly, unless they also depend
+ # on the DISPLAY environment variable.
+ #
+ if [[ $WS_SYSTEM != Windows && $WS_SYSTEM != Darwin ]] && [ -z "$DISPLAY" ]; then
+ echo -n ' (X server not available)'
+ test_step_skipped
+ return
+ fi
+
+ DUT="$WIRESHARK_CMD"
+ test_step_add "Capture 10 packets" capture_step_10packets
+ # piping to stdout doesn't work with Wireshark and capturing!
+ #test_step_add "Capture 10 packets using stdout: -w -" capture_step_10packets_stdout
+ if [ $TEST_FIFO ]; then
+ test_step_add "Capture via fifo" capture_step_fifo
+ fi
+ test_step_add "Capture via stdin" capture_step_stdin
+ # read filter doesn't work with Wireshark and capturing!
+ #test_step_add "Capture read filter (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_read_filter
+ test_step_add "Capture snapshot length 68 bytes (${TRAFFIC_CAPTURE_DURATION}s)" capture_step_snapshot
+}
+
+wireshark_gtk_capture_suite() {
+ # k: start capture immediately
+ # WIRESHARK_QUIT_AFTER_CAPTURE needs to be set.
+
+ #
# NOTE: if, on OS X, we start using a native-Quartz toolkit,
# this would need to change to check for WS_SYSTEM being
# "Darwin" and, if it is, check whether the standard output
@@ -484,6 +513,7 @@ capture_suite() {
test_suite_add "Dumpcap capture" dumpcap_capture_suite
test_suite_add "TShark capture" tshark_capture_suite
test_suite_add "Wireshark capture" wireshark_capture_suite
+ test_suite_add "Wireshark 1 capture" wireshark_gtk_capture_suite
}
#
diff --git a/test/suite-io.sh b/test/suite-io.sh
index 3245a61edb..07065369a8 100755
--- a/test/suite-io.sh
+++ b/test/suite-io.sh
@@ -143,6 +143,12 @@ io_step_rawshark_pcap_stdin() {
}
+wireshark_io_suite() {
+ # Q: quit after cap, k: start capture immediately
+ DUT="$WIRESHARK"
+ test_step_add "Input file" io_step_input_file
+}
+
wireshark_gtk_io_suite() {
# Q: quit after cap, k: start capture immediately
DUT="$WIRESHARK_GTK"
diff --git a/test/test.sh b/test/test.sh
index a676b1f122..879d720088 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -114,7 +114,7 @@ trap test_cleanup EXIT
test_step_prerequisites() {
NOTFOUND=0
- for i in "$WIRESHARK_GTK" "$TSHARK" "$CAPINFOS" "$DUMPCAP" ; do
+ for i in "$WIRESHARK" "$WIRESHARK_GTK" "$TSHARK" "$CAPINFOS" "$DUMPCAP" ; do
if [ ! -x $i ]; then
echo "Couldn't find $i"
NOTFOUND=1
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp
index c742bbaf6f..30f3d37a32 100644
--- a/ui/qt/main.cpp
+++ b/ui/qt/main.cpp
@@ -298,7 +298,7 @@ print_usage(gboolean for_help_option) {
#ifndef _WIN32
fprintf(output, " --display=DISPLAY X display to use\n");
#endif
- fprintf(output, "\nNOTE: Not all options are already implemented in the QT port.\n");
+ fprintf(output, "\nNOTE: Not all options are implemented in the Qt port.\n");
#ifdef _WIN32
destroy_console();
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index e1b47791f9..b1951028aa 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -418,6 +418,12 @@ void MainWindow::captureCaptureUpdateFinished(capture_session *cap_session) {
setForCaptureInProgress(false);
setWindowIcon(wsApp->normalIcon());
+
+ if (global_capture_opts.quit_after_cap) {
+ /* command line asked us to quit after the capture */
+ /* don't pop up a dialog to ask for unsaved files etc. */
+ wsApp->quit();
+ }
#endif // HAVE_LIBPCAP
}
void MainWindow::captureCaptureFixedStarted(capture_session *cap_session) {
@@ -437,6 +443,12 @@ void MainWindow::captureCaptureFixedFinished(capture_session *cap_session) {
setForCaptureInProgress(false);
setWindowIcon(wsApp->normalIcon());
+
+ if (global_capture_opts.quit_after_cap) {
+ /* command line asked us to quit after the capture */
+ /* don't pop up a dialog to ask for unsaved files etc. */
+ wsApp->quit();
+ }
#endif // HAVE_LIBPCAP
}
void MainWindow::captureCaptureStopping(capture_session *cap_session) {
@@ -457,6 +469,12 @@ void MainWindow::captureCaptureFailed(capture_session *cap_session) {
main_ui_->mainStack->setCurrentWidget(main_welcome_);
setWindowIcon(wsApp->normalIcon());
+
+ if (global_capture_opts.quit_after_cap) {
+ /* command line asked us to quit after the capture */
+ /* don't pop up a dialog to ask for unsaved files etc. */
+ wsApp->quit();
+ }
#endif // HAVE_LIBPCAP
}