nic_router.run: avoid use of 'string cat'

It seems that our buildbot has a problem with the TCL command 'string
cat'. In most cases it is not necessary anyway as we can use the ""
enclosure instead. It unfolds inline procedure calls and variables
automatically. We don't want to use "" only in cases where the literal
shall contain many " characters itself as it is the case for XML
configs. Then we use the 'append' command and a helper variable instead.

Ref #2193
This commit is contained in:
Martin Stein 2017-02-23 12:12:28 +01:00 committed by Christian Helmuth
parent 70548959b7
commit 8ab0a5c795

View File

@ -30,13 +30,12 @@ proc nic_drv_build { } {
if {[nic_drv] == "usb_drv"} { return drivers/usb } if {[nic_drv] == "usb_drv"} { return drivers/usb }
} }
proc gpio_drv_build { } { if {[gpio_drv] != ""} { return " drivers/gpio" } } proc gpio_drv_build { } { if {[gpio_drv] != ""} { return drivers/gpio } }
build [string cat { build "core init drivers/timer server/nic_router server/nic_bridge
core init drivers/timer server/nic_router server/nic_bridge test/lwip/http_srv_static test/lwip/http_clnt test/lxip/udp_echo
test/lwip/http_srv_static test/lwip/http_clnt test/lxip/udp_echo test/lxip/udp_client [nic_drv_build] [gpio_drv_build]
test/lxip/udp_client } [nic_drv_build] { } [gpio_drv_build] { [platform_drv_build_components]"
} [platform_drv_build_components]]
create_boot_directory create_boot_directory
@ -45,35 +44,38 @@ create_boot_directory
# #
proc gpio_drv_config { } { proc gpio_drv_config { } {
if {[have_spec gpio]} {
if {[have_spec gpio]} { return [string cat { append result {
<start name="} [gpio_drv] {">
<start name="} [gpio_drv] {"> <resource name="RAM" quantum="4M"/>
<resource name="RAM" quantum="4M"/> <provides><service name="Gpio"/></provides>
<provides><service name="Gpio"/></provides> </start>}
</start>}] } return $result
}
} }
proc nic_drv_config { } { proc nic_drv_config { } {
if {[nic_drv] == "nic_drv"} {
if {[nic_drv] == "nic_drv"} { return [string cat { append result {
<start name="nic_drv">
<start name="nic_drv"> <resource name="RAM" quantum="6M"/>
<resource name="RAM" quantum="6M"/> <provides><service name="Nic"/></provides>
<provides><service name="Nic"/></provides> </start>}
</start>}] } return $result
}
if {[nic_drv] == "usb_drv"} { return [string cat { if {[nic_drv] == "usb_drv"} {
append result {
<start name="usb_drv"> <start name="usb_drv">
<resource name="RAM" quantum="12M"/> <resource name="RAM" quantum="12M"/>
<provides> <provides>
<service name="Nic"/> <service name="Nic"/>
</provides> </provides>
<config ehci="yes"> <config ehci="yes">
<nic mac="02:00:00:00:01:01" /> <nic mac="02:00:00:00:01:01" />
</config> </config>
</start>}] } </start>}
return $result
}
} }
proc client_bin { prot } { proc client_bin { prot } {
@ -85,8 +87,7 @@ proc server_bin { prot } {
if {$prot == "http"} { return "test-lwip_httpsrv_static" } } if {$prot == "http"} { return "test-lwip_httpsrv_static" } }
proc client_config { prot index ip_addr gateway netmask nic srv_port srv_ip } { proc client_config { prot index ip_addr gateway netmask nic srv_port srv_ip } {
return [string cat { append result {
<start name="} $prot {_client_} $index {"> <start name="} $prot {_client_} $index {">
<binary name="} [client_bin $prot] {" /> <binary name="} [client_bin $prot] {" />
<resource name="RAM" quantum="2M"/> <resource name="RAM" quantum="2M"/>
@ -99,12 +100,12 @@ proc client_config { prot index ip_addr gateway netmask nic srv_port srv_ip } {
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {" <libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {"
gateway="} $gateway {" netmask="} $netmask {"/> gateway="} $gateway {" netmask="} $netmask {"/>
</config> </config>
</start>}] </start>}
return $result
} }
proc server_config { prot index ip_addr gateway netmask nic port } { proc server_config { prot index ip_addr gateway netmask nic port } {
return [string cat { append result {
<start name="} $prot {_server_} $index {"> <start name="} $prot {_server_} $index {">
<binary name="} [server_bin $prot] {" /> <binary name="} [server_bin $prot] {" />
<resource name="RAM" quantum="2M"/> <resource name="RAM" quantum="2M"/>
@ -117,46 +118,47 @@ proc server_config { prot index ip_addr gateway netmask nic port } {
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {" <libc stdout="/dev/log" stderr="/dev/log" ip_addr="} $ip_addr {"
gateway="} $gateway {" netmask="} $netmask {"/> gateway="} $gateway {" netmask="} $netmask {"/>
</config> </config>
</start>}] </start>}
return $result
} }
proc test_1_config { } { proc test_1_config { } {
if {[enable_test_1]} { return [string cat { if {[enable_test_1]} { return "
} [client_config udp 1 10.0.98.55 10.0.98.33 255.255.255.0 nic_router 1337 10.0.98.33] { [client_config udp 1 10.0.98.55 10.0.98.33 255.255.255.0 nic_router 1337 10.0.98.33]
} [server_config udp 1 10.0.99.55 10.0.99.33 255.255.255.0 nic_router 1337 ]] } [server_config udp 1 10.0.99.55 10.0.99.33 255.255.255.0 nic_router 1337 ]" }
} }
proc test_2_config { } { proc test_2_config { } {
if {[enable_test_2]} { return [string cat { if {[enable_test_2]} { return "
} [client_config udp 2 10.0.2.212 10.0.2.1 255.255.255.0 nic_bridge 1 10.0.2.55] { [client_config udp 2 10.0.2.212 10.0.2.1 255.255.255.0 nic_bridge 1 10.0.2.55]
} [server_config udp 2 18.17.16.15 18.17.16.14 255.255.0.0 nic_router 1 ]] } [server_config udp 2 18.17.16.15 18.17.16.14 255.255.0.0 nic_router 1 ]" }
} }
proc test_3_config { } { proc test_3_config { } {
if {[enable_test_3]} { return [string cat { if {[enable_test_3]} { return "
} [client_config udp 3 217.13.192.2 217.13.192.1 255.255.192.0 nic_router 65535 10.0.2.213] { [client_config udp 3 217.13.192.2 217.13.192.1 255.255.192.0 nic_router 65535 10.0.2.213]
} [server_config udp 3 10.0.2.213 10.0.2.55 255.255.255.0 nic_bridge 65535 ]] } [server_config udp 3 10.0.2.213 10.0.2.55 255.255.255.0 nic_bridge 65535 ]" }
} }
proc test_4_config { } { proc test_4_config { } {
if {[enable_test_4]} { return [string cat { if {[enable_test_4]} { return "
} [client_config http 1 10.0.2.201 10.0.2.1 255.255.255.0 nic_bridge 80 10.0.2.55] { [client_config http 1 10.0.2.201 10.0.2.1 255.255.255.0 nic_bridge 80 10.0.2.55]
} [server_config http 1 192.168.1.18 192.168.1.1 255.255.255.0 nic_router 80 ]] } [server_config http 1 192.168.1.18 192.168.1.1 255.255.255.0 nic_router 80 ]" }
} }
proc test_5_config { } { proc test_5_config { } {
if {[enable_test_5]} { return [string cat { if {[enable_test_5]} { return "
} [client_config http 2 10.0.2.202 10.0.2.1 255.255.255.0 nic_bridge 8080 10.0.2.55] { [client_config http 2 10.0.2.202 10.0.2.1 255.255.255.0 nic_bridge 8080 10.0.2.55]
} [server_config http 2 192.168.2.72 192.168.2.1 255.255.255.0 nic_router 8080 ]] } [server_config http 2 192.168.2.72 192.168.2.1 255.255.255.0 nic_router 8080 ]" }
} }
proc test_6_config { } { proc test_6_config { } {
if {[enable_test_6]} { return [string cat { if {[enable_test_6]} { return "
} [client_config http 3 100.200.0.128 100.200.0.1 255.255.0.0 nic_router 2345 10.0.2.203] { [client_config http 3 100.200.0.128 100.200.0.1 255.255.0.0 nic_router 2345 10.0.2.203]
} [server_config http 3 10.0.2.203 10.0.2.1 255.255.255.0 nic_bridge 2345 ]] } [server_config http 3 10.0.2.203 10.0.2.1 255.255.255.0 nic_bridge 2345 ]" }
} }
install_config [string cat { append config {
<config> <config>
<parent-provides> <parent-provides>
<service name="ROM"/> <service name="ROM"/>
@ -254,22 +256,25 @@ install_config [string cat {
} [test_5_config] { } [test_5_config] {
} [test_6_config] { } [test_6_config] {
</config> }] </config> }
install_config $config
# #
# Create single image and execute # Create single image and execute
# #
build_boot_image [string cat {
build_boot_image "
core init timer nic_router nic_bridge ld.lib.so libc.lib.so libm.lib.so core init timer nic_router nic_bridge ld.lib.so libc.lib.so libm.lib.so
libc_resolv.lib.so lwip.lib.so lxip.lib.so test-http_clnt libc_resolv.lib.so lwip.lib.so lxip.lib.so test-http_clnt
test-lwip_httpsrv_static test-lxip_udp_echo test-lxip_udp_client test-lwip_httpsrv_static test-lxip_udp_echo test-lxip_udp_client
} [nic_drv] { } [gpio_drv] { } [platform_drv_boot_modules]] [nic_drv] [gpio_drv] [platform_drv_boot_modules]"
proc nic_qemu_args { } { proc nic_qemu_args { } {
if {[have_spec x86]} { return "-net nic,model=e1000" } if {[have_spec x86]} { return "-net nic,model=e1000" }
if {[have_spec lan9118]} { return "-net nic,model=lan9118" } } if {[have_spec lan9118]} { return "-net nic,model=lan9118" } }
append qemu_args { -m 384 -nographic -net user -redir udp:5555::1337 } [nic_qemu_args] append qemu_args "-m 384 -nographic -net user -redir udp:5555::1337 [nic_qemu_args]"
run_genode_until {.*Test done.*\n.*Test done.*\n.*Test done.*\n.*Test done.*\n.*Test done.*\n.*Test done.*\n} 60 run_genode_until {.*Test done.*\n.*Test done.*\n.*Test done.*\n.*Test done.*\n.*Test done.*\n.*Test done.*\n} 60