2018-06-08 15:44:19 +00:00
|
|
|
#
|
|
|
|
# Build
|
|
|
|
#
|
|
|
|
|
|
|
|
if {![have_include power_on/qemu] ||
|
|
|
|
[have_spec foc] || [have_spec odroid_xu] ||
|
|
|
|
[expr [have_spec imx53] && [have_spec trustzone]]} {
|
|
|
|
|
|
|
|
puts "Run script is not supported on this platform."
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2018-09-30 15:27:14 +00:00
|
|
|
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" }
|
2018-06-08 15:44:19 +00:00
|
|
|
|
|
|
|
set build_components {
|
|
|
|
core
|
|
|
|
init
|
|
|
|
drivers/timer
|
|
|
|
drivers/nic
|
|
|
|
server/nic_router
|
|
|
|
test/net_flood
|
|
|
|
app/ping
|
2018-09-30 15:27:14 +00:00
|
|
|
server/report_rom
|
|
|
|
server/dynamic_rom
|
2018-06-08 15:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 }
|
|
|
|
|
|
|
|
lappend_if [have_spec gpio] build_components drivers/gpio
|
|
|
|
|
|
|
|
source ${genode_dir}/repos/base/run/platform_drv.inc
|
|
|
|
append_platform_drv_build_components
|
|
|
|
|
|
|
|
build $build_components
|
|
|
|
|
|
|
|
create_boot_directory
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generate config
|
|
|
|
#
|
|
|
|
|
|
|
|
append config {
|
|
|
|
<config>
|
|
|
|
<parent-provides>
|
|
|
|
<service name="ROM"/>
|
2018-09-30 15:27:14 +00:00
|
|
|
<service name="RAM"/>
|
2018-06-08 15:44:19 +00:00
|
|
|
<service name="IRQ"/>
|
|
|
|
<service name="IO_MEM"/>
|
|
|
|
<service name="IO_PORT"/>
|
|
|
|
<service name="PD"/>
|
|
|
|
<service name="RM"/>
|
|
|
|
<service name="CPU"/>
|
|
|
|
<service name="LOG"/>
|
|
|
|
</parent-provides>
|
|
|
|
<default-route>
|
|
|
|
<any-service> <parent/> <any-child/> </any-service>
|
|
|
|
</default-route>
|
|
|
|
<default caps="100"/>}
|
|
|
|
|
|
|
|
append_platform_drv_config
|
|
|
|
|
|
|
|
append_if [have_spec gpio] config "
|
2018-09-30 15:27:14 +00:00
|
|
|
|
2018-06-08 15:44:19 +00:00
|
|
|
<start name=\"[gpio_drv]\" caps=\"150\">
|
|
|
|
<resource name=\"RAM\" quantum=\"4M\"/>
|
|
|
|
<provides><service name=\"Gpio\"/></provides>
|
|
|
|
<config/>
|
|
|
|
</start>"
|
|
|
|
|
|
|
|
append config {
|
2018-09-30 15:27:14 +00:00
|
|
|
|
2018-06-08 15:44:19 +00:00
|
|
|
<start name="timer">
|
|
|
|
<resource name="RAM" quantum="1M"/>
|
|
|
|
<provides><service name="Timer"/></provides>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
<start name="nic_drv" caps="150">
|
|
|
|
<binary name="} [nic_drv_binary] {"/>
|
|
|
|
<resource name="RAM" quantum="20M"/>
|
|
|
|
<provides><service name="Nic"/></provides>
|
|
|
|
} [nic_drv_config] {
|
|
|
|
</start>
|
|
|
|
|
2018-09-30 15:27:14 +00:00
|
|
|
<start name="report_rom">
|
|
|
|
<resource name="RAM" quantum="4M"/>
|
|
|
|
<provides> <service name="Report"/> <service name="ROM"/> </provides>
|
|
|
|
<config verbose="yes"/>
|
|
|
|
</start>
|
|
|
|
|
2018-06-08 15:44:19 +00:00
|
|
|
<start name="nic_router" caps="200">
|
2018-09-30 15:27:14 +00:00
|
|
|
<resource name="RAM" quantum="6M"/>
|
2018-06-08 15:44:19 +00:00
|
|
|
<provides><service name="Nic"/></provides>
|
2018-09-30 15:27:14 +00:00
|
|
|
<config ld_verbose="yes" verbose="no"
|
2018-06-08 15:44:19 +00:00
|
|
|
verbose_packets="no"
|
2018-06-19 14:27:11 +00:00
|
|
|
verbose_packet_drop="yes"
|
2018-09-30 15:27:14 +00:00
|
|
|
verbose_domain_state="no"
|
2018-06-08 15:44:19 +00:00
|
|
|
dhcp_discover_timeout_sec="1"
|
|
|
|
tcp_idle_timeout_sec="3600"
|
|
|
|
udp_idle_timeout_sec="3600"
|
|
|
|
icmp_idle_timeout_sec="3600">
|
|
|
|
|
2018-09-30 15:27:14 +00:00
|
|
|
<report stats="yes" config="no" bytes="no" interval_sec="} [expr [pause_sec] - 1] {"/>
|
|
|
|
<policy label_prefix="init -> " domain="downlinks"/>
|
|
|
|
<uplink domain="uplink"/>
|
2018-06-08 15:44:19 +00:00
|
|
|
|
|
|
|
<domain name="uplink" verbose_packets="no">
|
2018-09-30 15:27:14 +00:00
|
|
|
<nat domain="downlinks" udp-ports="16384"
|
|
|
|
tcp-ports="16384"
|
|
|
|
icmp-ids="16384"/>
|
2018-06-08 15:44:19 +00:00
|
|
|
</domain>
|
|
|
|
|
2018-09-30 15:27:14 +00:00
|
|
|
<domain name="downlinks" interface="10.0.1.1/24">
|
2018-06-08 15:44:19 +00:00
|
|
|
<dhcp-server ip_first="10.0.1.100"
|
|
|
|
ip_last="10.0.1.200"/>
|
|
|
|
|
|
|
|
<icmp dst="0.0.0.0/0" domain="uplink"/>
|
|
|
|
<udp dst="0.0.0.0/0"><permit-any domain="uplink"/></udp>
|
|
|
|
<tcp dst="0.0.0.0/0"><permit-any domain="uplink"/></tcp>
|
|
|
|
</domain>
|
|
|
|
|
|
|
|
</config>
|
|
|
|
<route>
|
|
|
|
<service name="Nic"> <child name="nic_drv"/> </service>
|
2018-09-30 15:27:14 +00:00
|
|
|
<service name="Report"> <child name="report_rom"/> </service>
|
2018-06-08 15:44:19 +00:00
|
|
|
<any-service> <parent/> <any-child/> </any-service>
|
|
|
|
</route>
|
|
|
|
</start>
|
|
|
|
|
2018-09-30 15:27:14 +00:00
|
|
|
<start name="dynamic_rom">
|
|
|
|
<resource name="RAM" quantum="10M"/>
|
|
|
|
<provides><service name="ROM"/> </provides>
|
|
|
|
<config verbose="yes">
|
|
|
|
|
|
|
|
<rom name="init.config">
|
|
|
|
|
|
|
|
<inline description="pause phase">
|
|
|
|
<config/>
|
|
|
|
</inline>
|
|
|
|
|
|
|
|
<sleep milliseconds="} [expr [pause_sec] * 1000] {"/>
|
|
|
|
|
|
|
|
<inline description="test phase">
|
|
|
|
<config>
|
|
|
|
|
|
|
|
<parent-provides>
|
|
|
|
<service name="ROM"/>
|
|
|
|
<service name="RAM"/>
|
|
|
|
<service name="IRQ"/>
|
|
|
|
<service name="IO_MEM"/>
|
|
|
|
<service name="IO_PORT"/>
|
|
|
|
<service name="PD"/>
|
|
|
|
<service name="RM"/>
|
|
|
|
<service name="CPU"/>
|
|
|
|
<service name="LOG"/>
|
|
|
|
<service name="Timer"/>
|
|
|
|
<service name="Nic"/>
|
|
|
|
</parent-provides>
|
|
|
|
<default-route>
|
|
|
|
<any-service> <parent/> </any-service>
|
|
|
|
</default-route>
|
|
|
|
<default caps="100"/>
|
|
|
|
|
|
|
|
<start name="test_flood_tcp">
|
|
|
|
<binary name="test-net_flood"/>
|
|
|
|
<resource name="RAM" quantum="8M"/>
|
|
|
|
<config dst_ip="} [bad_dst_ip] {"
|
|
|
|
protocol="tcp"
|
|
|
|
verbose="no"
|
|
|
|
sec="} [min_duration_sec] {"/>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
<start name="test_flood_udp">
|
|
|
|
<binary name="test-net_flood"/>
|
|
|
|
<resource name="RAM" quantum="8M"/>
|
|
|
|
<config dst_ip="} [bad_dst_ip] {"
|
|
|
|
protocol="udp"
|
|
|
|
verbose="no"
|
|
|
|
sec="} [min_duration_sec] {"/>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
<start name="test_flood_icmp">
|
|
|
|
<binary name="test-net_flood"/>
|
|
|
|
<resource name="RAM" quantum="8M"/>
|
|
|
|
<config dst_ip="} [bad_dst_ip] {"
|
|
|
|
protocol="icmp"
|
|
|
|
verbose="no"
|
|
|
|
sec="} [min_duration_sec] {"/>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
<start name="test_ping">
|
|
|
|
<binary name="ping"/>
|
|
|
|
<resource name="RAM" quantum="8M"/>
|
|
|
|
<config dst_ip="} [good_dst_ip] {"
|
|
|
|
period_sec="1"
|
|
|
|
count="} [expr [min_duration_sec] - 1] {"/>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
</config>
|
|
|
|
</inline>
|
|
|
|
|
|
|
|
<sleep milliseconds="} [expr ([min_duration_sec] + 2) * 1000] {"/>
|
|
|
|
</rom>
|
|
|
|
</config>
|
2018-06-08 15:44:19 +00:00
|
|
|
</start>
|
|
|
|
|
2018-09-30 15:27:14 +00:00
|
|
|
<start name="init" caps="1000">
|
|
|
|
<resource name="RAM" quantum="50M"/>
|
2018-06-08 15:44:19 +00:00
|
|
|
<route>
|
2018-09-30 15:27:14 +00:00
|
|
|
<service name="ROM" label="config"> <child name="dynamic_rom" label="init.config"/> </service>
|
2018-06-08 15:44:19 +00:00
|
|
|
<service name="Nic"> <child name="nic_router"/> </service>
|
|
|
|
<any-service> <parent/> <any-child/> </any-service>
|
|
|
|
</route>
|
|
|
|
</start>
|
|
|
|
|
|
|
|
</config>}
|
|
|
|
|
|
|
|
install_config $config
|
|
|
|
|
|
|
|
#
|
|
|
|
# Boot modules
|
|
|
|
#
|
|
|
|
|
|
|
|
# generic modules
|
|
|
|
append boot_modules {
|
|
|
|
core init
|
|
|
|
timer
|
|
|
|
} [nic_drv_binary] {
|
|
|
|
test-net_flood
|
|
|
|
ld.lib.so
|
|
|
|
nic_router
|
|
|
|
ping
|
2018-09-30 15:27:14 +00:00
|
|
|
report_rom
|
|
|
|
dynamic_rom
|
2018-06-08 15:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# platform-specific modules
|
|
|
|
lappend_if [have_spec linux] boot_modules fb_sdl
|
|
|
|
lappend_if [have_spec gpio] boot_modules [gpio_drv]
|
|
|
|
|
|
|
|
append_platform_drv_boot_modules
|
|
|
|
|
|
|
|
build_boot_image $boot_modules
|
|
|
|
|
|
|
|
append_if [have_spec x86] qemu_args " -net nic,model=e1000 "
|
|
|
|
append_if [have_spec lan9118] qemu_args " -net nic,model=lan9118 "
|
|
|
|
|
|
|
|
append qemu_args " -net user -nographic "
|
|
|
|
|
2018-09-30 15:27:14 +00:00
|
|
|
|
|
|
|
#########################
|
|
|
|
## 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 {.*<ram quota=.*\n}
|
|
|
|
append desired_str {.*<cap quota=.*\n}
|
|
|
|
|
|
|
|
run_genode_until $desired_str [expr [pause_sec] * 2] $serial_id
|
|
|
|
|
|
|
|
set quota_ram {}
|
|
|
|
regexp {<ram quota=\"[0-9]+\" used=\"[0-9]+\" shared=\"[0-9]+} $output quota_ram
|
|
|
|
regexp {[0-9]+} [regexp -inline {quota=\"[0-9]+} $quota_ram] ram_quota_2
|
|
|
|
regexp {[0-9]+} [regexp -inline {used=\"[0-9]+} $quota_ram] used_ram_2
|
|
|
|
regexp {[0-9]+} [regexp -inline {shared=\"[0-9]+} $quota_ram] shared_ram_2
|
|
|
|
|
|
|
|
set quota_cap {}
|
|
|
|
regexp {<cap quota=\"[0-9]+\" used=\"[0-9]+\" shared=\"[0-9]+} $output quota_cap
|
|
|
|
regexp {[0-9]+} [regexp -inline {quota=\"[0-9]+} $quota_cap] cap_quota_2
|
|
|
|
regexp {[0-9]+} [regexp -inline {used=\"[0-9]+} $quota_cap] used_cap_2
|
|
|
|
regexp {[0-9]+} [regexp -inline {shared=\"[0-9]+} $quota_cap] shared_cap_2
|
|
|
|
|
|
|
|
if {$ram_quota_1 != $ram_quota_2} {
|
|
|
|
puts stderr "*** Error: routers ram quota changed"
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
if {$cap_quota_1 != $cap_quota_2} {
|
|
|
|
puts stderr "*** Error: routers cap quota changed"
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
if {($used_ram_1 - $used_ram_2) != ($shared_ram_1 - $shared_ram_2)} {
|
|
|
|
puts stderr "*** Error: unexpected change in routers used ram quota"
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
if {($used_cap_1 - $used_cap_2) != ($shared_cap_1 - $shared_cap_2)} {
|
|
|
|
puts stderr "*** Error: unexpected change in routers used cap quota"
|
|
|
|
exit -1
|
|
|
|
}
|
|
|
|
if {$shared_ram_1 > 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 {.*<ram quota=.*\n}
|
|
|
|
append desired_str {.*<cap quota=.*\n}
|
|
|
|
|
|
|
|
run_genode_until $desired_str [expr [pause_sec] * 2]
|
|
|
|
|
|
|
|
set serial_id [output_spawn_id]
|
|
|
|
|
|
|
|
set quota_ram {}
|
|
|
|
regexp {<ram quota=\"[0-9]+\" used=\"[0-9]+\" shared=\"[0-9]+} $output quota_ram
|
|
|
|
regexp {[0-9]+} [regexp -inline {quota=\"[0-9]+} $quota_ram] ram_quota_1
|
|
|
|
regexp {[0-9]+} [regexp -inline {used=\"[0-9]+} $quota_ram] used_ram_1
|
|
|
|
regexp {[0-9]+} [regexp -inline {shared=\"[0-9]+} $quota_ram] shared_ram_1
|
|
|
|
|
|
|
|
set quota_cap {}
|
|
|
|
regexp {<cap quota=\"[0-9]+\" used=\"[0-9]+\" shared=\"[0-9]+} $output quota_cap
|
|
|
|
regexp {[0-9]+} [regexp -inline {quota=\"[0-9]+} $quota_cap] cap_quota_1
|
|
|
|
regexp {[0-9]+} [regexp -inline {used=\"[0-9]+} $quota_cap] used_cap_1
|
|
|
|
regexp {[0-9]+} [regexp -inline {shared=\"[0-9]+} $quota_cap] shared_cap_1
|
|
|
|
|
|
|
|
test
|
|
|
|
test
|
|
|
|
test
|