diff --git a/repos/os/run/nic_router_flood.run b/repos/os/run/nic_router_flood.run index 9ec3fb735..8d0837283 100644 --- a/repos/os/run/nic_router_flood.run +++ b/repos/os/run/nic_router_flood.run @@ -10,6 +10,10 @@ if {![have_include power_on/qemu] || exit 0 } +proc min_duration_sec { } { return 8 } +proc pause_sec { } { return 5 } +proc good_dst_ip { } { return "10.0.2.2" } +proc bad_dst_ip { } { return "10.0.0.123" } set build_components { core @@ -19,15 +23,14 @@ set build_components { server/nic_router test/net_flood app/ping + server/report_rom + server/dynamic_rom } proc gpio_drv { } { if {[have_spec rpi] && [have_spec hw]} { return hw_gpio_drv } if {[have_spec rpi] && [have_spec foc]} { return foc_gpio_drv } return gpio_drv } -proc good_dst_ip { } { return "10.0.2.2" } -proc bad_dst_ip { } { return "10.0.0.123" } - lappend_if [have_spec gpio] build_components drivers/gpio source ${genode_dir}/repos/base/run/platform_drv.inc @@ -45,6 +48,7 @@ append config { + @@ -61,6 +65,7 @@ append config { append_platform_drv_config append_if [have_spec gpio] config " + @@ -68,6 +73,7 @@ append_if [have_spec gpio] config " " append config { + @@ -80,29 +86,35 @@ append config { } [nic_drv_config] { + + + + + + - + - - - - + + + - + - + @@ -114,51 +126,92 @@ append config { + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + @@ -181,6 +234,8 @@ append boot_modules { ld.lib.so nic_router ping + report_rom + dynamic_rom } # platform-specific modules @@ -196,4 +251,158 @@ append_if [have_spec lan9118] qemu_args " -net nic,model=lan9118 " append qemu_args " -net user -nographic " -run_genode_until {.*ping\] 64 bytes from 10\.0\.2\.2: icmp_seq=30 .*\n} 120 + +######################### +## Execute and analyse ## +######################### + +proc test {} { + + global output + global serial_id + global ram_quota_1 + global cap_quota_1 + global used_ram_1 + global used_cap_1 + global shared_ram_1 + global shared_cap_1 + + set ram_quota_2 {} + set cap_quota_2 {} + set used_ram_2 {} + set used_cap_2 {} + set shared_ram_2 {} + set shared_cap_2 {} + + + ################ + ## Test phase ## + ################ + + set output {} + set desired_str {} + append desired_str {.*child "test_ping" exited with exit value 0.*\n} + append desired_str {.*child "test_fl.*" exited with exit value 0.*\n} + append desired_str {.*child "test_fl.*" exited with exit value 0.*\n} + append desired_str {.*child "test_fl.*" exited with exit value 0.*\n} + + run_genode_until $desired_str [expr [min_duration_sec] * 2] $serial_id + + if {[regexp {refused_for} $output]} { + puts stderr "*** Error: connections were refused during the test" + exit -1 + } + if {[regexp {drop packet} $output]} { + puts stderr "*** Error: packets were dropped during the test" + exit -1 + } + if {[regexp {Warning: (?!submitting signal failed)} $output]} { + puts stderr "*** Error: unexpected warnings during test" + exit -1 + } + if {[regexp {Error} $output]} { + puts stderr "*** Error: unexpected errors during test" + exit -1 + } + + + ################# + ## Pause phase ## + ################# + + set output {} + set desired_str {} + append desired_str {.* 4096} { + puts stderr "*** Error: routers shared ram quota bigger than expected" + exit -1 + } + if {$shared_cap_1 > 1} { + puts stderr "*** Error: routers shared cap quota bigger than expected" + exit -1 + } + + set ram_quota_1 $ram_quota_2 + set cap_quota_1 $cap_quota_2 + set used_ram_1 $used_ram_2 + set used_cap_1 $used_cap_2 + set shared_ram_1 $shared_ram_2 + set shared_cap_1 $shared_cap_2 +} + + +################ +## Init phase ## +################ + +global output +global serial_id +global ram_quota_1 +global cap_quota_1 +global used_ram_1 +global used_cap_1 +global shared_ram_1 +global shared_cap_1 + +set ram_quota_1 {} +set cap_quota_1 {} +set used_ram_1 {} +set used_cap_1 {} +set shared_ram_1 {} +set shared_cap_1 {} + +set desired_str {} +append desired_str {.* + @@ -19,6 +20,7 @@ + diff --git a/repos/os/src/test/net_flood/main.cc b/repos/os/src/test/net_flood/main.cc index 6f14012e5..df267a0a7 100644 --- a/repos/os/src/test/net_flood/main.cc +++ b/repos/os/src/test/net_flood/main.cc @@ -65,6 +65,9 @@ class Main : public Nic_handler, Protocol const _protocol { _config.attribute_value("protocol", Protocol::ICMP) }; Port _dst_port { FIRST_DST_PORT }; size_t _ping_sz { _init_ping_sz() }; + unsigned long _ping_cnt { 0 }; + unsigned long _sec { _config.attribute_value("sec", 10UL) }; + unsigned long _time_us { 0 }; size_t _init_ping_sz() const; @@ -264,7 +267,7 @@ void Main::_broadcast_arp_request(Ipv4_address const &dst_ip) } -void Main::_send_ping(Duration) +void Main::_send_ping(Duration time) { /* if we do not yet know the Ethernet destination, request it via ARP */ if (_dst_mac == Mac_address()) { @@ -363,9 +366,23 @@ void Main::_send_ping(Duration) ip.total_length(size_guard.head_size() - ip_off); ip.update_checksum(); }); + _ping_cnt++; } } catch (Net::Packet_stream_source::Packet_alloc_failed) { } + unsigned long const new_time_us = time.trunc_to_plain_us().value; + if (new_time_us - _time_us > 1000000) { + if (!_ping_cnt) { + error("test failed (could not send packet for a second)"); + _env.parent().exit(-1); + } + log("alive (", _ping_cnt, " pkt/sec)"); + if (!--_sec) { + _env.parent().exit(0); } + + _ping_cnt = 0; + _time_us = new_time_us; + } }