#!/usr/bin/perl

use IO::Socket::UNIX;
use File::Temp qw /tempdir/;

# Create a tempfile name with same length as "path"
my $tmpdir = tempdir( CLEANUP => 0);
my $testfile = $tmpdir . "/" . "x" x 3;
my $truncated = 0;
my $sock;
eval {
    $sock= new IO::Socket::UNIX
    (
        Local => $testfile,
        Listen => 1,
    );
    $truncated= 1; # Be negatvie
    die "Could not create UNIX domain socket: $!" unless defined $sock;
    die "UNIX domain socket path was truncated" unless ($testfile eq $sock->hostpath());
    $truncated = 0;
};

print $truncated ? "FAILED\n" : "SUCCESS\n";
print "$@\n" if $@;
