X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=test%2Fscripts.test;h=9ef6416442f520f8514c29fd6b2e8ec042904934;hb=4fbaf80d56a418ebd23eeace9053fa8f20097f77;hp=3b3f27493e063aa6d22a5d229795592e26109b5e;hpb=70fed5f7ffdeb0416ee6b77881098faab9a7cd47;p=tinc diff --git a/test/scripts.test b/test/scripts.test index 3b3f2749..9ef64164 100755 --- a/test/scripts.test +++ b/test/scripts.test @@ -1,112 +1,133 @@ #!/bin/sh +# shellcheck source=testlib.sh . ./testlib.sh -# Initialize server node +echo [STEP] Initializing server node -$tinc $c1 <$d1/$script << EOF -#!/bin/sh -echo $script \$NETNAME,\$NAME,\$DEVICE,\$IFACE,\$NODE,\$REMOTEADDRESS,\$REMOTEPORT,\$SUBNET,\$WEIGHT,\$INVITATION_FILE,\$INVITATION_URL,\$DEBUG >>$OUT +echo [STEP] Setting up scripts + +OUT=$DIR_FOO/scripts.out +rm -f "$OUT" + +for script in \ + tinc-up tinc-down \ + host-up host-down \ + subnet-up subnet-down \ + hosts/foo-up hosts/foo-down \ + hosts/bar-up hosts/bar-down \ + invitation-created invitation-accepted; do + + commands=$( + cat <>'$OUT' "$script" "$TINC_SCRIPT_VARS" EOF -chmod u+x $d1/$script + ) + + create_script foo "$script" "$commands" done -# Start server node +echo [STEP] Starting server node + +start_tinc foo -n netname +wait_script foo subnet-up 2 +echo foo-started >>"$OUT" + +echo [STEP] Inviting client node -$tinc -n netname $c1 start $r1 +url=$(tinc foo -n netname2 invite bar) +file=$(basename "$(find "$DIR_FOO/invitations" -type f ! -name ed25519_key.priv)") -echo foo-started >>$OUT +if is_windows; then + file=$(cygpath --unix -- "$file") +fi -# Invite client node +wait_script foo invitation-created +echo bar-invited >>"$OUT" -url=`$tinc -n netname2 $c1 invite bar` -file=`cd $d1/invitations; ls | grep -v ed25519_key.priv` -echo bar-invited >>$OUT -$tinc -n netname3 $c2 join $url -echo bar-joined >>$OUT +echo [STEP] Joining client node -# Start and stop client node +tinc bar -n netname3 join "$url" +wait_script foo invitation-accepted +echo bar-joined >>"$OUT" -$tinc $c2 << EOF +echo [STEP] Starting client node + +tinc bar <>$OUT - -$tinc $c1 debug 4 -$tinc $c2 stop - -sleep 1 - -echo bar-stopped >>$OUT - -$tinc $c1 debug 5 -$tinc $c2 start $r2 +start_tinc bar +wait_script foo subnet-up 2 +echo bar-started-1 >>"$OUT" -sleep 1 +tinc foo debug 4 +tinc bar stop +wait_script foo subnet-down 2 +echo bar-stopped >>"$OUT" -echo bar-started >>$OUT +tinc foo debug 5 +start_tinc bar +wait_script foo subnet-up 2 +echo bar-started-2 >>"$OUT" -# Stop server node +echo [STEP] Stop server node -$tinc $c1 stop -sleep 1 -$tinc $c2 stop +tinc foo stop +tinc bar stop +wait_script foo tinc-down -# Check if the script output is what is expected +echo [STEP] Check if the script output is what is expected -cat >$OUT.expected << EOF +cat >"$OUT.expected" <