Test+Qt: Add an automatic update check.

Add software_update_info() to the software update module, which returns
the name of our update library if we have one. Use it to add automatic
update information to the compiled information in `wireshark --version`.

Add a "release" test suite, which contains a test for automatic updates.

Ping-Bug: 16381
Change-Id: I867a96bdcfde8be541eca2dc0e84b5000276e7dd
Reviewed-on: https://code.wireshark.org/review/36107
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Gerald Combs 2020-02-13 15:18:14 -08:00 committed by Anders Broman
parent 7247b98d45
commit d7bbe384f5
6 changed files with 78 additions and 2 deletions

View File

@ -3338,6 +3338,7 @@ set(_test_group_list
suite_mergecap
suite_nameres
suite_outputformats
suite_release
suite_text2pcap
suite_sharkd
suite_unittests

47
test/suite_release.py Normal file
View File

@ -0,0 +1,47 @@
#
# -*- coding: utf-8 -*-
# Wireshark tests
#
# Copyright (c) 2019 Gerald Combs <gerald@wireshark.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later
#
'''Release tests'''
import fixtures
import re
import subprocess
import subprocesstest
import types
@fixtures.fixture
def wireshark_features(request, cmd_wireshark, make_env):
'''
Returns an object describing available features in Wireshark. Tests
will be skipped unless --enable-release is passed on the command line.
'''
enabled = request.config.getoption('--enable-release', default=False)
if not enabled:
fixtures.skip('Release tests are not enabled via --enable-release')
try:
wireshark_v = subprocess.check_output(
(cmd_wireshark, '--version'),
stderr=subprocess.PIPE,
universal_newlines=True,
env=make_env()
)
wireshark_v = re.sub(r'\s+', ' ', wireshark_v)
except subprocess.CalledProcessError as ex:
print('Failed to detect Wireshark features: %s' % (ex,))
wireshark_v = ''
return types.SimpleNamespace(
have_automatic_updates='with automatic updates' in wireshark_v,
)
@fixtures.uses_fixtures
class case_release_automatic_updates(subprocesstest.SubprocessTestCase):
def test_automatic_updates_present(self, wireshark_features):
'''Checks whether Wireshark was built with automatic updates.'''
self.assertTrue(wireshark_features.have_automatic_updates);

View File

@ -54,6 +54,8 @@ def main():
parser = argparse.ArgumentParser(description='Wireshark unit tests')
cap_group = parser.add_mutually_exclusive_group()
cap_group.add_argument('-E', '--disable-capture', action='store_true', help='Disable capture tests')
release_group = parser.add_mutually_exclusive_group()
release_group.add_argument('--enable-release', action='store_true', help='Enable release tests')
parser.add_argument('-p', '--program-path', default=os.path.curdir, help='Path to Wireshark executables.')
parser.add_argument('--skip-missing-programs',
help='Skip tests that lack programs from this list instead of failing'

View File

@ -79,6 +79,7 @@
#include "ui/commandline.h"
#include "ui/capture_ui_utils.h"
#include "ui/preference_utils.h"
#include "ui/software_update.h"
#include "ui/taps.h"
#include "ui/qt/conversation_dialog.h"
@ -137,8 +138,8 @@
# INFO = 64
# DEBUG = 128
*/
#define DEBUG_STARTUP_TIME_LOGLEVEL 252
*/
/* update the main window */
void main_window_update(void)
@ -226,6 +227,14 @@ get_gui_compiled_info(GString *str)
g_string_append(str, "without QtMultimedia");
#endif
g_string_append(str, ", ");
const char *update_info = software_update_info();
if (update_info) {
g_string_append_printf(str, "with automatic updates using %s", update_info);
} else {
g_string_append_printf(str, "without automatic updates");
}
#ifdef _WIN32
g_string_append(str, ", ");
#ifdef HAVE_AIRPCAP

View File

@ -123,6 +123,10 @@ extern void software_update_cleanup(void) {
win_sparkle_cleanup();
}
const char *software_update_info(void) {
return "WinSparkle " WIN_SPARKLE_VERSION_STRING;
}
#elif defined (__APPLE__)
/** Initialize software updates.
*/
@ -146,6 +150,10 @@ software_update_check(void) {
*/
void software_update_cleanup(void) {
}
const char *software_update_info(void) {
return "Sparkle";
}
#endif
#else /* No updates */
@ -167,6 +175,10 @@ software_update_check(void) {
void software_update_cleanup(void) {
}
const char *software_update_info(void) {
return NULL;
}
#endif /* defined(HAVE_SOFTWARE_UPDATE) && defined (_WIN32) */
/*
@ -181,4 +193,3 @@ void software_update_cleanup(void) {
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/

View File

@ -41,6 +41,12 @@ extern void software_update_check(void);
*/
extern void software_update_cleanup(void);
/** Fetch a description of the software update mechanism.
*
* @return NULL, "Sparkle", or "WinSparkle".
*/
extern const char *software_update_info(void);
#ifdef _WIN32
/** Check to see if Wireshark can shut down safely (e.g. offer to save the
* current capture). Called from a separate thread.