Skip to content

Commit 69f86ed

Browse files
ritenfeske
authored andcommitted
use 'assert'-proc in run scripts
Issue #396
1 parent c0aca2b commit 69f86ed

20 files changed

+73
-124
lines changed

run/boot2java.run

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ set ::env(LOG) core
1313

1414
set lynx [installed_command lynx]
1515

16-
if {[expr ![have_include "power_on/qemu"] && [have_board pc]]} {
17-
puts "\n Run script is not supported on this platform. \n"; exit 0 }
16+
assert {[have_include power_on/qemu] && [have_board pc]}
1817

1918
source ${genode_dir}/repos/gems/run/sculpt.run
2019

run/drill.run

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
assert_spec x86
1+
assert {[have_spec x86]}
22

3-
if {[have_board linux]} {
4-
puts "The [run_name] scenario requires QEMU networking."
5-
exit 1
6-
}
3+
assert {![have_board linux]} \
4+
"The [run_name] scenario requires QEMU networking."
75

86
create_boot_directory
97
import_from_depot [depot_user]/src/[base_src] \

run/gmock.run

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
if {[have_board linux]} {
2-
puts "Platform is unsupported. (rtc driver support)"
3-
exit 0
4-
}
1+
2+
assert {![have_board linux]}
53

64
build {
75
core lib/ld init timer

run/iperf.inc

+14-16
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,28 @@
44
# \date 2020-08-04
55
#
66

7-
if {[expr $use_nic_bridge && $use_nic_router]} {
8-
puts "Cannot test with both NIC bridge and NIC router.";
9-
exit 0
10-
}
7+
assert {!($use_nic_bridge && $use_nic_router)} \
8+
"Cannot test with both NIC bridge and NIC router."
119

12-
if {[get_cmd_switch --autopilot] && [have_include "power_on/qemu"]} {
13-
puts "\nRunning netperf in autopilot on Qemu is not recommended.\n"
14-
exit
10+
if {[have_cmd_switch --autopilot]} {
11+
assert {![have_include power_on/qemu]} \
12+
"Running netperf in autopilot on Qemu is not recommended."
1513
}
1614

17-
if {[have_include "power_on/qemu"] &&
18-
[expr $use_nic_bridge || $use_nic_router || $use_usb_driver || $use_wifi_driver]} {
19-
puts "Cannot test this configuration on qemu.";
20-
exit 0
15+
if {[have_include power_on/qemu]} {
16+
assert {!$use_nic_bridge &&
17+
!$use_nic_router &&
18+
!$use_usb_driver &&
19+
!$use_wifi_driver} \
20+
"Cannot test this configuration on qemu."
2121
}
2222

23-
if {[have_board imx53_qsb_tz]} {
24-
puts "Run script is not supported on this platform."
25-
exit 0
26-
}
23+
assert {![have_board imx53_qsb_tz]}
24+
2725
set bridge_mac "02:02:02:02:16:00"
2826

2927
# autopilot: configure disjoint mac-address ranges for x86_32, x86_64, and others
30-
if {[get_cmd_switch --autopilot]} {
28+
if {[have_cmd_switch --autopilot]} {
3129
if {[have_spec x86_32]} { set bridge_mac "02:02:02:02:32:00" }
3230
if {[have_spec x86_64]} { set bridge_mac "02:02:02:02:64:00" }
3331
}

run/java.run

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
if {![have_spec x86_64] && ![have_spec arm_v7] ||
22
[expr [have_spec sel4] && ![have_spec x86_64]]} {
3-
puts "Java is not supported on this platform. Valid platforms are x86_64 and arm_v7a."
4-
exit 0
3+
assert {false} "Java is not supported on this platform. Valid platforms are x86_64 and arm_v7a."
54
}
65

76
build { core lib/ld init timer }

run/mbim-fetchurl.run

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# \date 2023-08-17
55
#
66

7+
assert {[have_recipe pkg/test_usb_host-[board]]} \
8+
"Recipe for 'pkg/test_usb_host-[board]' not available."
9+
710
proc ip_stack { } { return lxip }
811

912
proc socket_fs_plugin { } {
@@ -175,8 +178,7 @@ build_boot_image [build_artifacts]
175178
if {[have_include "power_on/qemu"]} {
176179
set USB_PORT 0
177180
if [catch { set USB_PORT $env(USB_PORT)}] {
178-
puts "No 'USB_PORT=<port>' environment variable set"
179-
exit 0
181+
assert {false} "No 'USB_PORT=<port>' environment variable set"
180182
}
181183
puts "Using USB_PORT=$USB_PORT"
182184

run/mbimcli.run

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
assert {[have_recipe pkg/test_usb_host-[board]]} \
2+
"Recipe for 'pkg/test_usb_host-[board]' not available."
3+
14
create_boot_directory
25

36
import_from_depot [depot_user]/src/[base_src] \
@@ -142,8 +145,7 @@ build_boot_image [build_artifacts]
142145
if {[have_include "power_on/qemu"]} {
143146
set USB_PORT 0
144147
if [catch { set USB_PORT $env(USB_PORT)}] {
145-
puts "No 'USB_PORT=<port>' environment variable set"
146-
exit 0
148+
assert {false} "No 'USB_PORT=<port>' environment variable set"
147149
}
148150
puts "Using USB_PORT=$USB_PORT"
149151

@@ -152,7 +154,7 @@ if {[have_include "power_on/qemu"]} {
152154
append qemu_args " -device usb-host,hostbus=1,hostaddr=$USB_PORT,bus=xhci.0 "
153155
}
154156

155-
if {[expr ![get_cmd_switch --autopilot]]} {
157+
if {[expr ![have_cmd_switch --autopilot]]} {
156158
run_genode_until forever
157159
} else {
158160
run_genode_until {child "ping" exited with exit value 0} 60

run/pkcs11_tool.run

+5-12
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,14 @@
2626
# the script.
2727
#
2828

29-
if {[expr ![have_include power_on/qemu]]} {
30-
puts "Run script is not supported on this platform."
31-
exit 0
32-
}
29+
assert {[have_include power_on/qemu]}
3330

34-
if {![info exists ::env(USB_BUS_ADDR)]} {
35-
puts "\nPlease define the USB_BUS_ADDR environment variable\n"
36-
exit 0
37-
}
31+
assert {[info exists ::env(USB_BUS_ADDR)]} \
32+
"Please define the USB_BUS_ADDR environment variable."
3833
set usb_bus_addr $::env(USB_BUS_ADDR)
3934

40-
if {![info exists ::env(USB_DEV_ADDR)]} {
41-
puts "\nPlease define the USB_DEV_ADDR environment variable\n"
42-
exit 0
43-
}
35+
assert {[info exists ::env(USB_DEV_ADDR)]} \
36+
"Please define the USB_DEV_ADDR environment variable."
4437
set usb_dev_addr $::env(USB_DEV_ADDR)
4538

4639
#

run/python3.run

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
# \date 2011-11-22
66
#
77

8-
if {![have_spec x86]} {
9-
puts "Run script is only supported on x86"; exit 0 }
8+
assert {[have_spec x86]}
109

11-
proc depot_user {} { return [get_cmd_arg --depot-user local] }
10+
proc depot_user {} { return [cmd_arg --depot-user local] }
1211

1312
create_boot_directory
1413

run/seoul-auto.run

+11-19
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,19 @@
77
# It assumes that the module files are present at '<build-dir>/bin/'
88
#
99

10-
assert_spec x86
10+
assert {[have_spec x86]}
11+
assert {[have_spec foc] || [have_spec sel4] || [have_spec nova] || [have_spec hw]}
1112

12-
if { [get_cmd_switch --autopilot] && [have_spec x86_32] } {
13-
puts "\n Run script is not supported on this platform. \n";
14-
exit 0
15-
}
13+
if {[have_cmd_switch --autopilot]} {
1614

17-
if { [get_cmd_switch --autopilot] && [have_include "power_on/qemu"] } {
18-
puts "\n Run script is not supported on this platform. \n";
19-
exit 0
20-
}
15+
assert {![have_spec x86_32]} \
16+
"Autopilot mode is not supported on this platform."
2117

22-
if { [get_cmd_switch --autopilot] && [have_spec hw] && ![have_include "power_on/qemu"] } {
23-
puts "\n Run script is not supported on this platform. \n";
24-
exit 0
25-
}
18+
assert {![have_include power_on/qemu]} \
19+
"Autopilot mode is not supported on this platform."
2620

27-
if {[have_spec foc] || [have_spec sel4] || [have_spec nova] || [have_spec hw]} {
28-
} else {
29-
puts "\n Run script is not supported on this platform. \n";
30-
exit 0
21+
assert {!([have_spec hw] && ![have_include power_on/qemu])} \
22+
"Autopilot mode is not supported on this platform."
3123
}
3224

3325
set use_multiboot 0
@@ -43,7 +35,7 @@ set use_block_sata 0
4335
# The test machine in autopilot mode has a usb hid test device which
4436
# attach/detach several times and clutters the log.
4537
#
46-
set use_usb [expr ![get_cmd_switch --autopilot]]
38+
set use_usb [expr ![have_cmd_switch --autopilot]]
4739

4840
set use_part_block 0
4941

@@ -88,7 +80,7 @@ append qemu_args " -m 1536 "
8880
append qemu_args " -cpu EPYC "
8981
append_qemu_nic_args
9082

91-
if { [get_cmd_switch --autopilot] } {
83+
if { [have_cmd_switch --autopilot] } {
9284
append qemu_args " -nographic "
9385
run_genode_until {\[init -\> seoul\] VMM: # CPU: vendor_id} 60
9486

run/seoul.inc

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set fb_name "boot_fb"
1414
if {[have_include power_on/qemu] && ([have_include image/iso] || [have_include image/disk])} {
1515
set fb_name "vesa_fb"
1616
}
17-
if {[get_cmd_switch --autopilot]} {
17+
if {[have_cmd_switch --autopilot]} {
1818
set fb_name "vesa_fb"
1919
}
2020

@@ -241,7 +241,7 @@ proc config_part_block { } {
241241
# Build
242242
#
243243

244-
assert_spec x86
244+
assert {[have_spec x86]}
245245

246246
set map_small "no"
247247
set vmm_vcpu_same_cpu "no"
@@ -251,10 +251,7 @@ if {[have_spec sel4]} {
251251
set vmm_vcpu_same_cpu "yes"
252252

253253
# seL4 has no AMD SVM support
254-
if {[have_include "power_on/qemu"]} {
255-
puts "\n Run script is not supported on this platform. \n";
256-
exit 0
257-
}
254+
assert {![have_include power_on/qemu]}
258255
}
259256

260257

run/ssh.run

+2-2
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ run_genode_until {.*ssh_server\] --- SSH terminal started.*\n} 5 serial_id
331331
set options "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o BatchMode=no"
332332

333333
set count 0
334-
if {[get_cmd_switch --autopilot]} {
334+
if {[have_cmd_switch --autopilot]} {
335335
set count 5
336336
}
337337

@@ -364,7 +364,7 @@ puts "or `sftp -p $port $sftp_user@$host` (password: $sftp_password)"
364364
puts "for remote file transfer session."
365365
puts ""
366366

367-
if {![get_cmd_switch --autopilot]} {
367+
if {![have_cmd_switch --autopilot]} {
368368
run_genode_until forever 0 $serial_id
369369
}
370370

run/ssh_client.run

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# \author Emery Hemingway
44
#
55

6-
assert_spec x86
6+
assert {[have_spec x86]}
77

88
set build_components {
99
app/ssh_client

run/ssh_exec_channel.run

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
# \brief Test for the SSH terminal
33
#
44

5-
assert_spec x86
6-
7-
if {[have_spec linux]} {
8-
puts "Run script is not supported on this platform."
9-
exit 0
10-
}
5+
assert {[have_spec x86]}
6+
assert {![have_spec linux]}
117

128
build { test/exec_terminal }
139
create_boot_directory
@@ -246,7 +242,7 @@ set nic_router_match_string ".uplink. dynamic IP config. interface (\[0-9\]+\.\[
246242

247243
proc sshpass { } { return [installed_command sshpass] }
248244

249-
if {[get_cmd_switch --autopilot]} {
245+
if {[have_cmd_switch --autopilot]} {
250246
run_genode_until $nic_router_match_string 60
251247
set serial_id [output_spawn_id]
252248

run/ssh_terminal.run

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
# \brief Test for the SSH terminal
33
#
44

5-
assert_spec x86
6-
7-
if {[have_spec linux]} {
8-
puts "Run script is not supported on this platform."
9-
exit 0
10-
}
5+
assert {[have_spec x86]}
6+
assert {![have_spec linux]}
117

128
# Build
139
#
@@ -249,7 +245,7 @@ append_qemu_nic_args "hostfwd=tcp::5555-:22"
249245

250246
set lxip_match_string "ipaddr=(\[0-9\]+\.\[0-9\]+\.\[0-9\]+\.\[0-9\]+).*\n"
251247

252-
if {[get_cmd_switch --autopilot]} {
248+
if {[have_cmd_switch --autopilot]} {
253249
run_genode_until $lxip_match_string 60
254250
set serial_id [output_spawn_id]
255251

run/stubby.run

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
assert_spec x86
1+
assert {[have_spec x86]}
22

3-
if {[have_board linux]} {
4-
puts "The [run_name] scenario requires QEMU networking."
5-
exit 1
6-
}
3+
assert {![have_board linux]} \
4+
"The [run_name] scenario requires QEMU networking."
75

86
source ${genode_dir}/repos/base/run/platform.inc
97

run/stubby_deploy.run

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
assert_spec x86
1+
assert {[have_spec x86]}
22

3-
if {[have_board linux]} {
4-
puts "Platform is unsupported."
5-
exit 0
6-
}
3+
assert {![have_board linux]}
74

85
create_boot_directory
96

run/tox_dht_bootstrap.run

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
# \author Emery Hemingway
44
#
55

6-
if { ![have_board pbxa9] && ![have_board pc] } {
7-
puts "Run script does not support this platform."
8-
exit 0
9-
}
6+
assert {[have_board pbxa9] || [have_board pc]}
107

118
import_from_depot \
129
[depot_user]/src/[base_src] \

0 commit comments

Comments
 (0)