From patchwork Mon Nov 17 15:59:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Stergiopoulos X-Patchwork-Id: 74810 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 688EDCEACEF for ; Mon, 17 Nov 2025 16:00:04 +0000 (UTC) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.12799.1763395196048447838 for ; Mon, 17 Nov 2025 07:59:56 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=CYBlRvRi; spf=pass (domain: smile.fr, ip: 209.85.128.47, mailfrom: andreas.stergiopoulos@smile.fr) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4779a637712so14055485e9.1 for ; Mon, 17 Nov 2025 07:59:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1763395194; x=1763999994; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LGhHOeIZ/hBf6SkGjXIPccvnKcx3AEeoWe7ypaabSwc=; b=CYBlRvRiIADcUfb0UqydMpkincEd/8PNT6RayY1hHmSWmdF6zz4hLfU8YJsMzZamCX cWqbWF0x+se0i+L22+PaU3TZqxNLk7m53e5B/QkJAssEpzqQLz8JeXdfw85kuB+WFmy7 hvDamYVNXassJeFwn4A+Li1Er0vQpwrNiv0n8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763395194; x=1763999994; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LGhHOeIZ/hBf6SkGjXIPccvnKcx3AEeoWe7ypaabSwc=; b=BUh19UwoUFiW80+q1tkUF3GuRBhRXuj225tC6WwWrCGI+/UvDJ+M9jc/AUzF2IfRwC rH/GBm+irw51Qg+fsi2I62vIWSTb8rQILsPdhBqqG/AJnGNPSfIoCfm3hpjZs29zg+qN Bmz+7YRlo1agK4bj6aBoxpNMYJRNNaFnpERxiX7PP/7dAdbiq57yrxWDm1kg7Mitv1On 7VPAJnp4PIehRJWIElNgcv/jR/BIvFibMiPTRoY6s7UCq05R0eLse2qr6cLd+pvQgP0f ui5kvducGOoYzEk1eJ5MO97tu/jqBHdjzYRCcd8GXjiqEQAJR91vWVGN6tNa1idOzKdV 7XhA== X-Gm-Message-State: AOJu0YyqJVQxFRoexveoNU7AsMyWqOVkPkqvlbJCey7j8XOaDnyGyYBj VajSM1x5YXH79mhUHauBiuA3+tylQ0uTcQqy7cLs1TzpvMXA/RYpiZMvsTOfZ/8IWxxbKRc9lD+ kLo3V X-Gm-Gg: ASbGncvK5Gs4JK50oHtJ9CQGh49K00W9IDtGkBh1PDybgA455GzoXXiCYycR3mEPY/t AyqbbwZVQdCcMIna76CpF6pXENIz8gxracEUcJlQ8aOycQNZOVZiJd/Up/w2jXL7/NUXYm/ZlPO B8P9aIBdOfd0LzIGwCQuu8GiryhsMyfqUQqTcFf8dx75p8Y8PvJb9ddQL3CAT/ktn/DQM2oIl1u xhXn/aOAX6QNRaVAc5Bjuif0fREjkYJqncVox2DkaNlQ6otIF+wXY9ihBHZvOk1gLVUMrtonnLw C8Uhgr48LGSnl2XucB7v3Ge1wRqmNKXHkiItb2BBEAnesw30uZktRW/niUL43gySZRfJaxePBWk CZRbGuzF+wSsP8Q7LEGVwB6ioh4+FjR2oDY30lZHgyYJU/9YZ+F4u5wGIfX+3nqTJmw5FCbMXDI yOnHrIIBNiMw497Adn/JpfGBbiDdtyWlutjb1KR2p2LjVyrOkZzSsgbpEtYvWDz1s0kmh98og1N HUjm9RgrFSGOhaUlF5txO9nYKqZx34= X-Google-Smtp-Source: AGHT+IEiHh/jazVi8Q3rZTqmTtMj0EPgJBnMpitIWz14q0QiqjaKbbY4am8HvIp7HoBoyHiEtCBEcQ== X-Received: by 2002:a05:600c:3112:b0:477:9650:3184 with SMTP id 5b1f17b1804b1-47796503351mr86341015e9.2.1763395194217; Mon, 17 Nov 2025 07:59:54 -0800 (PST) Received: from FRSMI25-PILS.idf.intranet (static-css-ccs-204145.business.bouyguestelecom.com. [176.157.204.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47787daab3fsm340609225e9.0.2025.11.17.07.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Nov 2025 07:59:53 -0800 (PST) From: Andreas Stergiopoulos To: openembedded-core@lists.openembedded.org Cc: yoann.congal@smile.fr, Andreas Stergiopoulos Subject: [PATCH v2 1/3] ptest-cargo.bbclass: Collect only test binaries and not executables Date: Mon, 17 Nov 2025 16:59:25 +0100 Message-ID: <20251117155927.427462-2-andreas.stergiopoulos@smile.fr> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251117155927.427462-1-andreas.stergiopoulos@smile.fr> References: <20251117155927.427462-1-andreas.stergiopoulos@smile.fr> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 17 Nov 2025 16:00:04 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/226497 This commit changes the files that are collected during compilation of tests. Till now, all the produced binaries were collected. This commit changes the conditions inside the loop so that only the binary and integration tests are collected. To do this, the variable "test" of the object "profile" is examined. Tests are all compiled with the "test" profile, whereas the binaries are compiled with the "dev" profile. Signed-off-by: Andreas Stergiopoulos --- No changes in v2. --- meta/classes-recipe/ptest-cargo.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta/classes-recipe/ptest-cargo.bbclass b/meta/classes-recipe/ptest-cargo.bbclass index 30463e117b..004abb40f7 100644 --- a/meta/classes-recipe/ptest-cargo.bbclass +++ b/meta/classes-recipe/ptest-cargo.bbclass @@ -55,7 +55,8 @@ python do_compile_ptest_cargo() { current_manifest_path = os.path.normpath(data['manifest_path']) common_path = os.path.commonpath([current_manifest_path, project_manifest_path]) if common_path in [manifest_dir, current_manifest_path]: - if (data['target']['test'] or data['target']['doctest']) and data['executable']: + # Collect tests (integration and unit) and nothing but tests + if (data['target']['test'] or data['target']['doctest']) and data['executable'] and data['profile']['test']: test_bins.append(data['executable']) except (KeyError, ValueError) as e: # skip lines that do not meet the requirements From patchwork Mon Nov 17 15:59:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Stergiopoulos X-Patchwork-Id: 74809 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 6CC38CEBF92 for ; Mon, 17 Nov 2025 16:00:04 +0000 (UTC) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.12982.1763395196431914744 for ; Mon, 17 Nov 2025 07:59:56 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=hrEJs0CR; spf=pass (domain: smile.fr, ip: 209.85.128.45, mailfrom: andreas.stergiopoulos@smile.fr) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4779adb38d3so15824075e9.2 for ; Mon, 17 Nov 2025 07:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1763395195; x=1763999995; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=plB1TprOU2XhKYxz+gpLLYs/+lq4gMA7OO2Ail1qdQg=; b=hrEJs0CRthdPqTq3I3cACn4ceHm0845LZVOWF7vwkkr8/jDjUwKyk0KDsa4XI2fEb1 Jjry67L1tmWDKF57MdER1qrXDk9ueyzvMEVD6TI+gTjcK7oC9Kf5gOz68NZJjcz7H2c+ jFQYAwsX/uLT1UVZTDEyZDrZ/aevtkyoSyoWM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763395195; x=1763999995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=plB1TprOU2XhKYxz+gpLLYs/+lq4gMA7OO2Ail1qdQg=; b=i+96yKHgy7Jq7/n2Iar8YAXr74O6AGo0mY5ZPITNJkeXpTdjxnq0Hz4hcaDhmBVOy4 okdXG+vJbm41+M/z0TfmOeEq0gFBCdKNNfXXUODvhgF7zool4VaY4GMpy01LFBBo3eBU stdZgeERJqOKOrtQNwEubK9+/53Vq7K3a0IJY9NTKbGIW9q78ZpV3EmZ7Y0Qbjv2dwlj u11bHO0bxrK2BAclb2EsABmdLwBwCzXELpPOgsX53yDVnBR8cf4k5y6wt9VPJkKFtkdG OblwrKvAVUJjj5LgSvqXqkynwfqaY8GVGzqm5rf3T2C4IChOFB4OKdHbSq9ofDNCC9gX LCzg== X-Gm-Message-State: AOJu0Yy6vQtGns/11slrtD/GKdQZaS+6sTMMxpy/nZOQi5S4J7QAqmRb ooy11G69xA8DHudxcUbKEhMI344RhLygSuTar+h0qWsaBo24v+/NrQo35cZScBehADuZ4woWswW Zfbd8 X-Gm-Gg: ASbGnctRR4huxl5RpRH66jZkUm/+YtaIZE0R1hOEHhgHO0sbAGVHcZJa9Lpt/3m4y/v iVMnk3IoHz6aUFRVt3hsre5/5vVeHdXAHcvipD4uzWzOuAZXOc1XdXy7dSQ8+K84odps7tG+nWL aIC8fqwp70vVfmv4/x5ClgKCoDvwcJp1MinhbtEIZqhssFvFJNCIZUYCpHapNxqr/V+00EDHJds fm+kU1/Tc7q0lY79tIUCjiwcG/n9M/RmvLx/UShCY3zvof938UBnCDfU6ab1owfJ0rlEuNvFwmm Vno/3SNktY6dy+V2vimM57WfNDnBQs0e24yzp3t/Cy9aLgLoBT+F7sSd9+s2eNZnw98W1mpM4BJ pbccUNOu0Fhc6bQxc3Ak5yoZEHR8/nOH0dytb4VdJqrAaDfcss1oV+xUdcPXgRTKcPOomr9b7Y2 D7yB55jV8aIqx1HwCJMUpqKbnWeKqG282J02TDJZ7QwKEg99HhJghBfJntqJDtGhUGRUekTGFWx hc94rnVs5g6L9VMX0XLa3jaKdDQacI= X-Google-Smtp-Source: AGHT+IG6trLuMi+f86tWVbTFuV3lg7t7TJ1vM/qDSht+8GijxxZnSkiGl0eQrv2uQ6wWSQmjSjbpgA== X-Received: by 2002:a05:600c:4505:b0:45d:e28c:875a with SMTP id 5b1f17b1804b1-4778feb255emr141253965e9.31.1763395194657; Mon, 17 Nov 2025 07:59:54 -0800 (PST) Received: from FRSMI25-PILS.idf.intranet (static-css-ccs-204145.business.bouyguestelecom.com. [176.157.204.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47787daab3fsm340609225e9.0.2025.11.17.07.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Nov 2025 07:59:54 -0800 (PST) From: Andreas Stergiopoulos To: openembedded-core@lists.openembedded.org Cc: yoann.congal@smile.fr, Andreas Stergiopoulos Subject: [PATCH v2 2/3] cargo.bbclass: Collect installation paths of executable binaries Date: Mon, 17 Nov 2025 16:59:26 +0100 Message-ID: <20251117155927.427462-3-andreas.stergiopoulos@smile.fr> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251117155927.427462-1-andreas.stergiopoulos@smile.fr> References: <20251117155927.427462-1-andreas.stergiopoulos@smile.fr> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 17 Nov 2025 16:00:04 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/226498 All the binary executables that are installed in the image are collected along with their paths and then added to the cargo_bin_exe_paths file. This file is then used for the CARGO_BIN_EXE_ environment variables, used by the integration tests. Signed-off-by: Andreas Stergiopoulos --- No changes in v2. --- meta/classes-recipe/cargo.bbclass | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meta/classes-recipe/cargo.bbclass b/meta/classes-recipe/cargo.bbclass index 2dd28e95d3..167040cb81 100644 --- a/meta/classes-recipe/cargo.bbclass +++ b/meta/classes-recipe/cargo.bbclass @@ -58,6 +58,7 @@ cargo_do_compile () { cargo_do_install () { local have_installed=false + binary_exe_path_list="${B}/binary_exe_path_list" for tgt in "${B}/target/${CARGO_TARGET_SUBDIR}/"*; do case $tgt in *.so|*.rlib) @@ -83,6 +84,8 @@ cargo_do_install () { install -d "${D}${bindir}" install -m755 "$tgt" "${D}${bindir}" have_installed=true + # Append the install path of the executable to the bin_exe list + echo "${bindir}/$(basename ${tgt})" >> ${binary_exe_path_list} fi ;; esac From patchwork Mon Nov 17 15:59:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Stergiopoulos X-Patchwork-Id: 74808 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 5744DCE8D6B for ; Mon, 17 Nov 2025 16:00:04 +0000 (UTC) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.12983.1763395196996019721 for ; Mon, 17 Nov 2025 07:59:57 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@smile.fr header.s=google header.b=rtg9H8zk; spf=pass (domain: smile.fr, ip: 209.85.128.44, mailfrom: andreas.stergiopoulos@smile.fr) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4779d47be12so15106795e9.2 for ; Mon, 17 Nov 2025 07:59:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smile.fr; s=google; t=1763395195; x=1763999995; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dSH2UzmDeMnq1dG2amjEfVhAlWjPR8C+SaUswyvjR6k=; b=rtg9H8zkfqiuonxsB2lDE+S2M0xcb09CBq4Yx9U/fwUq8fFqwE/mfPZrThC7aBeqp0 mQV2utvmzKIC09m3FsQaZGvc81M8hE4yI/CjRpHwq+ReBXXkJ9s+32fgIur4O8EnfQvz pBqTGfAAuN9hzvog0AnM2WctD33FMwiRtf1q4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763395195; x=1763999995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=dSH2UzmDeMnq1dG2amjEfVhAlWjPR8C+SaUswyvjR6k=; b=tXg0FBq1m/UXUYRdEBn2V8FHGwayXE0HlpZunWISvtRfsrhVCDNf3zzFWD7M8Acwyz 40d692Qx7FvHT0E2Scrz87P8DASXwI0CjM8cNMvTIt+PLFh1PeIbJYAR7yZllG1GMV/O Bp0V/7eSAlP70Qu2knCNNbN27FRYDZnw9KRieavvuL/omZZbNcoRFpPwfM/E4EUDlkwb uuqoC1s1XVbezmoOvsIzwb1cJ4RlfxuI9c6NudXp7eaxvXd8ZdskxjoW0SEXnTKLXgxh 2ZDL/aRCI+wh1F4TtSvi34T7ZhDBWd4RmDkQS8VAcXz4eCcwcsUUubyS4Ar0nqgP0nPx cyNg== X-Gm-Message-State: AOJu0YzyGu+PEkuS8PqgG7vCVjqdyzv6ij+inkaomp6iE3c67BG7/OdU qRIOiSvmMSJ8CADiPOZKvXYaIjtLT+dlbL6Hj/zcPM+7E2ylX7HEbAlTUEf0kUIy/ytjRVZyNdf DDhPc X-Gm-Gg: ASbGnctmpAz0zyi0Sw7/EcZ7hM6ELOj69WyklnPOhFPOosrXIVcRICvyS7pQo3DpZZx XamoUJfaGlVh0elbtEnFRh6K3l9IRjqQmklEgbXdQB8AyaT1mdG5MLiw/uiAi1a9T7ynfSBWniK dIpYCFc4g151G9d46PuEG125fj1e/hsb3Ht2CJ/F4QRlJcvLLPrdOhALiyDKih4NMhTShLMT8Ec K58vD8z3QFTgQZBXja3lPsnO7oxJJBEQuU55bv4Y2e4ru+0V+GVGTWhjd0YTK/3LzPZu279sGJF e5LCyr1nOaLngntKu/KUjdNFRf6cWTLui7mbAeS0mw2h+rNEbadmY5UXDBCL7Di4zp2OOVYhLRS tb4uIx9TklSLh8cPv5ZKvCV85RVv96aBhEz6yTPNsZ6jTLIg6HCp4UnRvM8ntBM+QppmFOWMUFZ VP8Bt6HHbx74ofF5H0F+vo+s0T0grPh2XxuZJH6oH85yMbBWafprD88wHPwU6ybLZwtmaFNnigZ cs9HtDsW929WNswL6PN9JvAhd20ex0= X-Google-Smtp-Source: AGHT+IF6uz+i2cWa8NBQH28c1PKc+WyKuRnKiIv1dZORFVp10cheAW/ZHKYFNJZioDDAV990hszAVQ== X-Received: by 2002:a05:600c:1986:b0:46e:35a0:3587 with SMTP id 5b1f17b1804b1-4778fea7037mr117427995e9.27.1763395195091; Mon, 17 Nov 2025 07:59:55 -0800 (PST) Received: from FRSMI25-PILS.idf.intranet (static-css-ccs-204145.business.bouyguestelecom.com. [176.157.204.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47787daab3fsm340609225e9.0.2025.11.17.07.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Nov 2025 07:59:54 -0800 (PST) From: Andreas Stergiopoulos To: openembedded-core@lists.openembedded.org Cc: yoann.congal@smile.fr, Andreas Stergiopoulos Subject: [PATCH v2 3/3] ptest-cargo.bbclass: Add support for CARGO_BIN_EXE_ environment variables Date: Mon, 17 Nov 2025 16:59:27 +0100 Message-ID: <20251117155927.427462-4-andreas.stergiopoulos@smile.fr> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251117155927.427462-1-andreas.stergiopoulos@smile.fr> References: <20251117155927.427462-1-andreas.stergiopoulos@smile.fr> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 17 Nov 2025 16:00:04 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/226499 This commit takes the installation paths collected during package installation and sets them up as environment variables in the run-ptest script. This is necessary as the integration tests require the executable binary to run successfully. The paths collected are not those of the artifacts created during cargo test, but the paths where the artifacts in the system. The intention for this choice was to ensure that the tested binaries are those who are actually executed by the user and vice versa. Env has been used instead of export, as export explicitly does not support dashes "-" when setting up environment variables. The execution environment is set up inside the function exec_in_env. For every binary executable artifact collected, one environment variable is added irregardles of whether it is needed or not. Signed-off-by: Andreas Stergiopoulos --- Changes in v2: * Remove the "-" when invoking env. The "-" implies a new empty environment. * Improve how spaces are printed for better-looking auto-generated code. --- meta/classes-recipe/ptest-cargo.bbclass | 41 +++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/meta/classes-recipe/ptest-cargo.bbclass b/meta/classes-recipe/ptest-cargo.bbclass index 004abb40f7..68f0090b74 100644 --- a/meta/classes-recipe/ptest-cargo.bbclass +++ b/meta/classes-recipe/ptest-cargo.bbclass @@ -6,6 +6,11 @@ RUST_TEST_ARGS[doc] = "Arguments to give to the test binaries (e.g. --shuffle)" # I didn't find a cleaner way to share data between compile and install tasks CARGO_TEST_BINARIES_FILES ?= "${B}/test_binaries_list" +# Integration tests usually require the application binary to execute successfully. +# This file contains the paths in the image where all the crate executable artifacts +# reside. +CARGO_BIN_EXE_PATHS ?= "${B}/binary_exe_path_list" + # Sadly, generated test binaries have no deterministic names (https://github.com/rust-lang/cargo/issues/1924) # This forces us to parse the cargo output in json format to find those test binaries. python do_compile_ptest_cargo() { @@ -84,6 +89,7 @@ python do_install_ptest_cargo() { pn = d.getVar("PN") ptest_path = d.getVar("PTEST_PATH") cargo_test_binaries_file = d.getVar('CARGO_TEST_BINARIES_FILES') + cargo_bin_exe_paths = d.getVar('CARGO_BIN_EXE_PATHS') rust_test_args = d.getVar('RUST_TEST_ARGS') or "" ptest_dir = os.path.join(dest_dir, ptest_path.lstrip('/')) @@ -94,6 +100,14 @@ python do_install_ptest_cargo() { for line in f.readlines(): test_bins.append(line.strip('\n')) + # Read the file that contains the paths to the executable binaries. This step is + # necessary in order to successfully set up the execution environment for integration tests. + cargo_bin_exes = [] + if os.path.exists(cargo_bin_exe_paths): + with open(cargo_bin_exe_paths, "r") as f: + for line in f.readlines(): + cargo_bin_exes.append(line.strip('\n')) + test_paths = [] for test_bin in test_bins: shutil.copy2(test_bin, ptest_dir) @@ -106,11 +120,34 @@ python do_install_ptest_cargo() { f.write("#!/bin/sh\n") else: f.write(f"\necho \"\"\n") - f.write(f"echo \"## starting to run rust tests ##\"\n") + f.write(f"echo \"## starting to run rust tests ##\"\n") + + # For the integration tests, cargo uses the CARGO_BIN_EXE_ environment variable to + # communicate the location of the binary executable. More info on this variable can be + # found in the link: (https://doc.rust-lang.org/cargo/reference/environment-variables.html). + + # This environment variable is exported by cargo automatically during compilation. Making it + # also available during runtime is a very powerful tool as it allows the ptest framework to + # run the integration tests on the actual executables installed in the target, no matter the + # installation location. + + # By using env we ensure that we will be able to create environment variables even for apps + # whose name contains dashes "-", which is not supported by export. For every binary executable + # produced by the rust compiler, one environment variable is added. + + f.write("exec_in_env () {\n") + f.write(" env ") + for cargo_bin_exe in cargo_bin_exes: + f.write(f"CARGO_BIN_EXE_{os.path.basename(cargo_bin_exe)}={cargo_bin_exe} \\\n") + f.write(" ") + + f.write("\"$@\"\n") + f.write("}\n") + f.write("if [ -z \"$rc\" ]; then rc=0; fi\n") for test_path in test_paths: script = textwrap.dedent(f"""\ - if ! {test_path} {rust_test_args} + if ! exec_in_env {test_path} {rust_test_args} then rc=1 echo "FAIL: {test_path}"