X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=test%2Fscripts.test;h=ff0e565fd88351ba17c53e99e75125b0b5704e11;hb=df716df33af8e9a5b93d573a023ecd7fc24d9a03;hp=de69ad3a6a1fa9a233d1d6c11db8ecebb79c5e79;hpb=0af3dcf7a838dede699194c02444f1607644bb28;p=tinc diff --git a/test/scripts.test b/test/scripts.test index de69ad3a..ff0e565f 100755 --- a/test/scripts.test +++ b/test/scripts.test @@ -1,110 +1,133 @@ #!/bin/sh -. ./testlib.sh +# shellcheck disable=SC1090 +. "$TESTLIB_PATH" -# 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 +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" <