From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7044859904479199232 X-Received: by 2002:ac8:7009:: with SMTP id x9mr1218144qtm.420.1640259267588; Thu, 23 Dec 2021 03:34:27 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:620a:1221:: with SMTP id v1ls2624339qkj.10.gmail; Thu, 23 Dec 2021 03:34:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2fp8kqog8tPePcTgo0Zg4SefX4pqfcs0wL5Et2v9ZZsF6durBWKkGqy7ViqTsTg/zJ3Tm X-Received: by 2002:a05:620a:121c:: with SMTP id u28mr1007511qkj.12.1640259267085; Thu, 23 Dec 2021 03:34:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1640259267; cv=pass; d=google.com; s=arc-20160816; b=JIgEvDeBGf3rJbNjqr8wLfFtc6y1Yp4wde+PPASD+5DEMYT9tHfXK0bU3NsQ9/MmKb vaMKI71bP2uIYk4+LS+nJmkK7ZG/n35n70CDnpZkUV6jztm7myEp+PsLP+tasevvg0Jz LgjeZcUv2tz3gGNuX7/kM/UtHdMOphBsEAZHTgCN+hTVnCtt6xlZMJt1yyumWHpXqmQk vAYTbv5fbLrgtkhZalPSqUoVt7N/sFFsR6sDtizyj6dOHc8MxowMedSvVRBhSKI8oTwz KEG2Ey+iFTRgxP/1t3lkHHZy6Q0Xh30ji7StSBKzYg6ixzbgEwNC3cxlhIC2pnGDN2BT TqMQ== ARC-Message-Signature: i=2; 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:cc:to:from:dkim-signature; bh=F+nvcpEhXZ+ArgVGhhApIpZKYXLfBJ40JABgBdZcdEs=; b=ZPnoix6lP5DzUqJeNzuc1ho9n7+lleDGZmXRPan0OoT9ds5eHTS9Cbe4l5Xv0aJvYD x0rIsgUXssnmU47Ry/7I+dIR7EbgE6YdqMjRAVuUI/8qvVqCIfJ/xyO5LK8K4AqyF276 nLoFAs7u/LbxEm07b0/ahkg1FjpJYqybBnYPi5iqT9Xi6Ohx0wb5cijWlBV3ZjAScSy4 raDVDeuvj9WEyPqN21AA+kfJz7qoMQmJ3199R6ed6p1rchDtGFplzVl6IVXYBZ3FEENg rTM3i73rDjcRKKoORJrHuK2as05yb6ZBVLFCaTxvar+pMJQkSOB8DvN/nfHRiXLE067V spYg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=gX8mbxos; arc=pass (i=1 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of adriaan.schmidt@siemens.com designates 40.107.3.40 as permitted sender) smtp.mailfrom=adriaan.schmidt@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30040.outbound.protection.outlook.com. [40.107.3.40]) by gmr-mx.google.com with ESMTPS id 22si905528qty.4.2021.12.23.03.34.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Dec 2021 03:34:27 -0800 (PST) Received-SPF: pass (google.com: domain of adriaan.schmidt@siemens.com designates 40.107.3.40 as permitted sender) client-ip=40.107.3.40; Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=gX8mbxos; arc=pass (i=1 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of adriaan.schmidt@siemens.com designates 40.107.3.40 as permitted sender) smtp.mailfrom=adriaan.schmidt@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ct5gCRvJzTeK9qZdBh4jMk2gzv53rRnFs/wBOm2V4QCOu4wXSTa+ZK1XU8/FtekSJr62v+sjGnGmKCHTSg6uiHRqFPjcb1/l+wrkyQRgc93WTRRJrl0y73VI2DSXmXg+gztH316nkIavhahihjhlUml2h1BzprylO78bhBA+SZhqfZhU0YaUo72ho5ZW63uCacdEReu8T4A4lySb9rEnOX3bEKqS20Q3+Pr6ooe7XD5lHAiOg6dhyeWcHMq+QUH3gmfAVZSXoNfqh0iCbCMtdZ3h2Cb9fgD/jgJUIUcp59iK+7xYYERfA3PQwaShVjCEJBvOZ6JCX1F9cDG2sbNbIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F+nvcpEhXZ+ArgVGhhApIpZKYXLfBJ40JABgBdZcdEs=; b=Q5L9eorhXfNBvsp+OidCVufGBGUqk6D4SKLNEYCrUus0vIoIOJF6vVISuJlIyW16x2g/BxXJmYYDuIfEoTbl5BbJaEyc3fvuoNVlBy0W+ZvxZ1ypDWSxIy6sZJFbwRsd6nXVo4TWe2wk0id2shH6S4WXNh74/nlP+zkHxiMqoY2aKVPcMxaiQPfVsrgBrJjhc4hOc5+K/b1N0LzMBv8yj6H0rOoEOlght7hCK+76idiARkkORAERP9MbpTat3Fb7boNQHye8Yl/bUWWu2he18PXcTbxfspRmPBoaSTs3v+o+vfEmbwzcNAi6MXL1Bf1zT1+4dyj/B45ayUOP9TD/YA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.71) smtp.rcpttodomain=googlegroups.com smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=siemens.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F+nvcpEhXZ+ArgVGhhApIpZKYXLfBJ40JABgBdZcdEs=; b=gX8mbxos0Uyi3DXffk/X/leIBnOjSyoDjjxatXBwckcGyOZxFJ9W/QJFZ/jGjz4QtMVHHk3ICU8Uam0nfcbWQ6OI90zKuD1OSyGjjjw1FC2mBNtzOfVr/S4g6HmN5FiixZL/wIIJrw3VBRhnKnqiI3O4WG/DXN7cJHVJ4plg5Jvz66STXOkKXBRAFeYivwsGP1f4qzB0tTRNiw+GzFCq9o5MqN8LdseULxE3L7cOup4nyPH1C95pKyKQR9HPbVsl5ZO/fDPW86OU8XhngX3AT1SfVocupsM558TChpPCwi9syCqx+wqiF1YCHZ/xzhb47o02aGzU08gGb4b2Z1eU0Q== Received: from OL1P279CA0064.NORP279.PROD.OUTLOOK.COM (2603:10a6:e10:15::15) by AM9PR10MB4337.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:268::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.18; Thu, 23 Dec 2021 11:34:24 +0000 Received: from HE1EUR01FT011.eop-EUR01.prod.protection.outlook.com (2603:10a6:e10:15:cafe::b5) by OL1P279CA0064.outlook.office365.com (2603:10a6:e10:15::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.18 via Frontend Transport; Thu, 23 Dec 2021 11:34:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.71) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.71 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.71; helo=hybrid.siemens.com; Received: from hybrid.siemens.com (194.138.21.71) by HE1EUR01FT011.mail.protection.outlook.com (10.152.0.173) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4823.18 via Frontend Transport; Thu, 23 Dec 2021 11:34:24 +0000 Received: from DEMCHDC89XA.ad011.siemens.net (139.25.226.103) by DEMCHDC9SKA.ad011.siemens.net (194.138.21.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 23 Dec 2021 12:34:23 +0100 Received: from random.ppmd.siemens.net (139.25.68.25) by DEMCHDC89XA.ad011.siemens.net (139.25.226.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Thu, 23 Dec 2021 12:34:23 +0100 From: Adriaan Schmidt To: CC: Adriaan Schmidt Subject: [PATCH 1/3] testsuite: refactor Date: Thu, 23 Dec 2021 12:33:58 +0100 Message-ID: <20211223113400.1123555-2-adriaan.schmidt@siemens.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211223113400.1123555-1-adriaan.schmidt@siemens.com> References: <20211223113400.1123555-1-adriaan.schmidt@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Return-Path: adriaan.schmidt@siemens.com X-Originating-IP: [139.25.68.25] X-ClientProxiedBy: DEMCHDC8A1A.ad011.siemens.net (139.25.226.107) To DEMCHDC89XA.ad011.siemens.net (139.25.226.103) X-TM-AS-Product-Ver: SMEX-14.0.0.3080-8.6.1018-26606.007 X-TM-AS-Result: No-10--9.822800-8.000000 X-TMASE-MatchedRID: jnr7XxEHNUeQLaoaEKRbU8ZPPXOsW6nbyHwwnnWuWmvo5fsYXP0fUBiD IOPlOJG11YzbHoRn9L0E8cQsUQdAHwQy4qivAwYgSsX+ZURUowlmZsAqgZ7gH2wTEruL9ObTpWO BfK9L1z/An6/WnA76fvM+9Fw01I7GfGzuoVn0Vs6PQi9XuOWoOMWo6kJnduXJKrDHzH6zmUUEa8 g1x8eqF9JO+sYlhfSotVS7djV62e+CukcfrdcoGZctTH4XjCd+brPIUt6+GzgtvPXhZLGnkTuDa yXS0LqBCgNjqBgJU5O0gcB1l1Fz4ady/Us1uHCq4dJOQj1ZX0rFlh6wZqSS6+pKEpRpjeYiJScv OTX4jHP5L8Bg16S75PEqCMNk4PLqxj2D+pDNSMKAqyvkiZGeGWOEtO7K/2e5ZacDbE73ZSktOI9 ZW/K3Op+4ziUPq4LxzKhI/PM+wq96QAuR8hT0ILlUFWrj927bMbO7pRnSf75v+ggm5QAi4fE/cU LMuCxwCuSPuSVW5+66Ij5glj2cugXsO/8AMIjNWa/mmNeQ2z8+KbeGe6bo/fgAhuaFie7S1K3bs e3FjTs+argXbuCfh8qZ/PwTGIUMUtTgmoNQjI2MqybMD87ynPV1MnnwgooQggra2NOo2i2CeHfY ZgVO5plTEz+bsQajoIXZ6Oi7T50OjITYH5OIYCASu+a9XHN6nM8FMFzcocJ1e7Xbb6Im2uHv2XT +zK5Wa0TOsL14A2lOoawJu9w+jPBRw3B3Rda2sMG9Y6Ua1MqpoPO56643Ez8Cl1gFtRUpgDLqnr RlXrbWCLclQTx48t0H8LFZNFG73Yq8RVaZivX1op4CuIdKIEeDd/XqpRP75n3s8xIs54+vtVhYC 3KgKww1evz4MQhx X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--9.822800-8.000000 X-TMASE-Version: SMEX-14.0.0.3080-8.6.1018-26606.007 X-TM-SNTS-SMTP: 4AFC68BFB332C8A949F3E70524F72E3F3A1022586F6C64599675114D2B934FBF2000:8 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0da03e31-d7dd-458e-d4de-08d9c6082bb5 X-MS-TrafficTypeDiagnostic: AM9PR10MB4337:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /mGW3c8deRdxsltQFvnFOfg8+rVKRUYBO/ta32mKLkEFhAdohXqcTu5orXpOHBTynQP9x6klPumpGwKfOTsFWt4caz2GJi05mdlzkeaiX/TTROtnAhuoi+oUgDm4rBcdepi4mwxY8ompB6VkXVRqop10JyLdb71dpPwr41Td7VVUsm7LMu29zyIt1WoY7i8riHTeQv47A9G55RNRxxijh/uFRjlERhLOmHK1/Z9AzB6WAI8shbrTNjiXoEdDjbB5R0QTcDORjuUebtxbygYGcVLuCULhxYbQ0x6+GNmQgjzYaYLCa2ZwXMeQLqpAFDB3AjvZV9GEnsHsn9wogMric9EDqZqDQApSzLce1zZcSX42nRNU7/12toNF6tws+iiUh0m0UedaZ2Tof1O3nYtL/hDEy9c495xVbgsBWiqBSgrGUzbvYq/fLEsuBjiVAhnp+jRmUhPVCJ/zV8ECQG8o4cyUj8NgVRQ657vq6H3VfdTgolIlSfUfBUdEVCEo9s37wt9otpEDL7pyyBXXCXqa77y/XT3uf2/99uqnQhkTFkFkfTmuRApQvRgzkAK/Cqco0MJeZSPYSsYQe0XW++GUDirUGheCuBnw/5rB9IGEDRS5Mzzb6GfoaguSVMwnDiOAarQVYqKgwsPFVvHVOnGec69wGpDWVVXVlL3Mr3J6wLbyEjtLLTJ6jyDgZ/+bnX6uXKTMX0AajJV+bQ2eHeaRddOhMunFNNz1H1Azg3c4KljtbgvOUwGBlmEfw9txC4RkBkHJrUkhz3ZoLBYMPX+Up3f9of+XurZ/n7bFFebOnRo= X-Forefront-Antispam-Report: CIP:194.138.21.71;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:hybrid.siemens.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(46966006)(40470700002)(36840700001)(8936002)(40460700001)(47076005)(4326008)(36860700001)(508600001)(8676002)(82310400004)(5660300002)(30864003)(44832011)(82960400001)(6916009)(81166007)(316002)(83380400001)(356005)(16526019)(2906002)(107886003)(2616005)(36756003)(186003)(956004)(26005)(1076003)(336012)(70586007)(70206006)(86362001)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2021 11:34:24.4202 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0da03e31-d7dd-458e-d4de-08d9c6082bb5 X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a;Ip=[194.138.21.71];Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: HE1EUR01FT011.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR10MB4337 X-TUID: DrrWP64vQeqJ - make test initialization more explicit. tests now call init() to initialize build_dir and environment, and configure() to generate the config file and bitbake_args - only configure() touches the config file. if config needs to change during one test case, it is created from scratch (no appending by the test case itself). - build_dir is not passed via avocado parameter. each test can set it in the call to init(). this makes dependencies between tests explicit and permits parallelization. - in the main invocation script, rename --build to --base. what we're setting here is not the bitbake build_dir but the base dir for avocado test output. Signed-off-by: Adriaan Schmidt --- scripts/ci_build.sh | 22 +++--- testsuite/build_test/build_test.py | 41 ++++++----- testsuite/build_test/cibase.py | 72 ++++++------------- testsuite/build_test/cibuilder.py | 109 +++++++++++++++++++++-------- 4 files changed, 134 insertions(+), 110 deletions(-) diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh index e9ba034..339ebca 100755 --- a/scripts/ci_build.sh +++ b/scripts/ci_build.sh @@ -27,8 +27,8 @@ fi # Get Avocado build tests path BUILD_TEST_DIR="$(pwd)/testsuite/build_test" -# Start build in Isar tree by default -BUILD_DIR=./build +# Start tests in current path by default +BASE_DIR=./build # Check dependencies DEPENDENCIES="umoci skopeo" @@ -45,8 +45,8 @@ show_help() { echo " $0 [params]" echo echo "Parameters:" - echo " -b, --build BUILD_DIR set path to build directory. If not set," - echo " the build will be started in current path." + echo " -b, --base BASE_DIR set path to base directory. If not set," + echo " the tests will be started in current path." echo " -c, --cross enable cross-compilation." echo " -d, --debug enable debug bitbake output." echo " -f, --fast cross build reduced set of configurations." @@ -73,8 +73,8 @@ do show_help exit 0 ;; - -b|--build) - BUILD_DIR="$2" + -b|--base) + BASE_DIR="$2" shift ;; -c|--cross) @@ -117,10 +117,10 @@ fi mkdir -p .config/avocado cat < .config/avocado/avocado.conf [datadir.paths] -base_dir = $(realpath $BUILD_DIR)/ -test_dir = $(realpath $BUILD_DIR)/tests -data_dir = $(realpath $BUILD_DIR)/data -logs_dir = $(realpath $BUILD_DIR)/job-results +base_dir = $(realpath $BASE_DIR)/ +test_dir = $(realpath $BASE_DIR)/tests +data_dir = $(realpath $BASE_DIR)/data +logs_dir = $(realpath $BASE_DIR)/job-results EOF export VIRTUAL_ENV="./" @@ -129,4 +129,4 @@ set -x avocado $VERBOSE run "$BUILD_TEST_DIR/build_test.py" \ -t $TAGS --test-runner=runner --disable-sysinfo \ - -p build_dir="$BUILD_DIR" -p quiet=$QUIET -p cross=$CROSS_BUILD + -p quiet=$QUIET -p cross=$CROSS_BUILD diff --git a/testsuite/build_test/build_test.py b/testsuite/build_test/build_test.py index 5a771d1..d343a78 100644 --- a/testsuite/build_test/build_test.py +++ b/testsuite/build_test/build_test.py @@ -30,7 +30,8 @@ class ReproTest(CIBaseTest): 'mc:qemuarm64-stretch:isar-image-base' ] - self.perform_repro_test(targets, 1) + self.init() + self.perform_repro_test(targets, signed=True) def test_repro_unsigned(self): targets = [ @@ -38,7 +39,8 @@ class ReproTest(CIBaseTest): 'mc:qemuarm-stretch:isar-image-base' ] - self.perform_repro_test(targets, 0) + self.init() + self.perform_repro_test(targets) class CcacheTest(CIBaseTest): @@ -49,6 +51,7 @@ class CcacheTest(CIBaseTest): """ def test_ccache_rebuild(self): targets = ['mc:de0-nano-soc-buster:isar-image-base'] + self.init() self.perform_ccache_test(targets) class CrossTest(CIBaseTest): @@ -69,15 +72,17 @@ class CrossTest(CIBaseTest): 'mc:rpi-stretch:isar-image-base' ] - self.perform_build_test(targets, 1, None) + self.init() + self.perform_build_test(targets, cross=True) def test_cross_ubuntu(self): targets = [ 'mc:qemuarm64-focal:isar-image-base' ] + self.init() try: - self.perform_build_test(targets, 1, None) + self.perform_build_test(targets, cross=True) except: self.cancel('KFAIL') @@ -86,8 +91,9 @@ class CrossTest(CIBaseTest): 'mc:qemuarm-bullseye:isar-image-base' ] + self.init() try: - self.perform_build_test(targets, 1, None) + self.perform_build_test(targets, cross=True) except: self.cancel('KFAIL') @@ -101,7 +107,8 @@ class SdkTest(CIBaseTest): def test_sdk(self): targets = ['mc:qemuarm-stretch:isar-image-base'] - self.perform_build_test(targets, 1, 'do_populate_sdk') + self.init() + self.perform_build_test(targets, bitbake_cmd='do_populate_sdk') class NoCrossTest(CIBaseTest): @@ -130,11 +137,10 @@ class NoCrossTest(CIBaseTest): 'mc:virtualbox-ova-buster:isar-image-base' ] + self.init() # Cleanup after cross build - self.deletetmp(self.params.get('build_dir', - default=os.path.dirname(__file__) + '/../../build')) - - self.perform_build_test(targets, 0, None) + self.delete_from_build_dir('tmp') + self.perform_build_test(targets, cross=False) def test_nocross_bullseye(self): targets = [ @@ -145,8 +151,9 @@ class NoCrossTest(CIBaseTest): 'mc:hikey-bullseye:isar-image-base' ] + self.init() try: - self.perform_build_test(targets, 0, None) + self.perform_build_test(targets, cross=False) except: self.cancel('KFAIL') @@ -158,8 +165,7 @@ class RebuildTest(CIBaseTest): :avocado: tags=rebuild,fast,full """ def test_rebuild(self): - is_cross_build = int(self.params.get('cross', default=0)) - + self.init() layerdir_core = self.getlayerdir('core') dpkgbase_file = layerdir_core + '/classes/dpkg-base.bbclass' @@ -169,8 +175,7 @@ class RebuildTest(CIBaseTest): file.write('do_fetch_append() {\n\n}') try: - self.perform_build_test('mc:qemuamd64-stretch:isar-image-base', - is_cross_build, None) + self.perform_build_test('mc:qemuamd64-stretch:isar-image-base') finally: self.restorefile(dpkgbase_file) @@ -189,7 +194,8 @@ class ContainerImageTest(CIBaseTest): 'mc:container-amd64-bullseye:isar-image-base' ] - self.perform_container_test(targets, None) + self.init() + self.perform_build_test(targets, container=True) class ContainerSdkTest(CIBaseTest): @@ -202,4 +208,5 @@ class ContainerSdkTest(CIBaseTest): def test_container_sdk(self): targets = ['mc:container-amd64-stretch:isar-image-base'] - self.perform_container_test(targets, 'do_populate_sdk') + self.init() + self.perform_build_test(targets, bitbake_cmd='do_populate_sdk', container=True) diff --git a/testsuite/build_test/cibase.py b/testsuite/build_test/cibase.py index 33bddfd..842ceaa 100644 --- a/testsuite/build_test/cibase.py +++ b/testsuite/build_test/cibase.py @@ -8,50 +8,21 @@ import time from cibuilder import CIBuilder from avocado.utils import process -isar_root = os.path.dirname(__file__) + '/../..' - class CIBaseTest(CIBuilder): - - def prep(self, testname, targets, cross, debsrc_cache): - build_dir = self.params.get('build_dir', default=isar_root + '/build') - build_dir = os.path.realpath(build_dir) - quiet = int(self.params.get('quiet', default=0)) - bitbake_args = '-v' - - if quiet: - bitbake_args = '' - - self.log.info('===================================================') - self.log.info('Running ' + testname + ' test for:') - self.log.info(targets) - self.log.info('Isar build folder is: ' + build_dir) - self.log.info('===================================================') - - self.init(build_dir) - self.confprepare(build_dir, 1, cross, debsrc_cache) - - return build_dir, bitbake_args; - - def perform_build_test(self, targets, cross, bitbake_cmd): - build_dir, bb_args = self.prep('Isar build', targets, cross, 1) + def perform_build_test(self, targets, **kwargs): + self.configure(**kwargs) self.log.info('Starting build...') - self.bitbake(build_dir, targets, bitbake_cmd, bb_args) - - def perform_repro_test(self, targets, signed): - cross = int(self.params.get('cross', default=0)) - build_dir, bb_args = self.prep('repro Isar build', targets, cross, 0) + self.bitbake(targets, **kwargs) + def perform_repro_test(self, targets, signed=False, **kwargs): gpg_pub_key = os.path.dirname(__file__) + '/../base-apt/test_pub.key' gpg_priv_key = os.path.dirname(__file__) + '/../base-apt/test_priv.key' - if signed: - with open(build_dir + '/conf/ci_build.conf', 'a') as file: - # Enable use of signed cached base repository - file.write('BASE_REPO_KEY="file://' + gpg_pub_key + '"\n') + self.configure(gpg_pub_key=gpg_pub_key if signed else None, **kwargs) - os.chdir(build_dir) + os.chdir(self.build_dir) os.environ['GNUPGHOME'] = tempfile.mkdtemp() result = process.run('gpg --import %s %s' % (gpg_pub_key, gpg_priv_key)) @@ -59,24 +30,22 @@ class CIBaseTest(CIBuilder): if result.exit_status: self.fail('GPG import failed') - self.bitbake(build_dir, targets, None, bb_args) + self.bitbake(targets, **kwargs) - self.deletetmp(build_dir) - with open(build_dir + '/conf/ci_build.conf', 'a') as file: - file.write('ISAR_USE_CACHED_BASE_REPO = "1"\n') - file.write('BB_NO_NETWORK = "1"\n') + self.delete_from_build_dir('tmp') + self.configure(gpg_pub_key=gpg_pub_key if signed else None, offline=True, **kwargs) - self.bitbake(build_dir, targets, None, bb_args) + self.bitbake(targets, **kwargs) # Disable use of cached base repository - self.confcleanup(build_dir) + self.unconfigure() if not signed: # Try to build with changed configuration with no cleanup - self.bitbake(build_dir, targets, None, bb_args) + self.bitbake(targets, **kwargs) # Cleanup - self.deletetmp(build_dir) + self.delete_from_build_dir('tmp') def perform_container_test(self, targets, bitbake_cmd): cross = int(self.params.get('cross', default=0)) @@ -93,21 +62,20 @@ class CIBaseTest(CIBuilder): self.deletetmp(build_dir) process.run('rm -rf ' + build_dir + '/ccache', sudo=True) - with open(build_dir + '/conf/ci_build.conf', 'a') as file: - file.write('USE_CCACHE = "1"\n') - file.write('CCACHE_TOP_DIR = "${TOPDIR}/ccache"') + self.delete_from_build_dir('tmp') + self.delete_from_build_dir('ccache') self.log.info('Starting build and filling ccache dir...') start = time.time() - self.bitbake(build_dir, targets, None, bb_args) + self.bitbake(targets, **kwargs) first_time = time.time() - start self.log.info('Non-cached build: ' + str(round(first_time)) + 's') - self.deletetmp(build_dir) + self.delete_from_build_dir('tmp') self.log.info('Starting build and using ccache dir...') start = time.time() - self.bitbake(build_dir, targets, None, bb_args) + self.bitbake(targets, **kwargs) second_time = time.time() - start self.log.info('Cached build: ' + str(round(second_time)) + 's') @@ -116,5 +84,5 @@ class CIBaseTest(CIBuilder): self.fail('No speedup after rebuild with ccache') # Cleanup - self.deletetmp(build_dir) - process.run('rm -rf ' + build_dir + '/ccache', sudo=True) + self.delete_from_build_dir('tmp') + self.delete_from_build_dir('ccache') diff --git a/testsuite/build_test/cibuilder.py b/testsuite/build_test/cibuilder.py index 94786c7..2cfb6ec 100644 --- a/testsuite/build_test/cibuilder.py +++ b/testsuite/build_test/cibuilder.py @@ -2,7 +2,6 @@ import logging import os -import re import select import shutil import subprocess @@ -11,7 +10,7 @@ from avocado import Test from avocado.utils import path from avocado.utils import process -isar_root = os.path.dirname(__file__) + '/../..' +isar_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) backup_prefix = '.ci-backup' app_log = logging.getLogger("avocado.app") @@ -28,17 +27,60 @@ class CIBuilder(Test): self._file_handler.setFormatter(formatter) app_log.addHandler(self._file_handler) - def init(self, build_dir): + def init(self, build_dir='build'): + # initialize build_dir and setup environment + # needs to run once (per test case) + if hasattr(self, 'build_dir'): + self.error("Broken test implementation: init() called multiple times.") + self.build_dir = os.path.join(isar_root, build_dir) os.chdir(isar_root) - path.usable_rw_dir(build_dir) + path.usable_rw_dir(self.build_dir) output = process.getoutput('/bin/bash -c "source isar-init-build-env \ - %s 2>&1 >/dev/null; env"' % build_dir) + %s 2>&1 >/dev/null; env"' % self.build_dir) env = dict(((x.split('=', 1) + [''])[:2] \ for x in output.splitlines() if x != '')) os.environ.update(env) - def confprepare(self, build_dir, compat_arch, cross, debsrc_cache): - with open(build_dir + '/conf/ci_build.conf', 'w') as f: + def check_init(self): + if not hasattr(self, 'build_dir'): + self.error("Broken test implementation: need to call init().") + + def configure(self, compat_arch=True, cross=None, debsrc_cache=True, + container=False, ccache=False, sstate=False, offline=False, + gpg_pub_key=None, **kwargs): + # write configuration file and set bitbake_args + # can run multiple times per test case + self.check_init() + + # get parameters from avocado cmdline + quiet = bool(int(self.params.get('quiet', default=0))) + if cross is None: + cross = bool(int(self.params.get('cross', default=0))) + + # get parameters from environment + distro_apt_premir = os.getenv('DISTRO_APT_PREMIRRORS') + + self.log.info(f'===================================================\n' + f'Configuring build_dir {self.build_dir}\n' + f' compat_arch = {compat_arch}\n' + f' cross = {cross}\n' + f' debsrc_cache = {debsrc_cache}\n' + f' offline = {offline}\n' + f' container = {container}\n' + f' ccache = {ccache}\n' + f' sstate = {sstate}\n' + f' gpg_pub_key = {gpg_pub_key}\n' + f'===================================================') + + # determine bitbake_args + self.bitbake_args = [] + if not quiet: + self.bitbake_args.append('-v') + if not sstate: + self.bitbake_args.append('--no-setscene') + + # write ci_build.conf + with open(self.build_dir + '/conf/ci_build.conf', 'w') as f: if compat_arch: f.write('ISAR_ENABLE_COMPAT_ARCH_amd64 = "1"\n') f.write('ISAR_ENABLE_COMPAT_ARCH_arm64 = "1"\n') @@ -48,36 +90,45 @@ class CIBuilder(Test): f.write('ISAR_CROSS_COMPILE = "1"\n') if debsrc_cache: f.write('BASE_REPO_FEATURES = "cache-deb-src"\n') - distro_apt_premir = os.getenv('DISTRO_APT_PREMIRRORS') + if offline: + f.write('ISAR_USE_CACHED_BASE_REPO = "1"\n') + f.write('BB_NO_NETWORK = "1"\n') + if container: + f.write('SDK_FORMATS = "docker-archive"\n') + f.write('IMAGE_INSTALL_remove = "example-module-${KERNEL_NAME} enable-fsck"\n') + if gpg_pub_key: + f.write('BASE_REPO_KEY="file://' + gpg_pub_key + '"\n') if distro_apt_premir: f.write('DISTRO_APT_PREMIRRORS = "%s"\n' % distro_apt_premir) - with open(build_dir + '/conf/local.conf', 'r+') as f: + # include ci_build.conf in local.conf + with open(self.build_dir + '/conf/local.conf', 'r+') as f: for line in f: if 'include ci_build.conf' in line: break else: f.write('\ninclude ci_build.conf') - def containerprep(self, build_dir): - with open(build_dir + '/conf/ci_build.conf', 'a') as f: - f.write('SDK_FORMATS = "docker-archive"\n') - f.write('IMAGE_INSTALL_remove = "example-module-${KERNEL_NAME} enable-fsck"\n') + def unconfigure(self): + self.check_init() + open(self.build_dir + '/conf/ci_build.conf', 'w').close() - def confcleanup(self, build_dir): - open(build_dir + '/conf/ci_build.conf', 'w').close() + def delete_from_build_dir(self, path): + self.check_init() + process.run('rm -rf ' + self.build_dir + '/' + path, sudo=True) - def deletetmp(self, build_dir): - process.run('rm -rf ' + build_dir + '/tmp', sudo=True) - - def bitbake(self, build_dir, target, cmd, args): - os.chdir(build_dir) + def bitbake(self, target, bitbake_cmd=None, **kwargs): + self.check_init() + self.log.info('===================================================') + self.log.info('Building ' + str(target)) + self.log.info('===================================================') + os.chdir(self.build_dir) cmdline = ['bitbake'] - if args: - cmdline.append(args) - if cmd: + if self.bitbake_args: + cmdline.extend(self.bitbake_args) + if bitbake_cmd: cmdline.append('-c') - cmdline.append(cmd) + cmdline.append(bitbake_cmd) if isinstance(target, list): cmdline.extend(target) else: @@ -103,30 +154,28 @@ class CIBuilder(Test): self.fail('Bitbake failed') def backupfile(self, path): + self.check_init() try: shutil.copy2(path, path + backup_prefix) except FileNotFoundError: self.log.warn(path + ' not exist') def backupmove(self, path): + self.check_init() try: shutil.move(path, path + backup_prefix) except FileNotFoundError: self.log.warn(path + ' not exist') def restorefile(self, path): + self.check_init() try: shutil.move(path + backup_prefix, path) except FileNotFoundError: self.log.warn(path + backup_prefix + ' not exist') def getlayerdir(self, layer): - try: - path.find_command('bitbake') - except path.CmdNotFoundError: - build_dir = self.params.get('build_dir', - default=isar_root + '/build') - self.init(build_dir) + self.check_init() output = process.getoutput('bitbake -e | grep "^LAYERDIR_.*="') env = dict(((x.split('=', 1) + [''])[:2] \ for x in output.splitlines() if x != '')) -- 2.30.2