mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
generic/131: dynamically allocate tcp listen port to avoid port clashes
Current port selection algorithm is bound to have port clashes. To eliminate clashes, let server pick an unused port and report it on stdout. Signed-off-by: Tahsin Erdogan <tahsin@google.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
committed by
Eryu Guan
parent
795ea36a18
commit
b936f63c27
+7
-10
@@ -49,21 +49,18 @@ _require_test_fcntl_advisory_locks
|
||||
|
||||
TESTFILE=$TEST_DIR/lock_file
|
||||
|
||||
# Grab a port which is hopefully unused
|
||||
if [ $$ -gt 1024 -a $$ -lt 32000 ]; then
|
||||
PORT=$$
|
||||
elif [ $$ -lt 1024 ]; then
|
||||
PORT=$(($$+1024))
|
||||
elif [ $$ -gt 32000 ]; then
|
||||
PORT=$(($$%30000+1024))
|
||||
fi
|
||||
|
||||
# Start the server
|
||||
src/locktest -p $PORT $TESTFILE 2>&1 > $TEST_DIR/server.out &
|
||||
src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out &
|
||||
locktest_pid1=$!
|
||||
|
||||
sleep 1
|
||||
|
||||
PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}')
|
||||
if [ -z $PORT ]; then
|
||||
echo "Could not get server port"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start the client
|
||||
src/locktest -p $PORT -h localhost $TESTFILE 2>&1 > $TEST_DIR/client.out
|
||||
locktest_pid2=$!
|
||||
|
||||
Reference in New Issue
Block a user