File 2785-Add-tests-and-documentation.patch of Package erlang
From 91564533a94492308442d7773fc1f023650cde50 Mon Sep 17 00:00:00 2001
From: Benedikt Reinartz <filmor@gmail.com>
Date: Tue, 13 Dec 2022 19:34:41 +0100
Subject: [PATCH 05/12] Add tests and documentation
---
lib/observer/doc/src/observer.xml | 37 ++++++++++++++++++++++++++--
lib/observer/test/observer_SUITE.erl | 35 ++++++++++++++++++++++++--
2 files changed, 68 insertions(+), 4 deletions(-)
diff --git a/lib/observer/doc/src/observer.xml b/lib/observer/doc/src/observer.xml
index 3fa59db70a..6994994756 100644
--- a/lib/observer/doc/src/observer.xml
+++ b/lib/observer/doc/src/observer.xml
@@ -52,8 +52,41 @@
<fsummary>Start the Observer GUI.</fsummary>
<desc>
<p>Starts the Observer GUI.
- To stop the tool, close the window.
- </p>
+ To stop the tool, close the window or call
+ <seemfa marker="#stop/0">stop/0</seemfa>.
+ </p>
+ </desc>
+ </func>
+ <func>
+ <name since="OTP 26">start(Node) -> ok</name>
+ <fsummary>Start the Observer GUI connected against <c>Node</c>.</fsummary>
+ <desc>
+ <p>Starts the Observer GUI and tries to connect it to <c>Node</c>.</p>
+ </desc>
+ </func>
+ <func>
+ <name since="OTP 26">start_and_wait() -> ok</name>
+ <fsummary>Start the Observer GUI blocking.</fsummary>
+ <desc>
+ <p>Starts the Observer GUI and only return when it is either stopped or
+ the window is closed</p>
+ </desc>
+ </func>
+ <func>
+ <name since="OTP 26">start_and_wait(Node) -> ok</name>
+ <fsummary>Start the Observer GUI blocking and connect it to <c>Node</c>.</fsummary>
+ <desc>
+ <p>Starts the Observer GUI and only return when it is either stopped or
+ the window is closed, connects it directly to <c>Node</c> like
+ <seemfa marker="#start/1">start/1</seemfa>.
+ </p>
+ </desc>
+ </func>
+ <func>
+ <name since="OTP 26">stop() -> ok</name>
+ <fsummary>Stop the Observer GUI.</fsummary>
+ <desc>
+ <p>Stops the Observer GUI.</p>
</desc>
</func>
</funcs>
diff --git a/lib/observer/test/observer_SUITE.erl b/lib/observer/test/observer_SUITE.erl
index 1a1dca0fe0..3c3eca7ce7 100644
--- a/lib/observer/test/observer_SUITE.erl
+++ b/lib/observer/test/observer_SUITE.erl
@@ -35,7 +35,8 @@
%% Test cases
-export([app_file/1, appup_file/1,
basic/1, process_win/1, table_win/1,
- port_win_when_tab_not_initiated/1
+ port_win_when_tab_not_initiated/1,
+ blocking_start/1, remote_node/1
]).
%% Default timetrap timeout (set in init_per_testcase)
@@ -58,7 +59,9 @@ groups() ->
[basic,
process_win,
table_win,
- port_win_when_tab_not_initiated
+ port_win_when_tab_not_initiated,
+ remote_node,
+ blocking_start
]
}].
@@ -468,6 +471,34 @@ table_win(Config) when is_list(Config) ->
?P("table_win -> done"),
ok.
+remote_node(_Config) ->
+ {ok, Peer, _Node} = ?CT_PEER(),
+ ok = observer:start(Peer),
+ Peer = observer:get_active_node(),
+ observer:stop(),
+ ensure_observer_stopped(),
+ peer:stop(Peer).
+
+blocking_start(_Config) ->
+ _Pid = spawn(fun observer:start_and_wait/0),
+ MonitorRef = monitor(process, observer),
+ receive
+ {'DOWN', MonitorRef, _, _, _} ->
+ error(observer_stopped_unexpectedly)
+ after
+ 500 ->
+ ok
+ end,
+ observer:stop(),
+ ensure_observer_stopped(),
+ receive
+ {'DOWN', MonitorRef, _, _, _} ->
+ ok
+ after
+ 500 ->
+ error(observer_should_have_stopped)
+ end.
+
%% Test PR-1296/OTP-14151
%% Clicking a link to a port before the port tab has been activated the
%% first time crashes observer.
--
2.35.3