From patchwork Sat Apr 13 05:54:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Opdenacker X-Patchwork-Id: 42293 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 aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 802F3C4345F for ; Sat, 13 Apr 2024 05:54:56 +0000 (UTC) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by mx.groups.io with SMTP id smtpd.web11.5513.1712987690626766976 for ; Fri, 12 Apr 2024 22:54:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dO4A8CLb; spf=pass (domain: bootlin.com, ip: 217.70.183.197, mailfrom: michael.opdenacker@bootlin.com) Received: by mail.gandi.net (Postfix) with ESMTPSA id 72F781C0003; Sat, 13 Apr 2024 05:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712987688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=HgJpLPdgXZtfCGZLNv+OjmBI820ND9clT8IB0zC42SU=; b=dO4A8CLbCmHUwZ9tDlc7FOdHCrUw4JxIKowrtmcDRUBFwH9O1EN8Hpk+7d7z3HICQc+8ds zoLWFUfNBA2J2ddrxNp6Emidj25+mXpljSUV5UzvfN9l9h4eKJODED1wwvu9iBP5Bji9le gA4iIydRW6gvpRg6kMx68HVVH3T5gMzR5d4YWQfOJmmEf9Zk5ENUV0+dREe1RUtck5GcCC avOiPO/AHvaJg1ImF9e9kCMxrkWGya8ma/eZEBLE8jEi5TeluSP6txiGGXIacVZKXIdZ5C vu2KSdEQy41wZlYmN+O7zExuQBl0cfy+vRg6agfIswX8bMJ24ZdU2zrwZXb/GQ== From: michael.opdenacker@bootlin.com To: openembedded-core@lists.openembedded.org Cc: Michael Opdenacker , Richard Purdie , Thomas Petazzoni , Bruce Ashfield Subject: [RFC PATCH] scripts: new oe-test-system-upgrade test Date: Sat, 13 Apr 2024 07:54:21 +0200 Message-Id: <20240413055421.210001-1-michael.opdenacker@bootlin.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-GND-Spam-Score: 300 X-GND-Status: SPAM X-GND-Sasl: michael.opdenacker@bootlin.com List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 13 Apr 2024 05:54:56 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/198191 From: Michael Opdenacker Proof of concept "testimage" test to check whether the generated package feeds can be used to update an older image provided by the Yocto Project autobuilder. Signed-off-by: Michael Opdenacker Suggested-by: Richard Purdie CC: Thomas Petazzoni CC: Bruce Ashfield --- Tested on the latest master against yocto-5.0_M3 A bit surprised that only one package got upgraded: DEBUG: Command: opkg upgrade Status: 0 Output: Upgrading libexpat1 (2.6.1-r0) to libexpat1 (2.6.2) on root Downloading http://192.168.7.1:44893/core2-64/libexpat1_2.6.2-r0_core2-64.ipk. Removing obsolete file /usr/lib/libexpat.so.1.9.1. Configuring libexpat1. Test with a more complete image than core-image-full-cmdline? --- .../lib/oeqa/runtime/cases/opkg_sysupgrade.py | 71 +++++++++++++++++++ scripts/oe-test-system-upgrade | 34 +++++++++ 2 files changed, 105 insertions(+) create mode 100644 meta/lib/oeqa/runtime/cases/opkg_sysupgrade.py create mode 100755 scripts/oe-test-system-upgrade diff --git a/meta/lib/oeqa/runtime/cases/opkg_sysupgrade.py b/meta/lib/oeqa/runtime/cases/opkg_sysupgrade.py new file mode 100644 index 0000000000..7431db9198 --- /dev/null +++ b/meta/lib/oeqa/runtime/cases/opkg_sysupgrade.py @@ -0,0 +1,71 @@ +# +# Copyright OpenEmbedded Contributors +# +# Test that generated ipk packages can be used to upgrade +# an older image version. +# +# This is done by the scripts/oe-test-system-upgrade script +# replacing the fresh generated image by the older image +# generated by the Yocto Project autobuilder. +# +# Here, we then replace the original package feeds by our own. +# This test is not meant to be used as a regular "testimage" test +# run on the fresh image. +# +# SPDX-License-Identifier: MIT +# + +import os +from oeqa.utils.httpserver import HTTPService +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.data import skipIfNotDataVar, skipIfNotFeature, skipIfFeature +from oeqa.runtime.decorator.package import OEHasPackage + +class OpkgSysUpgradeTest(OERuntimeTestCase): + + def pkg(self, command, expected = 0): + command = 'opkg %s' % command + status, output = self.target.run(command, 1500) + message = os.linesep.join([command, output]) + self.assertEqual(status, expected, message) + return output + +class OpkgRepoTest(OpkgSysUpgradeTest): + + @classmethod + def setUp(cls): + service_repo = os.path.join(cls.tc.td['DEPLOY_DIR_IPK']) + cls.repo_server = HTTPService(service_repo, + '0.0.0.0', port=cls.tc.target.server_port, + logger=cls.tc.logger) + cls.repo_server.start() + + @classmethod + def tearDown(cls): + cls.repo_server.stop() + + def setup_source_config_for_package_install(self): + source_server = 'http://%s:%s' % (self.tc.target.server_ip, self.repo_server.port) + sourceslist_dir = '/etc/opkg' + pkgarch = self.tc.td["TUNE_PKGARCH"] + machinedir = self.tc.td["MACHINE"].replace("-", "_") + self.target.run('cd %s; echo src/gz all %s/all > base-feeds.conf' % (sourceslist_dir, source_server)) + self.target.run('cd %s; echo src/gz %s %s/%s >> base-feeds.conf' % (sourceslist_dir, pkgarch, source_server, pkgarch)) + self.target.run('cd %s; echo src/gz %s %s/%s >> base-feeds.conf' % (sourceslist_dir, machinedir, source_server, machinedir)) + + def cleanup_source_config_for_package_install(self): + sourceslist_dir = '/etc/opkg' + self.target.run('rm -rf %s; mv %s.orig %s' % (sourceslist_dir, sourceslist_dir, sourceslist_dir)) + + @skipIfNotFeature('package-management', + 'Test requires package-management to be in IMAGE_FEATURES') + @skipIfNotDataVar('IMAGE_PKGTYPE', 'ipk', + 'IPK is not the primary package manager') + @skipIfFeature('read-only-rootfs', + 'Test does not work with read-only-rootfs in IMAGE_FEATURES') + @OEHasPackage(['opkg']) + def test_opkg_system_upgrade_from_repo(self): + self.setup_source_config_for_package_install() + self.pkg('update') + self.pkg('upgrade') + diff --git a/scripts/oe-test-system-upgrade b/scripts/oe-test-system-upgrade new file mode 100755 index 0000000000..0d36a70a8a --- /dev/null +++ b/scripts/oe-test-system-upgrade @@ -0,0 +1,34 @@ +#!/bin/sh +# Proof of concept script to test that generated ipk packages can +# be used to upgrade an older image version. +# +# This is done by generating an image but then replacing it +# by an older image shared by the Yocto Project autobuilder. +# We then run QEMU on the old image and replace the original +# original package feeds by our own. + +IMAGE=core-image-full-cmdline +MILESTONE=yocto-5.0_M3 +MACHINE=qemux86-64 +MACHINE_VARIANT=-alt +IMAGE_FILE=$IMAGE-$MACHINE.rootfs.ext4 +IMAGE_PATH=tmp/deploy/images/$MACHINE/$IMAGE_FILE +PACKAGE_TYPE=ipk + +# Need a configuration with poky-alt, package_management, ipk package +# Need to build a full image to build the .json file needed by QEMU. +# Therefore, it is not sufficient to run only "package_write_ipk" for the image. + +bitbake $IMAGE +bitbake package-index + +# Download image to test +# Remove the link to the generated image if any + +rm -f $IMAGE_PATH +wget -O $IMAGE_PATH https://downloads.yoctoproject.org/releases/yocto/milestones/$MILESTONE/machines/qemu/$MACHINE$MACHINE_VARIANT/$IMAGE_FILE + +# Run test + +echo "TEST_SUITES=\"opkg_sysupgrade\"" > conf/auto.conf +bitbake $IMAGE -c testimage