aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/test/server.erl
diff options
context:
space:
mode:
authorPiotr Dorobisz <[email protected]>2011-03-28 08:59:27 +0200
committerHenrik Nord <[email protected]>2011-08-30 15:22:19 +0200
commit871839b699bcb9b9b6bdbdcb01aa272bdf049882 (patch)
treeec2c279d52542b343c2c09a26a6936848b2cb801 /lib/observer/test/server.erl
parent7e3bbc9f57bab238d04545bc0cda70ca0bb0b9f8 (diff)
downloadotp-871839b699bcb9b9b6bdbdcb01aa272bdf049882.tar.gz
otp-871839b699bcb9b9b6bdbdcb01aa272bdf049882.tar.bz2
otp-871839b699bcb9b9b6bdbdcb01aa272bdf049882.zip
new tests for ttb module
Diffstat (limited to 'lib/observer/test/server.erl')
-rw-r--r--lib/observer/test/server.erl43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/observer/test/server.erl b/lib/observer/test/server.erl
new file mode 100644
index 0000000000..c1b1fea562
--- /dev/null
+++ b/lib/observer/test/server.erl
@@ -0,0 +1,43 @@
+-module(server).
+-compile(export_all).
+
+start() ->
+ application:start(runtime_tools),
+ Pid = spawn(?MODULE,loop,[[], 0]),
+ register(server,Pid).
+
+stop() ->
+ case lists:member(server, registered()) of
+ true ->
+ server ! stop;
+ false ->
+ ok
+ end.
+
+loop(Data, Num) ->
+ receive
+ {put,From,Ting} -> From ! ok,
+ received(From,Ting),
+ loop([Ting|Data], Num+1);
+ {get,From} -> From ! Data,
+ loop(Data, Num+1);
+ stop -> stopped;
+ clear -> loop([], Num+1);
+ {cnt, From} -> From ! Num,
+ loop(Data, Num)
+ end.
+
+counter() ->
+ server ! {cnt, self()},
+ receive
+ Num ->
+ Num
+ end.
+
+received(From, Thing) ->
+ case Thing of
+ never_send_this_atom ->
+ loop(Thing, 0);
+ _ ->
+ {return, 27, Thing, From}
+ end.