| 1 | 31 | ▶ | use utf8; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 31 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 31 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 31 | ▶ | use feature 'state'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | package DR::Tnt::Test; | ||||||||||||||
| 7 | 31 | ▶ | use DR::Tnt::Test::TntInstance; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 31 | ▶ | use IO::Socket::INET; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 31 | ▶ | use Test::More; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 31 | ▶ | use base qw(Exporter); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 31 | our @EXPORT = qw( | |||||||||||||
| 12 | free_port | ||||||||||||||
| 13 | tarantool_version | ||||||||||||||
| 14 | tarantool_version_check | ||||||||||||||
| 15 | start_tarantool | ||||||||||||||
| 16 | ); | ||||||||||||||
| 17 | |||||||||||||||
| 18 | |||||||||||||||
| 19 | sub tarantool_version() { | ||||||||||||||
| 20 | |||||||||||||||
| 21 | 30 | ▶ | local $SIG{__WARN__} = sub { }; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
Subroutine
tarantool_version: called CC=3 SCAR=16.0
Pod
undocumented
| |||||||||||||||
| 22 | 30 | ▶ | if (open my $fh, '-|', 'tarantool', '-V') { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | 0 | my $v = <$fh>; | |||||||||||||
| 24 | 0 | ▶ | return undef unless $v =~ /^Tarantool\s+(\S+)/; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 25 | 0 | return $1; | |||||||||||||
| 26 | } | ||||||||||||||
| 27 | 30 | return undef; | |||||||||||||
| 28 | } | ||||||||||||||
| 29 | |||||||||||||||
| 30 | |||||||||||||||
| 31 | sub tarantool_version_check($) { | ||||||||||||||
| 32 | 29 | ▶ | my ($version) = @_; | ||||||||||||
|
Subroutine
tarantool_version_check: called CC=9 SCAR=32.8
Pod
undocumented
| |||||||||||||||
| 33 | 29 | ▶ | $version ||= '1.6'; | ||||||||||||
|
Condition50%1/2
$version ||= "1.6"
MC/DC0%0/1
$version ||= "1.6"
$version
Truth table50%1/2
A
A= $version
| |||||||||||||||
| 34 | |||||||||||||||
| 35 | 29 | my $v = tarantool_version; | |||||||||||||
| 36 | |||||||||||||||
| 37 | 29 | ▶ | goto FAIL unless $v; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 38 | 0 | my @p = split /\./, $version; | |||||||||||||
| 39 | 0 | $v =~ s/-.*//; | |||||||||||||
| 40 | 0 | my @v = split /\./, $v; | |||||||||||||
| 41 | |||||||||||||||
| 42 | 0 | ▶ | for (my $i = 0; $i < @p; $i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | 0 | ▶ | last unless $i < @v; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 44 | 0 | ▶ | goto OK if $v[$i] > $p[$i]; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 45 | 0 | ▶ | goto FAIL unless $v[$i] >= $p[$i]; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | } | ||||||||||||||
| 47 | |||||||||||||||
| 48 | 0 | ▶ | goto FAIL unless @v >= @p; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 49 | |||||||||||||||
| 50 | 0 | OK: | |||||||||||||
| 51 | return; | ||||||||||||||
| 52 | |||||||||||||||
| 53 | FAIL: { | ||||||||||||||
| 54 | 29 | my $tb = Test::More->builder; | |||||||||||||
| 55 | 29 | my @passed = $tb->details; | |||||||||||||
| 56 | 29 | ▶ | for (my $i = @passed; $i < $tb->expected_tests; $i++) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 57 | 1243 | $tb->skip("tarantool $version is not found"); | |||||||||||||
| 58 | } | ||||||||||||||
| 59 | 29 | exit; | |||||||||||||
| 60 | } | ||||||||||||||
| 61 | |||||||||||||||
| 62 | } | ||||||||||||||
| 63 | |||||||||||||||
| 64 | |||||||||||||||
| 65 | |||||||||||||||
| 66 | sub free_port() { | ||||||||||||||
| 67 | 2 | ▶ | state $busy_ports = {}; | ||||||||||||
|
Subroutine
free_port: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||
| 68 | 2 | while( 1 ) { | |||||||||||||
| 69 | 2 | my $port = 10000 + int rand 30000; | |||||||||||||
| 70 | 2 | ▶ | next if exists $busy_ports->{ $port }; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 71 | 2 | ▶ | next unless IO::Socket::INET->new( | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 72 | Listen => 5, | ||||||||||||||
| 73 | LocalAddr => '127.0.0.1', | ||||||||||||||
| 74 | LocalPort => $port, | ||||||||||||||
| 75 | Proto => 'tcp', | ||||||||||||||
| 76 | (($^O eq 'MSWin32') ? () : (ReuseAddr => 1)), | ||||||||||||||
| 77 | ); | ||||||||||||||
| 78 | 2 | return $busy_ports->{ $port } = $port; | |||||||||||||
| 79 | } | ||||||||||||||
| 80 | } | ||||||||||||||
| 81 | |||||||||||||||
| 82 | sub start_tarantool { | ||||||||||||||
| 83 | 0 | ▶ | my %opts = @_; | ||||||||||||
|
Subroutine
start_tarantool: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 84 | 0 | $opts{-port} = free_port; | |||||||||||||
| 85 | 0 | DR::Tnt::Test::TntInstance->new(%opts); | |||||||||||||
| 86 | } | ||||||||||||||
| 87 | |||||||||||||||
| 88 | 31 | 1; | |||||||||||||