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).
|
|
|
|
#
|
|
|
|
# Please make sure to include a nic driver in your build configuration. E.g.,
|
2015-04-29 13:27:43 +00:00
|
|
|
# on the x86 platform, you may enable the 'dde_ipxe' repository.
|
2011-12-22 15:19:25 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
2019-04-24 13:09:49 +00:00
|
|
|
if {[expr [have_spec linux]] ||
|
|
|
|
[expr [have_spec imx53] && [have_spec trustzone]] ||
|
2019-06-24 09:03:34 +00:00
|
|
|
[have_spec rpi3] ||
|
2019-04-24 13:09:49 +00:00
|
|
|
[expr [have_spec riscv]]} {
|
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
|
|
|
|
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 \
|
|
|
|
[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
|
|
|
|
2020-10-09 14:13:14 +00:00
|
|
|
<start name="drivers" caps="1000" 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>
|
|
|
|
<any-service> <parent/> </any-service>
|
|
|
|
</route>
|
|
|
|
<provides> <service name="Nic"/> </provides>
|
|
|
|
</start>
|
|
|
|
|
2020-10-09 14:13:14 +00:00
|
|
|
<start name="test-lwip_httpsrv" caps="120" priority="-1">
|
2018-07-10 17:09:40 +00:00
|
|
|
<resource name="RAM" quantum="4M"/>
|
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>
|
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 }
|
|
|
|
|
2019-04-24 13:09:49 +00:00
|
|
|
build_boot_image { test-lwip_httpsrv }
|
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 {
|
2018-07-10 17:09:40 +00:00
|
|
|
set match_string "lwIP Nic interface up address=.* netmask.*\n"
|
2013-05-14 07:56:48 +00:00
|
|
|
regexp $match_string $output ip_addr
|
|
|
|
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 :
|