Skip to content

Commit

Permalink
inet_dns: support TSIG (TO BE SQUASHED)
Browse files Browse the repository at this point in the history
Differentiate betwen Skip: and Error: in run-ns.
Skip: for no name server found or too old
Error: for any startup or configure error
  • Loading branch information
jimdigriz authored and RaimoNiskanen committed Jul 14, 2023
1 parent 05a63a7 commit af5b741
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
20 changes: 14 additions & 6 deletions lib/kernel/test/inet_res_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,17 @@ init_per_testcase(Func, Config) ->
%% dbg:p(all, c),
%% dbg:tpl(inet_res, query_nss_res, cx),
?P("init_per_testcase -> done:"
"~n NsSpec: ~p"
"~n Lookup: ~p", [NsSpec, Lookup]),
"~n NsSpec: ~p"
"~n Lookup: ~p", [NsSpec, Lookup]),
[{nameserver, NsSpec}, {res_lookup, Lookup} | Config]
catch
SkipReason ->
?P("init_per_testcase -> caught:"
"~n SkipReason: ~p", [SkipReason]),
{skip, SkipReason}
?P("init_per_testcase -> skip: ~p", [SkipReason]),
{skip, SkipReason};
Class : Reason : Stacktrace ->
?P("init_per_testcase -> ~w: ~p"
"~n ~p~n", [Class, Reason, Stacktrace]),
{fail, Reason}
end.

end_per_testcase(_Func, Config) ->
Expand Down Expand Up @@ -255,11 +258,16 @@ ns_start(ZoneDir, PrivDir, NS, P) ->
"Running: "++_ ->
?P("ns_start -> running"),
{ZoneDir,NS,P};
"Skip: "++Reason ->
?P("ns_start -> skip: "
"~n ~p", [Reason]),
ns_printlog(filename:join([PrivDir,ZoneDir,?LOG_FILE])),
throw(Reason);
"Error: "++Error ->
?P("ns_start -> error: "
"~n ~p", [Error]),
ns_printlog(filename:join([PrivDir,ZoneDir,?LOG_FILE])),
throw(Error);
error(Error);
_X ->
?P("ns_start -> retry"),
ns_start(ZoneDir, PrivDir, NS, P)
Expand Down
15 changes: 12 additions & 3 deletions lib/kernel/test/inet_res_SUITE_data/run-ns
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ PATH=/usr/sbin:/sbin:/usr/bin:/bin
SHELL=/bin/sh
export PATH SHELL

NS=knotd
LOG_FILE=ns.log
CONF_FILE=knot.conf
INC_FILE=knot_inc.conf
Expand All @@ -59,6 +60,12 @@ error () {
exit $r
}

skip () {
r=$?
echo "Skip: $*"
exit $r
}

ME="$0"
SELF=$$

Expand All @@ -83,16 +90,18 @@ test -f "$SRCDIR/$INC_FILE" || \
DIR="$3"

# Locate name server and check version.
NS=knotd
NS_STARTED="notice: $NS started"
for n in /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin
do
test -x "$n/$NS" && { NS="$n/$NS"; break; }
done

NS_VER="`"$NS" -V 2>&1`" || \
error "Name server not found!"
skip "Name server ($NS) not found!"
NS_VER="`echo "$NS_VER" | head -1`"
{ echo "$NS_VER" |
grep -q -e ' 2[.]9[.]' -e ' 2[.][1-9][0-9][0-9]*[.]' \
-e ' [3-9][.]' -e ' [1-9][0-9][0-9]*[.]'
} || skip "Name server $NS_VER < 2.9"

# Create working directory and cd to it
mkdir "$DIR" >/dev/null 2>&1
Expand Down

0 comments on commit af5b741

Please sign in to comment.