diff --git a/t/104_ipc.t b/t/104_ipc.t index 1412656..9afe615 100644 --- a/t/104_ipc.t +++ b/t/104_ipc.t @@ -1,34 +1,33 @@ use strict; +use warnings; use Test::More; -use Test::SharedFork; use File::Temp; +use ZMQ::LibZMQ3::LibZMQ2; +use ZMQ::Constants ':v2.1.11', qw(ZMQ_REP ZMQ_REQ); -BEGIN { - use_ok "ZMQ::LibZMQ3::LibZMQ2"; - use_ok "ZMQ::Constants", ":v2.1.11", qw(ZMQ_REP ZMQ_REQ); -} +my $path = File::Temp->new(UNLINK => 1)->filename; + +# Test ZMQ modules +use_ok "ZMQ::LibZMQ3::LibZMQ2"; +use_ok "ZMQ::Constants", ":v2.1.11", qw(ZMQ_REP ZMQ_REQ); -my $path = File::Temp->new(UNLINK => 0); -my $pid = Test::SharedFork->fork(); -if ($pid == 0) { - sleep 1; # hmmm, not a good way to do this... +my $pid = fork(); +if (not defined $pid) { + die "Could not fork: $!"; +} elsif ($pid == 0) { my $ctxt = zmq_init(); my $child = zmq_socket($ctxt, ZMQ_REQ ); zmq_connect( $child, "ipc://$path" ); zmq_send( $child, "Hello from $$" ); exit 0; -} elsif ($pid) { +} else { my $ctxt = zmq_init(); my $parent_sock = zmq_socket( $ctxt, ZMQ_REP); zmq_bind( $parent_sock, "ipc://$path" ); my $msg = zmq_recv( $parent_sock ); my $data = zmq_msg_data($msg); - if (! is $data, "Hello from $pid", "message is the expected message") { - diag "got '$data', expected 'Hello from $pid'"; - } + is($data, "Hello from $pid", "message is the expected message"); waitpid $pid, 0; -} else { - die "Could not fork: $!"; } unlink $path;