From patchwork Fri Dec 8 05:46:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henry Wang X-Patchwork-Id: 13484851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE554C10DC1 for ; Fri, 8 Dec 2023 05:47:12 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.650351.1015838 (Exim 4.92) (envelope-from ) id 1rBThY-0002OD-KC; Fri, 08 Dec 2023 05:47:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 650351.1015838; Fri, 08 Dec 2023 05:47:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rBThY-0002O2-HO; Fri, 08 Dec 2023 05:47:04 +0000 Received: by outflank-mailman (input) for mailman id 650351; Fri, 08 Dec 2023 05:47:03 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rBThX-0001af-KC for xen-devel@lists.xenproject.org; Fri, 08 Dec 2023 05:47:03 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-sth1.inumbo.com (Halon) with ESMTP id 361cfc7d-958d-11ee-98e8-6d05b1d4d9a1; Fri, 08 Dec 2023 06:47:02 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EFB5211FB; Thu, 7 Dec 2023 21:47:47 -0800 (PST) Received: from a015966.shanghai.arm.com (a015966.shanghai.arm.com [10.169.190.5]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 495FB3F5A1; Thu, 7 Dec 2023 21:46:59 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 361cfc7d-958d-11ee-98e8-6d05b1d4d9a1 From: Henry Wang To: xen-devel@lists.xenproject.org Cc: Henry Wang , Doug Goldstein , Stefano Stabellini , Michal Orzel , Julien Grall , Bertrand Marquis , Wei Chen Subject: [PATCH v2 3/5] automation: Add the expect script with test case for FVP Date: Fri, 8 Dec 2023 13:46:35 +0800 Message-Id: <20231208054637.1973424-4-Henry.Wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231208054637.1973424-1-Henry.Wang@arm.com> References: <20231208054637.1973424-1-Henry.Wang@arm.com> MIME-Version: 1.0 To interact with the FVP (for example entering the U-Boot shell and transferring the files by TFTP), we need to connect the corresponding port by the telnet first. Use an expect script to simplify the automation of the whole "interacting with FVP" stuff. The expect script will firstly detect the IP of the host, then connect to the telnet port of the FVP, set the `serverip` and `ipaddr` for the TFTP service in the U-Boot shell, and finally boot Xen from U-Boot and wait for the expected results by Xen, Dom0 and DomU. Signed-off-by: Henry Wang Reviewed-by: Michal Orzel --- v2: - No change. --- .../expect/fvp-base-smoke-dom0-arm64.exp | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 automation/scripts/expect/fvp-base-smoke-dom0-arm64.exp diff --git a/automation/scripts/expect/fvp-base-smoke-dom0-arm64.exp b/automation/scripts/expect/fvp-base-smoke-dom0-arm64.exp new file mode 100755 index 0000000000..25d9a5f81c --- /dev/null +++ b/automation/scripts/expect/fvp-base-smoke-dom0-arm64.exp @@ -0,0 +1,73 @@ +#!/usr/bin/expect + +set timeout 2000 + +# Command to use to run must be given as first argument +# if options are required, quotes must be used: +# xxx.exp "cmd opt1 opt2" +set runcmd [lindex $argv 0] + +# Maximum number of line to be printed, this can be used to prevent runs to +# go forever on errors when Xen is rebooting +set maxline 1000 + +# Configure slow parameters used with send -s +# This allows us to slow down console writes to prevent issues with slow +# emulators or targets. +# Format here is: {NUM TIME} which reads as wait TIME seconds each NUM of +# characters, here we send 1 char each 100ms +set send_slow {1 .1} + +proc test_boot {{maxline} {host_ip}} { + expect_after { + -re "(.*)\r" { + if {$maxline != 0} { + set maxline [expr {$maxline - 1}] + if {$maxline <= 0} { + send_user "ERROR-Toomuch!\n" + exit 2 + } + } + exp_continue + } + timeout {send_user "ERROR-Timeout!\n"; exit 3} + eof {send_user "ERROR-EOF!\n"; exit 4} + } + + # Extract the telnet port numbers from FVP output, because the telnet ports + # are not guaranteed to be fixed numbers. + expect -re {terminal_0: Listening for serial connection on port [0-9]+} + set terminal_0 $expect_out(0,string) + if {[regexp {port (\d+)} $terminal_0 match port_0]} { + puts "terminal_0 port is $port_0" + } else { + puts "terminal_0 port not found" + exit 5 + } + + spawn bash -c "telnet localhost $port_0" + expect -re "Hit any key to stop autoboot.*" + send -s " \r" + send -s "setenv serverip $host_ip; setenv ipaddr $host_ip; tftpb 0x80200000 boot.scr; source 0x80200000\r" + + # Initial Xen boot + expect -re "\(XEN\).*Freed .* init memory." + + # Dom0 and DomU + expect -re "Domain-0.*" + expect -re "BusyBox.*" + expect -re "/ #.*" +} + +# Get host IP +spawn bash -c "hostname -I | awk '{print \$1}'" +expect -re {(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})} +set host_ip $expect_out(0,string) + +# Start the FVP and run the test +spawn bash -c "$runcmd" + +test_boot 2000 "$host_ip" + +send_user "\nExecution with SUCCESS\n" +exit 0