summaryrefslogtreecommitdiff
path: root/verifycert.erl
diff options
context:
space:
mode:
authorMagnus Ahltorp <map@kth.se>2016-10-13 15:10:20 +0200
committerMagnus Ahltorp <map@kth.se>2016-10-13 15:16:29 +0200
commitc1dfe32e2ba948e62535102ab6dbafa60c3c6eda (patch)
treef645ce96cb3ec311115f3a4bba410132ca1dc2e9 /verifycert.erl
parent4213c3f7987b5f2a01fb12049ae7d5b84645640d (diff)
Make tests run independently from cwdlarge-tests3
Diffstat (limited to 'verifycert.erl')
-rwxr-xr-xverifycert.erl25
1 files changed, 24 insertions, 1 deletions
diff --git a/verifycert.erl b/verifycert.erl
index fa0e4e4..a606d1c 100755
--- a/verifycert.erl
+++ b/verifycert.erl
@@ -1,6 +1,5 @@
#!/usr/bin/env escript
%% -*- erlang -*-
-%%! -pa lib/catlfish-0.9.0-dev.ez/catlfish-0.9.0-dev/ebin -pa lib/lager-2.1.1.ez/lager-2.1.1/ebin -pa lib/plop-0.9.0-dev.ez/plop-0.9.0-dev/ebin
write_reply(Bin) ->
Length = size(Bin),
@@ -34,6 +33,30 @@ loop(RootCerts) ->
loop(RootCerts)
end.
+add_lib(Dirs, Name) ->
+ add_lib(Dirs, Dirs, Name).
+add_lib(AllDirs, [], Name) ->
+ {ok, Cwd} = file:get_cwd(),
+ io:format(standard_error,
+ "Could not add lib ~p: tried directories ~p cwd: ~p~n",
+ [Name, AllDirs, Cwd]),
+ halt(1);
+add_lib(AllDirs, [Dir | Rest], Name) ->
+ Path = Dir ++ "/" ++ Name ++ ".ez/" ++ Name ++ "/ebin",
+ case code:add_path(Path) of
+ true ->
+ ok;
+ {error, bad_directory} ->
+ add_lib(AllDirs, Rest, Name)
+ end.
+
main([KnownRoots]) ->
+ [ScriptFile | _] = init:get_plain_arguments(),
+ BaseDir = filename:dirname(ScriptFile),
+ LibDirs = [BaseDir ++ "/../lib", "../lib"],
+ add_lib(LibDirs, "catlfish-0.9.0-dev"),
+ add_lib(LibDirs, "lager-2.1.1"),
+ add_lib(LibDirs, "plop-0.9.0-dev"),
+
Certs = x509:read_pemfiles_from_dir(KnownRoots),
loop(Certs).