From patchwork Thu Nov 17 01:37:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9432987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D02DD60471 for ; Wed, 16 Nov 2016 22:30:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE4ED28D1C for ; Wed, 16 Nov 2016 22:30:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B32C729176; Wed, 16 Nov 2016 22:30:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=2.0 tests=BAYES_00, DATE_IN_FUTURE_03_06, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1F9CE28D1C for ; Wed, 16 Nov 2016 22:30:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c78gp-0004Ek-6j; Wed, 16 Nov 2016 22:28:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c78gn-0004D0-Uj for xen-devel@lists.xenproject.org; Wed, 16 Nov 2016 22:28:22 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id ED/7B-31609-58DDC285; Wed, 16 Nov 2016 22:28:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnkeJIrShJLcpLzFFi42KZM10+ULf1rk6 EQe81XovvWyYzOTB6HP5whSWAMYo1My8pvyKBNeP0vhmsBYtVKr69mcfSwNgj18XIxSEk0MEk cfz6LUYI5wujxO+bz5kgnI2MEjdOfGSFcLoZJXZ1vQQq4+BgEzCReLPKsYuRk0NEwFbiXuNsR hCbWSBc4v/+DiYQW1jAUqLj1wmwOIuAqsTHD43sIDavgLvErZdvWUFsCQE5ifPHfzKDjOQU8J B4+4MDJCwEVPLv3092iBJjib5ZfSwTGPkWMDKsYtQoTi0qSy3SNTTQSyrKTM8oyU3MzAHyzPR yU4uLE9NTcxKTivWS83M3MQIDhQEIdjDeWxZwiFGSg0lJlHfDMZ0IIb6k/JTKjMTijPii0pzU 4kOMMhwcShK82neAcoJFqempFWmZOcCQhUlLcPAoifCKg6R5iwsSc4sz0yFSpxh1OfbMevWAS YglLz8vVUqc1w6kSACkKKM0D24ELH4uMcpKCfMyAh0lxFOQWpSbWYIq/4pRnINRSZh3CsgUns y8ErhNr4COYAI6Yo8A2BEliQgpqQZGKbPvj90yCs1VlidM7ZxmU5m968LCZ7uqTjbIxpvm77V 7LOwyVy5m9+r+Iybnq2zPHdKdKqeU3LmWwb21r+rk4p0Tlu9+cWbhdOUjkU06ITOfBpXbtBw0 z56/zOuL5LdQJsdUhq26m/8zS7yLP/+oO1tc23vz5bgDy23j2i/9KjPj3PZ81vMOJZbijERDL eai4kQAb/8sfJoCAAA= X-Env-Sender: konrad.wilk@oracle.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1479335299!37534805!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11009 invoked from network); 16 Nov 2016 22:28:20 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-4.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 16 Nov 2016 22:28:20 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id uAGMSG5i018864 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Nov 2016 22:28:16 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.13.8/8.13.8) with ESMTP id uAGMSFeV023766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Nov 2016 22:28:15 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id uAGMSFWC011887; Wed, 16 Nov 2016 22:28:15 GMT Received: from osstest.dumpdata.com (/209.6.196.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 16 Nov 2016 14:28:15 -0800 From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, Ian.Jackson@eu.citrix.com Date: Wed, 16 Nov 2016 20:37:08 -0500 Message-Id: <1479346630-122644-6-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1479346630-122644-1-git-send-email-konrad.wilk@oracle.com> References: <1479346630-122644-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: Marcos.Matsunaga@oracle.com, Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v1 5/7] ts-livepatch: Initial test-cases. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP There are 32 test-cases in there. Before we run any of them we verify that the payload files are present in /usr/lib/debug. If so we go through all of the test-cases. Signed-off-by: Konrad Rzeszutek Wilk --- ts-livepatch | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 ts-livepatch diff --git a/ts-livepatch b/ts-livepatch new file mode 100755 index 0000000..a996ee9 --- /dev/null +++ b/ts-livepatch @@ -0,0 +1,102 @@ +#!/usr/bin/perl -w +# This is part of "osstest", an automated testing framework for Xen. +# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +use strict qw(vars); +use Osstest; +use POSIX; +use Osstest::TestSupport; + +tsreadconfig(); + +my @livepatch_files = ("xen_hello_world.livepatch", "xen_replace_world.livepatch", + "xen_bye_world.livepatch", "xen_nop.livepatch"); + +my @livepatch_tests = ( + {cmd => "xen-livepatch list", rc => 0}, + {cmd => "xl info | grep xen_extra | grep -q \"Hello World\"", rc => 256}, + {cmd => "xen-livepatch revert xen_hello_world", rc => 256}, + {cmd => "xen-livepatch load xen_hello_world.livepatch", rc => 0}, + {cmd => "xen-livepatch load xen_hello_world.livepatch", rc => 256}, + {cmd => "xen-livepatch list | grep -q xen_hello_world", rc => 0}, + {cmd => "xl info | grep xen_extra | grep -q \"Hello World\"", rc => 0}, + {cmd => "xen-livepatch revert xen_hello_world", rc => 0}, + {cmd => "xl info | grep xen_extra | grep -q \"Hello World\"", rc => 256}, + {cmd => "xen-livepatch unload xen_hello_world", rc => 0}, + {cmd => "xen-livepatch unload xen_hello_world", rc => 256}, + {cmd => "xl info | grep xen_extra | grep -q \"Hello World\"", rc => 256}, + {cmd => "xen-livepatch load xen_hello_world.livepatch", rc => 0}, + {cmd => "xen-livepatch load xen_bye_world.livepatch", rc => 0}, + {cmd => "xl info | grep xen_extra | grep -q \"Bye World\"", rc => 0}, + {cmd => "xen-livepatch upload xen_replace xen_replace_world.livepatch", rc => 0}, + {cmd => "xen-livepatch replace xen_replace", rc => 0}, + {cmd => "xen-livepatch apply xen_hello_world", rc => 256}, + {cmd => "xen-livepatch apply xen_bye_world", rc => 256}, + {cmd => "xl info | grep xen_extra | grep -q \"Hello Again Wor\"", rc => 0}, + {cmd => "xen-livepatch apply xen_replace", rc => 0}, + {cmd => "xen-livepatch revert xen_replace", rc => 0}, + {cmd => "xen-livepatch unload xen_replace", rc => 0}, + {cmd => "xen-livepatch unload xen_hello_world", rc => 0}, + {cmd => "xen-livepatch unload xen_bye_world", rc => 0}, + {cmd => "xen-livepatch list | grep -q xen", rc => 256}, + {cmd => "xen-livepatch load xen_nop.livepatch", rc => 0}, + {cmd => "xen-livepatch revert xen_nop", rc => 0}, + {cmd => "xen-livepatch apply xen_nop", rc => 0}, + {cmd => "[ `xl info| grep \"xen_m\" | grep or | sed s/.*:// | uniq | wc -l` == 1 ]", rc => 0}, + {cmd => "xen-livepatch unload xen_nop", rc => 256}, + {cmd => "xen-livepatch revert xen_nop", rc => 0}, + {cmd => "xen-livepatch unload xen_nop", rc => 0}, + ); + +our $ho = selecthost('host'); + +sub livepatch_test () +{ + logm "Have $#livepatch_tests test-cases\n"; + my $rc=0; + for my $i ( 0 .. $#livepatch_tests ) { + my $expected_rc = $livepatch_tests[$i]{rc}; + my $cmd = "(cd /usr/lib/debug;$livepatch_tests[$i]{cmd})"; + logm "Executing: '$cmd:' .."; + my $rc=target_cmd_root_rc($ho, $cmd); + if ( $rc != $expected_rc ) { + logm "FAILED (got $rc, expected: $expected_rc): \n"; + return $rc; + } + logm ".. OK!\n"; + } + return $rc +} + +sub livepatch_check () +{ + foreach my $file (@livepatch_files) + { + if (!target_file_exists($ho, "/usr/lib/debug/$$file")) { + die "$file is missing!\n"; + } + } + return 0 +} + + +our $livepatch_result = livepatch_check(); +exit $livepatch_result if $livepatch_result; +$livepatch_result = livepatch_test(); + +logm("Livepatch test returned $livepatch_result"); + +exit $livepatch_result;