From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7197811629045579776 X-Received: by 2002:a05:6870:899b:b0:15f:c06c:ebdf with SMTP id f27-20020a056870899b00b0015fc06cebdfmr354220oaq.139.1675871117049; Wed, 08 Feb 2023 07:45:17 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6870:219d:b0:15f:fd78:6392 with SMTP id l29-20020a056870219d00b0015ffd786392ls8909752oae.6.-pod-prod-gmail; Wed, 08 Feb 2023 07:45:16 -0800 (PST) X-Google-Smtp-Source: AK7set86Dn55Loc4mNKGZttA1EvrkGKBwlkxQRVevpYWjykGKAkqraDJLPKVbWohEmAHA+v1LwO0 X-Received: by 2002:a05:6870:b688:b0:163:2de7:63a9 with SMTP id cy8-20020a056870b68800b001632de763a9mr3162322oab.37.1675871116449; Wed, 08 Feb 2023 07:45:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675871116; cv=none; d=google.com; s=arc-20160816; b=PJ5ze59TK0JqenatcIb4ZsJ9BIH3P7sMoEyYRTXB3YubmKiaXN7pQHv3xMKnKVM6Ea +SvOnlr56/E0ANmjc3WOH9X20JIEZLm6SdVCLngjV9FyF4Sde9PIo3elTFMrqRBkXKte JJXXo0hADbqBd29Sz7+JeeKWlIpPmz1n16KjjaNhDtIbgEupr0aFPzCXnKV+p1SZwOCi U38zWE8GeNujRGEV6GhlAYpO1iiII8Epm4igawugio/Im/GC/4eN43EbQ36PL6w1pIlP ysrkbtQcs5iwyMM6Q5CQsEnGw3QgFAP4JpQ647OVW708gtdiwU+8q5yeNjyO7B5zESZX 3IZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=axFaeFML13rwY6CdbwkxA5e1hfjPc7QeEOd2SVfZmyM=; b=ND+77IToWmmN1EUgzBPGiYbmO1udKmkIGmJ4aptwc/sLX0GulbmDZ8VllW+CLbLn2e MJWs3xEGSfTQZFMGvvan/QXcLrCOFd/iopKkFEZNxT7GJZbtuomQLrw58U5742pJiZb5 MJkIk7uNBLUCH2GEsSd4QWTCfl8KDX/+PuPFzD+k3KnHre4umXomKXC1JdxFzM8zux5R e5fmzDrsfOuIA470/POG9hEP7IDRVsj/0Lt/NUWNCcKWY1H35+Rzesr+A5ZtkO7Mez0X DO0MT7GZCSJ6cF1r5GU+ultEUUpaeoedkRs4NR4QjpF6S3WJTMuzyUn3eZKg0jvEnqcy eIOQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id sc15-20020a056871220f00b001480308ea6csi1370796oab.0.2023.02.08.07.45.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Feb 2023 07:45:16 -0800 (PST) Received-SPF: pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Received: from baighyz.m.ilbers.de (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPSA id 318FjB50015298 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 8 Feb 2023 16:45:14 +0100 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH v2 7/9] testsuite: Support running custom scripts in VM Date: Wed, 8 Feb 2023 16:45:09 +0100 Message-Id: <20230208154511.1884-8-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230208154511.1884-1-ubely@ilbers.de> References: <20230208154511.1884-1-ubely@ilbers.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: Fxn5Ye6jxYMt By specifying `script=''` it's now possible to run VM and execute local script over SSH connection. Signed-off-by: Uladzimir Bely --- testsuite/cibuilder.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py index 9b64af90..5eebd5aa 100755 --- a/testsuite/cibuilder.py +++ b/testsuite/cibuilder.py @@ -228,6 +228,15 @@ class CIBuilder(Test): return rc + def run_script(self, script, cmd_prefix): + script_dir = self.params.get('test_script_dir', + default=os.path.abspath(os.path.dirname(__file__))) + '/' + script_path = script_dir + script + rc = subprocess.call('cat ' + script_path + ' | ' + str(cmd_prefix), shell=True, + stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + return rc + + def wait_connection(self, proc, cmd_prefix, timeout): self.log.debug('Waiting for SSH server ready...') @@ -252,12 +261,13 @@ class CIBuilder(Test): def vm_start(self, arch='amd64', distro='buster', enforce_pcbios=False, skip_modulecheck=False, - image='isar-image-base', cmd=None): + image='isar-image-base', cmd=None, script=None): time_to_wait = self.params.get('time_to_wait', default=60) self.log.info('===================================================') self.log.info('Running Isar VM boot test for (' + distro + '-' + arch + ')') self.log.info('Remote command is ' + str(cmd)) + self.log.info('Remote script is ' + str(script)) self.log.info('Isar build folder is: ' + self.build_dir) self.log.info('===================================================') @@ -309,7 +319,7 @@ class CIBuilder(Test): stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) - if cmd is not None: + if cmd is not None or script is not None: rc = None try: port = None @@ -330,8 +340,13 @@ class CIBuilder(Test): rc = self.wait_connection(p1, cmd_prefix, timeout) if rc == 0: - rc = self.exec_cmd(cmd, cmd_prefix) - self.log.debug('`' + cmd + '` returned ' + str(rc)) + if cmd is not None: + rc = self.exec_cmd(cmd, cmd_prefix) + self.log.debug('`' + cmd + '` returned ' + str(rc)) + elif script is not None: + rc = self.run_script(script, cmd_prefix) + self.log.debug('`' + script + '` returned ' + str(rc)) + finally: if p1.poll() is None: self.log.debug('Killing qemu...') -- 2.20.1