Skip to content

Commit

Permalink
tests: try to set a shorter path for Unix domain sockets
Browse files Browse the repository at this point in the history
We're only allowed 108 bytes for Unix domain sockets.
mktemp(1) usually generates path names of reasonable length
and we rely on it anyways.
  • Loading branch information
Eric Wong committed Nov 16, 2011
1 parent c4c880c commit fbcf6aa
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions t/test-lib.sh
Expand Up @@ -38,20 +38,29 @@ rtmpfiles () {
for id in "$@"
do
name=$id
_tmp=$t_pfx.$id
eval "$id=$_tmp"

case $name in
*fifo)
_tmp=$t_pfx.$id
eval "$id=$_tmp"
rm -f $_tmp
mkfifo $_tmp
T_RM_LIST="$T_RM_LIST $_tmp"
;;
*socket)
_tmp="$(mktemp -t $id.$$.XXXXXXXX)"
if test $(printf "$_tmp" |wc -c) -gt 108
then
echo >&2 "$_tmp too long, tests may fail"
echo >&2 "Try to set TMPDIR to a shorter path"
fi
eval "$id=$_tmp"
rm -f $_tmp
T_RM_LIST="$T_RM_LIST $_tmp"
;;
*)
_tmp=$t_pfx.$id
eval "$id=$_tmp"
> $_tmp
T_OK_RM_LIST="$T_OK_RM_LIST $_tmp"
;;
Expand Down

0 comments on commit fbcf6aa

Please sign in to comment.