aboutsummaryrefslogtreecommitdiffstats
path: root/test/lua
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2022-10-06 06:43:30 +0100
committerJoão Valverde <j@v6e.pt>2022-10-11 14:25:04 +0100
commita19834b98cda6d31bc31534b8cd497d055645439 (patch)
tree7de3e05fa14042c9d014bd353c5ed33460c8440d /test/lua
parent44d1cc6d4a8ac93c235356554d505759ea1d6aba (diff)
Windows: Store "gui.console_open" in the Windows registry
This removes the last dependency of the logging subsystem on the preferences module. The latter is started much later than the former and this is an issue. The Windows-only preference "gui.console_open" is stored in the registry as HKEY_LOCAL_USER\Software\Wireshark\ConsoleOpen. The semantics are exactly the same. The preference is read by the logging subsystem for initialization and then again by the preferences (read/write) so the user can configure it as before. The code to store the preference also in the preferences file was kept, for backward compatibility and because it is not incompatible with using the Registry concurrently. The elimination of the prefs dependency also allows moving the Windows console logic to wsutil and add the functionality to wslog directly, thereby eliminating the superfluous Wireshark/Logray custom log handler. To be able to read the ws_log_console_open global variable from libwireshark it becomes necessary to add a new export macro symbol called WSUTIL_EXPORT.
Diffstat (limited to 'test/lua')
-rw-r--r--test/lua/util.lua17
1 files changed, 8 insertions, 9 deletions
diff --git a/test/lua/util.lua b/test/lua/util.lua
index cb5b710252..737e1ee66d 100644
--- a/test/lua/util.lua
+++ b/test/lua/util.lua
@@ -16,6 +16,8 @@ local function test(name, ...)
end
end
+local console_open
+
--------------------------
-- Note: This tests expects some specific default values
@@ -32,7 +34,10 @@ test("get_preference-unknown-4",get_preference("ugi.ask_unsaved") == nil)
test("get_preference-uint-0",get_preference("gui.fileopen.preview") == 3)
test("get_preference-bool-0",get_preference("gui.ask_unsaved") == true)
test("get_preference-bool-1",get_preference("gui.interfaces_show_hidden") == false)
-test("get_preference-enum-1",get_preference("gui.console_open") == "NEVER")
+-- gui.console_open is persistent (in the Windows registry) and for that
+-- reason does not have a default value.
+console_open = get_preference("gui.console_open")
+test("get_preference-enum-0",console_open == "NEVER" or console_open == "AUTOMATIC" or console_open == "ALWAYS")
test("get_preference-string-0",get_preference("gui.window_title") == "")
test("get_preference-range-0",get_preference("http.tls.port") == "443")
success = pcall(get_preference, "user_dlt.encaps_table")
@@ -71,12 +76,8 @@ success = pcall(set_preference,"gui.console_open")
test("set_preference-enum-0", not success)
success = pcall(set_preference,"gui.console_open",true)
test("set_preference-enum-1", not success)
-test("set_preference-enum-2",set_preference("gui.console_open","NEVER") == false)
-test("set_preference-enum-3",set_preference("gui.console_open","AUTOMATIC") == true)
-test("set_preference-enum-3-get",get_preference("gui.console_open") == "AUTOMATIC")
-test("set_preference-enum-4",set_preference("gui.console_open","ALWAYS") == true)
-test("set_preference-enum-5",set_preference("gui.console_open","unknown") == false)
-test("set_preference-enum-6",set_preference("gui.console_open",42) == false)
+-- false means unchanged
+test("set_preference-enum-2",set_preference("gui.console_open",console_open) == false)
success = pcall(set_preference,"gui.window_title")
test("set_preference-string-0", not success)
success = pcall(set_preference,"gui.window_title",true)
@@ -112,8 +113,6 @@ test("reset_preference-uint-0",reset_preference("gui.fileopen.preview") == true)
test("reset_preference-uint-0-get",get_preference("gui.fileopen.preview") == 3)
test("reset_preference-bool-0",reset_preference("gui.ask_unsaved") == true)
test("reset_preference-bool-0-get",get_preference("gui.ask_unsaved") == true)
-test("reset_preference-enum-0",reset_preference("gui.console_open") == true)
-test("reset_preference-enum-0-get",get_preference("gui.console_open") == "NEVER")
test("reset_preference-string-0",reset_preference("gui.window_title") == true)
test("reset_preference-string-0-get",get_preference("gui.window_title") == "")
test("reset_preference-range-0",reset_preference("http.tls.port") == true)