2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
# \brief Test for using the lwIP TCP/IP stack
|
|
|
|
# \author Norman Feske
|
|
|
|
# \date 2011-05-22
|
|
|
|
#
|
|
|
|
# This test case executes a small HTTP server on Genode running on qemu. When
|
|
|
|
# the HTTP server is up, a HTTP request to the server is performed using
|
|
|
|
# 'lynx'. The response is validated against a known pattern.
|
|
|
|
#
|
2019-02-11 14:34:30 +00:00
|
|
|
# The test uses qemu's "-netdev user" option, redirecting Genode's port 80 to the
|
2011-12-22 15:19:25 +00:00
|
|
|
# host's port 5555. Consequently, it cannot be executed on non-qemu test
|
|
|
|
# environments (i.e., the test won't work with the Linux version of Genode).
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# TODO: Add support for Linux via user-level networking (using the
|
|
|
|
# tun/tap proxy driver at os/src/drivers/nic/linux)
|
|
|
|
#
|
2015-05-28 11:43:13 +00:00
|
|
|
|
2021-01-13 09:15:10 +00:00
|
|
|
if {[have_board linux] ||
|
|
|
|
[have_board imx53_qsb_tz] ||
|
2023-09-12 16:08:09 +00:00
|
|
|
[have_board rpi3] ||
|
|
|
|
[have_board rpi]} {
|
2013-07-11 09:14:57 +00:00
|
|
|
puts "\n Run script is not supported on this platform. \n"; exit 0 }
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2022-08-09 11:32:38 +00:00
|
|
|
if {[get_cmd_switch --autopilot] && [have_board virt_qemu_riscv]} {
|
2021-02-18 08:04:39 +00:00
|
|
|
puts "Autopilot mode is not supported on this platform."
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2018-06-19 17:55:04 +00:00
|
|
|
set lynx [installed_command lynx]
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
create_boot_directory
|
|
|
|
|
2019-04-24 13:09:49 +00:00
|
|
|
import_from_depot [depot_user]/src/[base_src] \
|
|
|
|
[depot_user]/pkg/[drivers_nic_pkg] \
|
|
|
|
[depot_user]/src/init \
|
2021-01-08 16:27:24 +00:00
|
|
|
[depot_user]/src/nic_router \
|
2019-04-24 13:09:49 +00:00
|
|
|
[depot_user]/src/libc \
|
|
|
|
[depot_user]/src/vfs_lwip \
|
|
|
|
[depot_user]/src/vfs
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2019-04-24 13:09:49 +00:00
|
|
|
install_config {
|
2020-10-09 14:13:14 +00:00
|
|
|
<config verbose="yes" prio_levels="2">
|
2011-12-22 15:19:25 +00:00
|
|
|
<parent-provides>
|
|
|
|
<service name="ROM"/>
|
|
|
|
<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>
|
2017-05-07 20:36:11 +00:00
|
|
|
<default caps="100"/>
|
2019-04-24 13:09:49 +00:00
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
<start name="timer">
|
2012-09-18 15:14:28 +00:00
|
|
|
<resource name="RAM" quantum="1M"/>
|
2011-12-22 15:19:25 +00:00
|
|
|
<provides> <service name="Timer"/> </provides>
|
|
|
|
</start>
|
2019-04-24 13:09:49 +00:00
|
|
|
|
2023-07-18 08:17:49 +00:00
|
|
|
<start name="drivers" caps="1200" managing_system="yes" priority="-1">
|
2020-07-10 11:04:12 +00:00
|
|
|
<resource name="RAM" quantum="32M"/>
|
2019-04-24 13:09:49 +00:00
|
|
|
<binary name="init"/>
|
|
|
|
<route>
|
|
|
|
<service name="ROM" label="config"> <parent label="drivers.config"/> </service>
|
|
|
|
<service name="Timer"> <child name="timer"/> </service>
|
2021-01-08 16:27:24 +00:00
|
|
|
<service name="Uplink"> <child name="nic_router"/> </service>
|
2019-04-24 13:09:49 +00:00
|
|
|
<any-service> <parent/> </any-service>
|
|
|
|
</route>
|
2021-01-08 16:27:24 +00:00
|
|
|
</start>
|
|
|
|
|
|
|
|
<start name="nic_router" caps="200">
|
|
|
|
<resource name="RAM" quantum="10M"/>
|
|
|
|
<provides>
|
|
|
|
<service name="Nic"/>
|
|
|
|
<service name="Uplink"/>
|
|
|
|
</provides>
|
|
|
|
<config verbose_domain_state="yes"
|
|
|
|
dhcp_discover_timeout_sec="1">
|
|
|
|
|
|
|
|
<policy label_prefix="test-lwip_httpsrv" domain="downlink"/>
|
|
|
|
<policy label_prefix="drivers" domain="uplink"/>
|
|
|
|
|
|
|
|
<domain name="uplink">
|
|
|
|
|
|
|
|
<nat domain="downlink"
|
|
|
|
tcp-ports="16384"
|
|
|
|
udp-ports="16384"
|
|
|
|
icmp-ids="16384"/>
|
|
|
|
|
|
|
|
<tcp-forward port="443" domain="downlink" to="10.0.3.2"/>
|
|
|
|
<tcp-forward port="80" domain="downlink" to="10.0.3.2"/>
|
|
|
|
|
|
|
|
</domain>
|
|
|
|
|
|
|
|
<domain name="downlink" interface="10.0.3.1/24">
|
|
|
|
|
|
|
|
<dhcp-server ip_first="10.0.3.2"
|
|
|
|
ip_last="10.0.3.2"
|
2021-08-05 11:31:13 +00:00
|
|
|
dns_config_from="uplink"/>
|
2021-01-08 16:27:24 +00:00
|
|
|
|
|
|
|
<tcp dst="0.0.0.0/0"><permit-any domain="uplink" /></tcp>
|
|
|
|
<udp dst="0.0.0.0/0"><permit-any domain="uplink" /></udp>
|
|
|
|
<icmp dst="0.0.0.0/0" domain="uplink"/>
|
|
|
|
|
|
|
|
</domain>
|
|
|
|
|
|
|
|
</config>
|
2019-04-24 13:09:49 +00:00
|
|
|
</start>
|
|
|
|
|
2020-10-09 14:13:14 +00:00
|
|
|
<start name="test-lwip_httpsrv" caps="120" priority="-1">
|
2022-12-03 21:00:59 +00:00
|
|
|
<resource name="RAM" quantum="8M"/>
|
2014-04-14 09:57:22 +00:00
|
|
|
<config>
|
2018-07-10 17:09:40 +00:00
|
|
|
<vfs>
|
|
|
|
<dir name="dev"> <log/> </dir>
|
|
|
|
<dir name="socket"> <lwip dhcp="yes"/> </dir>
|
|
|
|
</vfs>
|
|
|
|
<libc stdout="/dev/log" stderr="/dev/log" socket="/socket"/>
|
2014-04-14 09:57:22 +00:00
|
|
|
</config>
|
2021-01-08 16:27:24 +00:00
|
|
|
<route>
|
|
|
|
<service name="Nic"> <child name="nic_router"/> </service>
|
|
|
|
<any-service> <parent/> <any-child/> </any-service>
|
|
|
|
</route>
|
2019-04-24 13:09:49 +00:00
|
|
|
</start>
|
2011-12-22 15:19:25 +00:00
|
|
|
</config>
|
|
|
|
}
|
|
|
|
|
2020-10-09 14:13:14 +00:00
|
|
|
build { test/lwip/http_srv }
|
|
|
|
|
2023-09-12 14:21:03 +00:00
|
|
|
build_boot_image [build_artifacts]
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#
|
2019-04-24 13:09:49 +00:00
|
|
|
# Qemu config
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
2019-04-24 13:09:49 +00:00
|
|
|
append qemu_args " -nographic "
|
2020-04-02 19:20:50 +00:00
|
|
|
append_qemu_nic_args "hostfwd=tcp::5555-:80"
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2020-10-09 14:13:14 +00:00
|
|
|
run_genode_until {.*Start the server loop.*\n} 30
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2015-01-08 21:09:08 +00:00
|
|
|
if {[have_include "power_on/qemu"]} {
|
2013-03-20 11:45:54 +00:00
|
|
|
set uri "http://localhost:5555/"
|
2013-04-11 10:59:28 +00:00
|
|
|
} else {
|
2021-01-08 16:27:24 +00:00
|
|
|
set match_string "nic_router. .uplink. dynamic IP config: interface .*\n"
|
2013-05-14 07:56:48 +00:00
|
|
|
regexp $match_string $output ip_addr
|
2021-01-08 16:27:24 +00:00
|
|
|
regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $ip_addr ip_addr
|
2013-04-11 10:59:28 +00:00
|
|
|
|
|
|
|
set uri "http://$ip_addr:80/"
|
2013-03-20 11:45:54 +00:00
|
|
|
}
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
puts "http server is up, try to query website $uri"
|
|
|
|
|
2018-06-19 17:55:04 +00:00
|
|
|
set website [exec $lynx -dump $uri]
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
puts "response:\n$website"
|
|
|
|
|
|
|
|
if {![regexp {Welcome to our lwIP HTTP server!} $website dummy]} {
|
|
|
|
puts stderr "Query returned unexpected website"
|
|
|
|
exit 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
# vi: set ft=tcl :
|