Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add ts_plugin behaviour. Fix all plugins (dump and parse_bidi not

implemented in mosts of them)
  • Loading branch information...
commit 437fa016535a532b707e3e2839a85949c0c3b4f7 1 parent 07a5532
Nicolas Niclausse nniclausse authored
20 Makefile.in
View
@@ -78,6 +78,9 @@ TEMPLATES_DIR = $(datadir)/$(TEMPLATES_SUBDIR)
MAN_DIR = $(datadir)/man/man1/
DOC_DIR = $(datadir)/doc/tsung
+# custom behaviours
+BEHAVIORS = ebin/ts_plugin.beam
+
BUILDER_LOG = /tmp/builder-tsung.log
ERLANG_LIB_DIR = $(libdir)/erlang/lib
@@ -418,17 +421,22 @@ ebin/%.beam: src/lib/%.erl $(INC_FILES)
@echo "Compiling $< ... "
@$(CC) -W0 $(OPT) -I $(INC) -I $(ERLANG_XMERL_DIR) -o ebin $<
-ebin/%.beam: src/$(APPLICATION)/%.erl $(INC_FILES)
+# to avoid circular dependency
+ebin/ts_plugin.beam: src/$(APPLICATION)/ts_plugin.erl $(INC_FILES)
+ @echo "Compiling $< ... "
+ @$(CC) $(OPT) -I $(INC) -I $(ERLANG_XMERL_DIR) -pa ebin -o ebin $<
+
+ebin/%.beam: src/$(APPLICATION)/%.erl $(INC_FILES) $(BEHAVIORS)
@echo "Compiling $< ... "
- @$(CC) $(OPT) -I $(INC) -I $(ERLANG_XMERL_DIR) -o ebin $<
+ @$(CC) $(OPT) -I $(INC) -I $(ERLANG_XMERL_DIR) -pa ebin -o ebin $<
-ebin/%.beam: src/$(RECORDER_APPLICATION)/%.erl $(INC_FILES)
+ebin/%.beam: src/$(RECORDER_APPLICATION)/%.erl $(INC_FILES) $(BEHAVIORS)
@echo "Compiling $< ... "
- @$(CC) $(OPT) -I $(INC) -I $(ERLANG_XMERL_DIR) -o ebin $<
+ @$(CC) $(OPT) -I $(INC) -I $(ERLANG_XMERL_DIR) -pa ebin -o ebin $<
-ebin/%.beam: src/$(CONTROLLER_APPLICATION)/%.erl $(INC_FILES)
+ebin/%.beam: src/$(CONTROLLER_APPLICATION)/%.erl $(INC_FILES) $(BEHAVIORS)
@echo "Compiling $< ... "
- @$(CC) $(OPT) -I $(INC) -I $(ERLANG_XMERL_DIR) -o ebin $<
+ @$(CC) $(OPT) -I $(INC) -I $(ERLANG_XMERL_DIR) -pa ebin -o ebin $<
%:%.sh
# Override makefile default implicit rule
10 src/tsung/ts_fs.erl
View
@@ -23,6 +23,8 @@
-vc('$Id: ts_erlang.erl,v 0.0 2009/08/20 16:31:58 nniclaus Exp $ ').
-author('nniclaus@sophia.inria.fr').
+-behavior(ts_plugin).
+
-include("ts_profile.hrl").
-include("ts_fs.hrl").
-include_lib("kernel/include/file.hrl").
@@ -31,6 +33,7 @@
add_dynparams/4,
get_message/1,
session_defaults/0,
+ dump/2,
parse/2,
parse_bidi/2,
parse_config/2,
@@ -185,8 +188,11 @@ parse({ts_utils, read_file_raw, [Path], {error,Reason}},State) ->
%% if the return value is nodata, otherwise the Data binary will be
%% sent back to the server immediately.
%% @end
-parse_bidi(_Data, _State) ->
- erlang:error(dummy_implementation).
+parse_bidi(Data, State) ->
+ ts_plugin:parse_bidi(Data,State).
+
+dump(A,B) ->
+ ts_plugin:dump(A,B).
%% @spec get_message(param()) -> Message::binary()|tuple()
%% @doc Creates a new message to send to the connected server.
10 src/tsung/ts_http.erl
View
@@ -26,6 +26,8 @@
-vc('$Id$ ').
-author('nicolas.niclausse@niclux.org').
+-behavior(ts_plugin).
+
-include("ts_profile.hrl").
-include("ts_http.hrl").
@@ -35,6 +37,7 @@
session_defaults/0,
dump/2,
parse/2,
+ parse_bidi/2,
parse_config/2,
decode_buffer/2,
new_session/0]).
@@ -74,6 +77,10 @@ decode_buffer(Buffer,#http{compressed={_,Comp}})->
?DebugF("decoded buffer: ~p",[RealBody]),
<<Headers/binary, "\r\n\r\n", RealBody/binary >>.
+%% @spec dump(protocol, {Request::ts_request(),Session::term(), Id::integer(),
+%% Host::string(),DataSize::integer()}) -> ok
+%% @doc log request and response summary
+%% @end
dump(protocol,{#ts_request{param=HttpReq},HttpResp,UserId,Server,Size})->
Status = case element(2,HttpResp#http.status) of
none -> "error_no_http_status"; % something is really wrong here ... http 0.9 response ?
@@ -137,6 +144,9 @@ get_message2(Req=#http_request{method=put}) ->
parse(Data, State) ->
ts_http_common:parse(Data, State).
+parse_bidi(Data, State) ->
+ ts_plugin:parse(Data, State).
+
%%----------------------------------------------------------------------
%% Function: parse_config/2
%%----------------------------------------------------------------------
7 src/tsung/ts_jabber.erl
View
@@ -30,6 +30,8 @@
-module(ts_jabber).
-author('nniclausse@hyperion').
+-behavior(ts_plugin).
+
-include("ts_profile.hrl").
-include("ts_jabber.hrl").
@@ -76,9 +78,8 @@ new_session() ->
get_message(Req=#jabber{}) ->
ts_jabber_common:get_message(Req).
-
-dump(_,_) ->
- ok.
+dump(A,B) ->
+ ts_plugin:dump(A,B).
%%----------------------------------------------------------------------
%% Function: parse/2
12 src/tsung/ts_ldap.erl
View
@@ -22,14 +22,17 @@
%%% Author : Pablo Polvorin <ppolv@yahoo.com.ar>
%%% Purpose : LDAP plugin
-
-module(ts_ldap).
+-behavior(ts_plugin).
+
-export([init_dynparams/0,
add_dynparams/4,
get_message/1,
session_defaults/0,
+ dump/2,
parse/2,
+ parse_bidi/2,
parse_config/2,
decode_buffer/2,
new_session/0
@@ -73,6 +76,12 @@ new_session() ->
%% recognize asn1...
+dump(A,B)->
+ ts_plugin:dump(A,B).
+
+parse_bidi(A, B) ->
+ ts_plugin:dump(A,B).
+
%%----------------------------------------------------------------------
%% Function: parse/2
%% Purpose: parse the response from the server and keep information
@@ -83,7 +92,6 @@ new_session() ->
parse(closed, State) ->
{State#state_rcv{ack_done = true, datasize=0}, [], true};
-
%% Shortcut, when using ssl i'm getting lots <<>> data. Also, next
%% clause is an infinite loop if data is <<>>
parse(<<>>,State) ->
12 src/tsung/ts_mysql.erl
View
@@ -31,6 +31,8 @@
-vc('$Id:$ ').
-author('gregoire.reboul@laposte.net').
+-behavior(ts_plugin).
+
-include("ts_profile.hrl").
-include("ts_mysql.hrl").
@@ -39,6 +41,8 @@
get_message/1,
session_defaults/0,
parse/2,
+ parse_bidi/2,
+ dump/2,
parse_config/2,
decode_buffer/2,
new_session/0]).
@@ -66,6 +70,12 @@ decode_buffer(Buffer,#mysql{}) ->
new_session() ->
#mysql{}.
+parse_bidi(Data, State) ->
+ ts_plugin:parse_bidi(Data,State).
+
+dump(A,B) ->
+ ts_plugin:dump(A,B).
+
%%----------------------------------------------------------------------
%% Function: get_message/21
%% Purpose: Build a message/request ,
@@ -212,7 +222,7 @@ get_salt(PacketBody) ->
{Salt2, _Rest7} = asciz_binary(Rest6,[]),
Salt ++ Salt2.
-make_auth(User, "", Database, Salt) ->
+make_auth(User, "", Database, _Salt) ->
Caps = ?LONG_PASSWORD bor ?LONG_FLAG bor ?PROTOCOL_41 bor ?TRANSACTIONS
bor ?SECURE_CONNECTION bor ?CONNECT_WITH_DB,
Maxsize = ?MAX_PACKET_SIZE,
9 src/tsung/ts_pgsql.erl
View
@@ -33,6 +33,8 @@
-vc('$Id$ ').
-author('nicolas.niclausse@niclux.org').
+-behavior(ts_plugin).
+
-include("ts_profile.hrl").
-include("ts_pgsql.hrl").
@@ -41,6 +43,8 @@
get_message/1,
session_defaults/0,
parse/2,
+ parse_bidi/2,
+ dump/2,
parse_config/2,
to_pairs/1,
find_pair/2,
@@ -104,6 +108,11 @@ get_message(#pgsql_request{type=authenticate, auth_method=AuthType}) ->
?LOGF("PGSQL: Authentication method not implemented ! [~p] ~n",[AuthType],?ERR),
<<>>.
+parse_bidi(Data, State) ->
+ ts_plugin:parse_bidi(Data,State).
+
+dump(A,B) ->
+ ts_plugin:dump(A,B).
%%----------------------------------------------------------------------
%% Function: parse/2
10 src/tsung/ts_raw.erl
View
@@ -30,6 +30,8 @@
-module(ts_raw).
-author('nniclausse@hyperion').
+-behavior(ts_plugin).
+
-include("ts_profile.hrl").
-include("ts_raw.hrl").
@@ -39,6 +41,8 @@
session_defaults/0,
subst/2,
parse/2,
+ parse_bidi/2,
+ dump/2,
parse_config/2,
decode_buffer/2,
new_session/0]).
@@ -91,6 +95,12 @@ get_message(#raw{data=Data})->
parse(_Data, State) ->
State.
+parse_bidi(Data, State) ->
+ ts_plugin:parse_bidi(Data,State).
+
+dump(A,B) ->
+ ts_plugin:dump(A,B).
+
%%
parse_config(Element, Conf) ->
ts_config_raw:parse_config(Element, Conf).
7 src/tsung/ts_shell.erl
View
@@ -23,6 +23,8 @@
-vc('$Id: ts_erlang.erl,v 0.0 2009/08/20 16:31:58 nniclaus Exp $ ').
-author('nniclaus@sophia.inria.fr').
+-behaviour(ts_plugin).
+
-include("ts_profile.hrl").
-include("ts_shell.hrl").
-include_lib("kernel/include/file.hrl").
@@ -31,6 +33,7 @@
add_dynparams/4,
get_message/1,
session_defaults/0,
+ dump/2,
parse/2,
parse_bidi/2,
parse_config/2,
@@ -123,6 +126,10 @@ add_dynparams(#shell_dyndata{}, Param, _HostData) ->
subst(Req=#shell{command=Cmd,args=Args}, DynVars) ->
Req#shell{command=ts_search:subst(Cmd,DynVars),args=ts_search:subst(Args,DynVars)}.
+
+dump(A,B) ->
+ ts_plugin:dump(A,B).
+
%% @spec parse(Data::client_data(), State) -> {NewState, Opts, Close}
%% State = #state_rcv{}
%% Opts = proplist()
10 src/tsung/ts_webdav.erl
View
@@ -22,6 +22,8 @@
-vc('$Id: ts_webdav.erl,v 0.0 2008/03/12 12:47:07 nniclaus Exp $ ').
-author('nicolas.niclausse@niclux.org').
+-behaviour(ts_plugin).
+
-include("ts_profile.hrl").
-include("ts_http.hrl").
@@ -30,6 +32,8 @@
get_message/1,
session_defaults/0,
parse/2,
+ parse_bidi/2,
+ dump/2,
parse_config/2,
decode_buffer/2,
new_session/0]).
@@ -63,6 +67,12 @@ get_message(Req=#http_request{method=Method}) when Method == mkcol->
get_message(Req) ->
ts_http:get_message(Req).
+parse_bidi(Data, State) ->
+ ts_http:parse_bidi(Data,State).
+
+dump(A,B) ->
+ ts_http:dump(A,B).
+
parse(Data, State) ->
ts_http_common:parse(Data, State).
parse_config(Element, Conf) ->

2 comments on commit 437fa01

Yurii Rashkovskii

This likely caused tsung to become unbuildable:

remote: Counting objects: 7261, done.
Receiving objects: 100% (7261/7261), 1.97 MiB | 586 KiB/s, done.
Resolving deltas: 100% (5617/5617), done.
[Building...]
checking for sed... /usr/bin/sed
checking for erlc... /usr/local/Cellar/erlang/R14B02/lib/erlang/erts-5.8.3/bin/erlc
checking for erl... /usr/local/Cellar/erlang/R14B02/lib/erlang/erts-5.8.3/bin/erl
checking for erlc... /usr/local/Cellar/erlang/R14B02/lib/erlang/erts-5.8.3/bin/erlc
checking for erl... /usr/local/Cellar/erlang/R14B02/lib/erlang/erts-5.8.3/bin/erl
checking for Erlang/OTP root directory... /usr/local/Cellar/erlang/R14B02/lib/erlang
checking for Erlang/OTP '-hybrid' option... no
checking for Erlang/OTP 'xmerl' library subdirectory... /usr/local/Cellar/erlang/R14B02/lib/erlang/lib/xmerl-1.2.8
checking for Erlang/OTP 'xmerl' library version... 1.2.8
checking for Erlang/OTP 'ssl' library subdirectory... /usr/local/Cellar/erlang/R14B02/lib/erlang/lib/ssl-4.1.4
checking for Erlang/OTP 'ssl' library version... 4.1.4
checking for Erlang/OTP 'crypto' library subdirectory... /usr/local/Cellar/erlang/R14B02/lib/erlang/lib/crypto-2.0.2.1
checking for Erlang/OTP 'crypto' library version... 2.0.2.1
checking for Erlang/OTP 'public_key' library subdirectory... /usr/local/Cellar/erlang/R14B02/lib/erlang/lib/public_key-0.11
checking for Erlang/OTP 'public_key' library version... 0.11
checking if Erlang/OTP SSL application is running fine... yes
checking if Erlang/OTP crypto application is running fine... yes
checking if orelse is allowed in guards... yes
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
configure: Storing library files in /usr/local/agner/packages/tsung-@master/lib/tsung
configure: Storing data files in /usr/local/agner/packages/tsung-@master/share/tsung
configure: creating ./config.status
config.status: creating Makefile
config.status: creating tsung.spec
config.status: creating tsung.sh
config.status: creating tsung-recorder.sh
config.status: creating examples/.xml
config.status: creating src/tsung_stats.pl
config.status: WARNING: 'src/tsung_stats.pl.in' seems to ignore the --datarootdir setting
config.status: creating src/tsung-plotter/tsplot.py
config.status: creating src/log2tsung.pl
config.status: WARNING: 'src/log2tsung.pl.in' seems to ignore the --datarootdir setting
config.status: creating src/tsung_controller/tsung_controller.app.src
config.status: creating src/tsung_recorder/tsung_recorder.app.src
config.status: creating src/tsung/tsung.app.src
config.status: creating src/tsung-rrd.pl
make: *
* No rule to make target src/tsung/ts_plugin.erl', needed byebin/ts_plugin.beam'. Stop.
ERROR: Build failed

Nicolas Niclausse
Collaborator
Please sign in to comment.
Something went wrong with that request. Please try again.