18-open_dead.t

来自「SinFP是一种新的识别对方计算机操作系统类型的工具」· T 代码 · 共 32 行

T
32
字号
#!/usr/bin/perl -Tuse strict;use Test::More;use Net::Pcap;use lib 't';use Utils;plan skip_all => "pcap_open_dead() is not available" unless is_available('pcap_open_dead');plan tests => 5;eval "use Test::Exception"; my $has_test_exception = !$@;my($pcap,$datalink) = ('',0);  # datalink == DLT_NULL => no link-layer encapsulation# Testing error messagesSKIP: {    skip "Test::Exception not available", 1 unless $has_test_exception;    # open_dead() errors    throws_ok(sub {        Net::Pcap::open_dead()    }, '/^Usage: Net::Pcap::open_dead\(linktype, snaplen\)/',       "calling open_dead() with no argument");}# Testing open_dead()eval { $pcap = Net::Pcap::open_dead($datalink, 1024) };is( $@, '', "open_dead()" );ok( defined $pcap, " - \$pcap is defined" );isa_ok( $pcap, 'SCALAR', " - \$pcap" );isa_ok( $pcap, 'pcap_tPtr', " - \$pcap" );

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?