# # \brief Test for the SSH terminal # assert_spec x86 if {[have_spec linux]} { puts "Run script is not supported on this platform." exit 0 } # Build # source ${genode_dir}/repos/base/run/platform_drv.inc append_platform_drv_build_components lappend build_components test/exec_terminal build $build_components create_boot_directory import_from_depot [depot_user]/src/[base_src] \ [depot_user]/src/bash \ [depot_user]/src/coreutils-minimal \ [depot_user]/src/exec_terminal \ [depot_user]/src/init \ [depot_user]/src/ipxe_nic_drv \ [depot_user]/src/libc \ [depot_user]/src/libcrypto \ [depot_user]/src/libssh \ [depot_user]/src/platform_drv \ [depot_user]/src/posix \ [depot_user]/src/ram_fs \ [depot_user]/src/fs_rom \ [depot_user]/src/rtc_drv \ [depot_user]/src/ssh_terminal \ [depot_user]/src/vfs \ [depot_user]/src/vfs_jitterentropy \ [depot_user]/src/vfs_lxip \ [depot_user]/src/vim-minimal \ [depot_user]/src/zlib # # Generate config # set config { 2000-01-01 00:00 } append_platform_drv_config append config { } install_config $config # # Generate a new host key # if {![file exists bin/ed25519_key]} { exec ssh-keygen -t ed25519 -f bin/ed25519_key -q -N "" } # # Boot modules # # generic modules set boot_modules { ed25519_key exec_terminal } # platform-specific modules append_platform_drv_boot_modules build_boot_image $boot_modules # # Execute test # append qemu_args " -m 512 -nographic " proc qemu_nic_model {} { if [have_spec x86] { return e1000 } if [have_spec lan9118] { return lan9118 } return nic_model_missing } append qemu_args " -netdev user,id=net0,hostfwd=tcp::5555-:22 " append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 " set lxip_match_string "ipaddr=(\[0-9\]+\.\[0-9\]+\.\[0-9\]+\.\[0-9\]+).*\n" if {[get_cmd_switch --autopilot]} { run_genode_until $lxip_match_string 60 set serial_id [output_spawn_id] if {[have_include "power_on/qemu"]} { set host "localhost" set port "5555" } else { regexp $lxip_match_string $output all host puts "" set port "22" } # wait for ssh_terminal to come up run_genode_until "--- SSH terminal started ---.*\n" 15 $serial_id for {set index 0} {$index < 3} {incr index} { puts "test interactive channel" spawn sshpass -p xuon ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l noux $host -p $port set ssh_id $spawn_id run_genode_until {/bin/bash] Hello from Genode!.*\n} 15 $serial_id send -i $ssh_id "ls\r" run_genode_until "bin" 15 $ssh_id send -i $ssh_id "exit\r" run_genode_until "child \"init\" exited with exit value 0.*\n" 15 $serial_id puts "test exec channel echo" set echo_text "The quick brown fox jumps over the lazy dog" spawn sshpass -p xuon ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l noux $host -p $port echo "$echo_text" set ssh_id $spawn_id run_genode_until ".*$echo_text.*\n" 15 $ssh_id run_genode_until "child \"init\" exited with exit value 0.*\n" 15 $serial_id puts "test exec channel ls" spawn sshpass -p xuon ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l noux $host -p $port "ls" set ssh_id $spawn_id run_genode_until "bin" 15 $ssh_id run_genode_until "child \"init\" exited with exit value 0.*\n" 15 $serial_id puts "test exec channel with empty command will not hang" spawn sshpass -p xuon ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l noux $host -p $port " " set ssh_id $spawn_id run_genode_until "child \"init\" exited with exit value.*\n" 15 $serial_id } puts "" puts "" } else { run_genode_until forever } exec rm bin/ed25519_key bin/ed25519_key.pub # vi: set ft=tcl :