Browse files

tests: try to set a shorter path for Unix domain sockets

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...
1 parent c4c880c commit fbcf6aa641e5827da48a3b6776c9897de123b405 Eric Wong committed Nov 15, 2011
Showing with 11 additions and 2 deletions.
  1. +11 −2 t/test-lib.sh
View
13 t/test-lib.sh
@@ -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"
;;

0 comments on commit fbcf6aa

Please sign in to comment.