use Test2::V0 -no_srand => 1; BEGIN { skip_all 'Test requires a threading Perl' unless eval q{ use threads; 1 } } use FFI::CheckLib; use FFI::Platypus; use Config; my $ffi = FFI::Platypus->new(lib => find_lib(lib => 'test', symbol => 'f0', libpath => 't/ffi' )); sub f0 { $ffi->function(f0 => ['uint8'] => 'uint8')->call(@_); } sub otherthread { my $val = f0(22); undef $ffi; $val; } ok 1; is(threads->create(\&otherthread)->join(), 22, 'works in a thread'); is f0(24), 24, 'works in main thread'; done_testing;