⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 11-snapshot.t

📁 SinFP是一种新的识别对方计算机操作系统类型的工具
💻 T
字号:
#!/usr/bin/perl -Tuse strict;use Test::More;use Net::Pcap;use lib 't';use Utils;my @sizes = (128, 512, 1024, 2048, 4096, 8192, int(10000*rand), int(10000*rand), int(10000*rand), int(10000*rand));  # snapshot sizesplan skip_all => "must be run as root" unless is_allowed_to_use_pcap();plan skip_all => "no network device available" unless find_network_device();plan tests => @sizes * 2 + 2;eval "use Test::Exception"; my $has_test_exception = !$@;my($dev,$pcap,$snapshot,$err) = ('','','','');# Testing error messagesSKIP: {    skip "Test::Exception not available", 2 unless $has_test_exception;    # snapshot() errors    throws_ok(sub {        Net::Pcap::snapshot()    }, '/^Usage: Net::Pcap::snapshot\(p\)/',        "calling snapshot() with no argument");    throws_ok(sub {        Net::Pcap::snapshot(0)    }, '/^p is not of type pcap_tPtr/',        "calling snapshot() with incorrect argument type");}# Find a device$dev = find_network_device();for my $size (@sizes) {    # Open the device    $pcap = Net::Pcap::open_live($dev, $size, 1, 0, \$err);    # Testing snapshot()    $snapshot = 0;    eval { $snapshot = Net::Pcap::snapshot($pcap) };    is( $@, '', "snapshot()" );    is( $snapshot, $size, " - snapshot has the expected size" );    Net::Pcap::close($pcap);}

⌨️ 快捷键说明

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