From patchwork Wed Jun 14 06:55:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 692569 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp790064wru; Tue, 13 Jun 2023 23:56:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ76t3xUxC+AIsvdqtGE92/MEtfQvtTBbbiW1R8IUbB+iW/2EeBneW50npKb2PQy0SzpL6nD X-Received: by 2002:a05:6808:34a:b0:39a:9bad:8d3 with SMTP id j10-20020a056808034a00b0039a9bad08d3mr8472134oie.40.1686725768576; Tue, 13 Jun 2023 23:56:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686725768; cv=none; d=google.com; s=arc-20160816; b=KGKEHvosfcrwTgkXlMD5bOub9PUgV+mLrhNKLToJXqfjMEIY3vo4pGBZTxj33BzpCe YPUXEoJw9Z08NT8UDS8SP4HDcqIVsmaZBWZZIX6kvmlEauFt+kS3la33Zsn2xPo57/bg IBf3xHsqccA6esMBUlZCmDzfzpfe+4BoDXFKIltzE6et7KMvL204/VyNdcbWeTD9kGZ9 poLHj953msLH1RJntQrT7OSC+LCNaurxX74f+hvKfWMKfpg2c6hmz/Yo8IeRztSuFJLG 0Asep4EZ+JwdEwKp31OPGBB93H7oIVl/N81ihHTSf60fE75YyekRVXYghfGk7+bkOOD1 onsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=eHqmGFwmLU/9PHavSWJyGlM6Covf11F6H2T75TK6VFA=; b=pRHEC16+VaKar3f4hgYgoSoKyouNcGzzh2PQo8XVDJk1fQe2+OFS96q0/fpkCnV5IF DJkw0qzuDk3E8FXmzKY1CoIxo6nFzCPX85RLkKDNcIdiAzZROo6n09fAzEQ/s+Bk5z4c rUhurSU28EycOm0qCXeVtlJwMVAUlW0gliWm5TyDvqUwvEH2U8LIcb+kwPbqVWu4lJ2f htjmfHXvkHT/2Y7NVqhtqCMsYaPp5dX8DfC7bClwMp64hdm55uGH4n8yKt66YrjNyxIn vLXwnkwc7gntsibSO/zFj+UjtTwOtbY54ChMHVDQHpYll+xZk0EmQ0MOEHW3Tr+erWXY f8lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QEaJdmM5; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id o14-20020a17090ac70e00b0024e01bbc60asi4650413pjt.117.2023.06.13.23.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 23:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QEaJdmM5; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BF58485F50; Wed, 14 Jun 2023 08:55:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="QEaJdmM5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1A13B85FA5; Wed, 14 Jun 2023 08:55:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 012D185DFA for ; Wed, 14 Jun 2023 08:55:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f8cdb12719so2101265e9.1 for ; Tue, 13 Jun 2023 23:55:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686725752; x=1689317752; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eHqmGFwmLU/9PHavSWJyGlM6Covf11F6H2T75TK6VFA=; b=QEaJdmM53Q7wWnqRTdlrxnNYf1KdETHQRb69ddKucczDAM6OBcowdmRf2scobgUxXu rLXtGN70M9J4cWIT/BBZKJsH2OpUEbuNIlW6d7qlNFgjR5aIoVsuRxYYQB6jvF4uI0gs HMzIJOC5f/iKoyfpuknIuwELF3gxnPJDjLeAzlUgJYq4RSYdJ7Ub3mGonbsJerK3lswZ 44FiTJ2zkRFr/5NjoTjZnlDt1WXCN6VZLjVM0VnDpUZGQHq6dARRAj17f1iI8cjW5RlE mR7d0/ZsJkDCVxn2mdr1WEIv9g7CeTc2TxTD5Z112SGZqvHpIUsKDvk8YktAtw0F4vtd TpjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686725752; x=1689317752; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eHqmGFwmLU/9PHavSWJyGlM6Covf11F6H2T75TK6VFA=; b=QvQNFuBm3AOc/0BvPke/z/bpoXVHWOIvVO/07nUA9bGKAQb4MjwrEq8gc1Hx6HgFfE 17Pko6UOIN+M+iO8KdLLSzViaZUK5cUsnV72J8sUKfwMv9cpDA05ovbzuqoylH3lfxka kWgZ4r9rfoQfW58Yszq11eDWLXKMhdpwucnhY3HDiwsfUNjtVk1yhaeeBKf2uWUxijZc Q9oMYuAtttDSFMLJ7E0+q/6uzOTJTsV0HE638Qk67ZZh3+omJJnIPmFVt+X1WWy/brqY Q+IDT6l6hmn5BLS7js7ysmMOzi8mmDlQ0CikXQ+ljqVdei3wgVyEZ3Ka8nufeKxgQT7L YYKw== X-Gm-Message-State: AC+VfDx3X5uGHgRuR6yDqY4OL+qALsarZqTEDHaMJi6mHVZ9p0GakRx/ VZNn2I4kEfFbuLq5iSFPSstR8yvYvUys7lzVYpGiXg== X-Received: by 2002:a7b:c387:0:b0:3f8:c70e:7ee7 with SMTP id s7-20020a7bc387000000b003f8c70e7ee7mr3051884wmj.22.1686725752386; Tue, 13 Jun 2023 23:55:52 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id u3-20020a05600c210300b003f6028a4c85sm16284128wml.16.2023.06.13.23.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 23:55:52 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH v2] efi_selftests: fix controllers repeated selftesting Date: Wed, 14 Jun 2023 09:55:48 +0300 Message-Id: <20230614065549.143485-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Running the controller selftest more than one times fails with => setenv efi_selftest 'controllers' && bootefi selftest Testing EFI API implementation Selected test: 'controllers' Setting up 'controllers' Setting up 'controllers' succeeded Executing 'controllers' Executing 'controllers' succeeded Summary: 0 failures => bootefi selftest Testing EFI API implementation Selected test: 'controllers' Setting up 'controllers' lib/efi_selftest/efi_selftest_controllers.c(280): ERROR: InstallProtocolInterface failed lib/efi_selftest/efi_selftest.c(89): ERROR: Setting up 'controllers' failed Summary: 1 failures There are multiple reason for this. We don't uninstall the binding interface from the controller handle and we don't reset the handle pointers either. So let's uninstall all the protocols properly and reset the handles to NULL on setup(). While at it add a forgotten check when uninstalling protocols from the handle_controller and make sure the number of child controllers is 0 Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- Changes since v1: - Move the binding protocol removal to .teardown() - return EFI_ST_FAILURE if the last count_child_controllers() fails lib/efi_selftest/efi_selftest_controllers.c | 26 ++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) -- 2.39.2 diff --git a/lib/efi_selftest/efi_selftest_controllers.c b/lib/efi_selftest/efi_selftest_controllers.c index d2bbd1c4f65b..79bc86fb0c3a 100644 --- a/lib/efi_selftest/efi_selftest_controllers.c +++ b/lib/efi_selftest/efi_selftest_controllers.c @@ -271,6 +271,8 @@ static int setup(const efi_handle_t img_handle, efi_status_t ret; boottime = systable->boottime; + handle_controller = NULL; + handle_driver = NULL; /* Create controller handle */ ret = boottime->install_protocol_interface( @@ -402,14 +404,36 @@ static int execute(void) /* Check number of child controllers */ ret = count_child_controllers(handle_controller, &guid_controller, &count); - if (ret == EFI_SUCCESS) + if (ret == EFI_SUCCESS || count != 0) { efi_st_error("Uninstall failed\n"); + return EFI_ST_FAILURE; + } + + return EFI_ST_SUCCESS; } + /* + * Tear down unit test. + * + */ +static int teardown(void) +{ + efi_status_t ret; + /* Uninstall binding protocol */ + ret = boottime->uninstall_protocol_interface(handle_driver, + &guid_driver_binding_protocol, + &binding_interface); + if (ret != EFI_SUCCESS) + efi_st_error("Failed to uninstall protocols\n"); + + return ret; +} + EFI_UNIT_TEST(controllers) = { .name = "controllers", .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, .setup = setup, .execute = execute, + .teardown = teardown, };