Skip to content

Commit

Permalink
Merge pull request #9 from evnu/add_codepatha
Browse files Browse the repository at this point in the history
Add -pa and -pz command-line parameters
  • Loading branch information
kostis committed Mar 11, 2014
2 parents c2404cd + a155773 commit bffe113
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/concuerror.erl
Expand Up @@ -132,6 +132,14 @@ cliAux(Options) ->
?NT_OPTIONS = ets:new(?NT_OPTIONS, [named_table, public, set]),
ets:insert(?NT_OPTIONS, Options),
%% Handle options
case lists:keyfind('pa', 1, Options) of
false -> ok;
{'pa', PAs} -> addToCodePath(fun code:add_patha/1, PAs)
end,
case lists:keyfind('pz', 1, Options) of
false -> ok;
{'pz', PZs} -> addToCodePath(fun code:add_pathz/1, PZs)
end,
case lists:keyfind('gui', 1, Options) of
{'gui'} -> gui(Options);
false ->
Expand Down Expand Up @@ -172,6 +180,17 @@ cliAux(Options) ->
concuerror_util:timer_destroy(),
'true'.

addToCodePath(_Fun, []) ->
ok;
addToCodePath(Fun, [Path|Paths]) ->
case Fun(Path) of
true -> addToCodePath(Fun, Paths);
{error, bad_directory} ->
io:format("~s: cannot add bad_directory \"~s\" to code path\n",
[?APP_STRING, Path]),
addToCodePath(Fun, Paths)
end.

%% Parse command line arguments
parse([], Options) ->
Options;
Expand Down Expand Up @@ -421,6 +440,14 @@ parse([{Opt, Param} | Args], Options) ->
%% erl flag (ignore it)
parse(Args, Options);

"pa" ->
NewOptions = keyAppend('pa', 1, Options, Param),
parse(Args, NewOptions);

"pz" ->
NewOptions = keyAppend('pa', 1, Options, Param),
parse(Args, NewOptions);

Other ->
Msg = io_lib:format("unrecognised concuerror flag: -~s", [Other]),
{'error', 'arguments', Msg}
Expand Down Expand Up @@ -477,6 +504,8 @@ help() ->
" -t|--target module function [args]\n"
" Specify the function to execute\n"
" -f|--files modules Specify the files (modules) to instrument\n"
" -pa Dir Add Dir to the beginning of the code path\n"
" -pz Dir Add Dir to the end of the code path\n"
" -o|--output file Specify the output file (default results.txt)\n"
" -p|--preb number|inf Set preemption bound (default is 2)\n"
" -I include_dir Pass the include_dir to concuerror\n"
Expand Down

0 comments on commit bffe113

Please sign in to comment.