#!/usr/bin/env escript %% %% %CopyrightBegin% %% %% Copyright Ericsson AB 2018-2019. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. %% You may obtain a copy of the License at %% %% http://www.apache.org/licenses/LICENSE-2.0 %% %% Unless required by applicable law or agreed to in writing, software %% distributed under the License is distributed on an "AS IS" BASIS, %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %% See the License for the specific language governing permissions and %% limitations under the License. %% %% %CopyrightEnd% %% %% ========================================================================== %% %% This is a simple wrapper escript on top of the socket ttest program(s). %% The idea is to make it simple to run in a normal shell (bash). %% %% ========================================================================== -define(SECS(I), timer:seconds(I)). -define(CLIENT_MSG_1_MAX_OUTSTANDING, 100). -define(CLIENT_MSG_2_MAX_OUTSTANDING, 10). -define(CLIENT_MSG_3_MAX_OUTSTANDING, 1). main(Args) -> State = process_args(Args), exec(State), ok. usage(ErrorString) when is_list(ErrorString) -> eprint(ErrorString), usage(), erlang:halt(0). usage() -> io:format("usage: ~s [options]" "~n" "~n This erlang script is used to start the (e)socket ttest " "~n units (server or client)." "~n" "~n options: " "~n --help Display this info and exit. " "~n --server [server-options] Start a server. " "~n There are no mandatory server options." "~n --client client-options Start a client" "~n Some client options are mandatory and" "~n others optional." "~n --domain local | inet | inet6" "~n Which domain to use." "~n Only valid for server." "~n Defaults to: inet" "~n --async Asynchronous mode (Timeout = nowait)" "~n This option is only valid for transport = sock." "~n Also, its only used when active =/= false." "~n --active boolean() | once." "~n Valid for both client and server." "~n Defaults to: false" "~n --transport Which transport to use: gen|sock[:plain|msg]" "~n gen: gen_tcp" "~n sock: socket" "~n plain: recv/send (default)" "~n msg: recvmsg/sendmsg" "~n Defaults to: sock:plain" "~n --scon :| Server info." "~n The address part is in the standard form:" "~n \"a.b.c.d\"." "~n is used for Unix Domain sockets (local)." "~n Only valid, and mandatory, for client." "~n --msg-id <1|2|3> Choose which message to use during the test." "~n Basically: " "~n 1: small" "~n 2: medium" "~n 3: large" "~n Defaults to: 1" "~n --max-outstanding How many messages to send before waiting for" "~n a reply." "~n Valid only for client." "~n Defaults to: " "~n MsgID 1: 100" "~n MsgID 2: 10" "~n MsgID 3: 1" "~n --runtime