Received: by 2002:a05:7208:3003:b0:81:def:69cd with SMTP id f3csp175085rba; Tue, 26 Mar 2024 12:28:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxjq3W9T4lbCgbSZt3F1TDIEsTP3Q07c9mGN9SzbyXnmLcQ/cqTQ+hm8UtejqZMEsErFhrrMIIxGa4l/gSjV5BTAbdfCC3lNSQjOg7Qw== X-Google-Smtp-Source: AGHT+IGfZO5NBIezZN/iIDElxd0OPZjhNrKQ151GZ8EvMH4bwAa/228NZeN9BXzWH/dwV7xMR0fI X-Received: by 2002:a05:620a:240a:b0:789:ea35:5f97 with SMTP id d10-20020a05620a240a00b00789ea355f97mr13767092qkn.74.1711481331678; Tue, 26 Mar 2024 12:28:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711481331; cv=pass; d=google.com; s=arc-20160816; b=A/9zb0eyGo0tmg9WzkgQ198t9hEsBgOnNIspLNHA/s7qErVN73K9pKETA7aikTgumq jieHA2rztPWgg316xyivIU88QXThQnXkzMlehz57kOn/7+0gZFxlvuFzuoKk6fcVaT67 uhseI4SpgZemR2f6gBw8yk+K8Ics6WH2riazqYsnHwnRCQghyvqctzZCnlXRERodxjoa 2hnTAit6cJE+XFhgXOjlSBBPcWzTjUEvH5ALgQ0VfGFXkk+P+Px1aZwL4uXS40I16neI mabIThyOuzaHBiFSDLTqzi7LdDUyKgCMLyYhL2XKjdjh7T84JigIlsOiqd6k+a55OUmc YUFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=oMhhYxPXIMzKgR+yyLw0jVFOM6anKrGN9I2uAN6d+Fk=; fh=cF7CRff0Oxie7C8+rT9levuR+xILeBqPc1YIcRdG03c=; b=b696Wtw/3HKZXnznBSDfO1IF8zJxAp3EsZSA8x4O0PZA3atZExLucHiaPbE+Q3CCNW W7SVPzNRNvYvws2nzqGO1QCQ4kWbRLPUCuT+bys4HWCFYyX7QxU7S19GlkNeoi54nKF0 TjJZ2+wnwOOp2Axm/FhVogTgm/MrMAyaJ3o50bP1X9KYlVEVWhcxu3Oaqah4G/Otm9Nw WDBi8fNqHS9GNK/PoYN6eFvaOulIMS24uEpWA7mlLPnfN9PPmbKDimRQtuEHVHkgiJ9q xbAR+XuPm3NkeJyMcT5ngnZ+HZ821fXTj348MBSI69XPFGL+UNq4YppmQVQuhfxFgHT2 /pdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=e51ozD30; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linuxfoundation.org dmarc=pass fromdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-119808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119808-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bi8-20020a05620a318800b00789e73fd464si9424242qkb.466.2024.03.26.12.28.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 12:28:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=e51ozD30; arc=pass (i=1 spf=pass spfdomain=linuxfoundation.org dkim=pass dkdomain=linuxfoundation.org dmarc=pass fromdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-119808-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119808-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6EA911C621B4 for ; Tue, 26 Mar 2024 19:28:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A10613D24C; Tue, 26 Mar 2024 19:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="e51ozD30" Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97E4213CFB3 for ; Tue, 26 Mar 2024 19:28:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711481325; cv=none; b=UpC8H2nL5m5sA8ivLLZXMazPtlv21dP6anNOXXjv4lnO/X2S7wL1ygAy53The5lbnUxD3grDDrx33OwKqTBrMa1oOG97nhvAsfSOBRKSk7sz08YXsgzZtwTh0oKCBoQDKXLqqcVGHm/9t2zMPqcHtFzeGcMbTkvunVZDJxxOg4U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711481325; c=relaxed/simple; bh=bZkcMY6/zNJLzXlN29HNPDWIoq+t5jSFu1zf0pMsBL8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ojzu5C8yQHRBU7JlUHOvNYF5WWBVmcPCVAKFWnXFhJ3XIJ3IxE+QXar9LkSuViNfdhjO5ytaUh1smiTO/H6vfubY/njsN3M7TwRqB0GNW/22SAo7iZ+8EllDxHHLvorneJP89sXM7EuZviodOW+Evss9Xrkf1JT7WFVYewsCoEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org; spf=pass smtp.mailfrom=linuxfoundation.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=e51ozD30; arc=none smtp.client-ip=209.85.166.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linuxfoundation.org Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-3688f1b7848so630995ab.0 for ; Tue, 26 Mar 2024 12:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1711481322; x=1712086122; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=oMhhYxPXIMzKgR+yyLw0jVFOM6anKrGN9I2uAN6d+Fk=; b=e51ozD30OJfZCovJ6HgSscFQR/Y98KmDYpnKPbAxBusX+pBBH0jkj4axA8XW2iEMjj xy02YHeVnwgEmNOdKABpU3szi3W6hQ/ro61Nrg3GSZvVTmPqss7wbhqWVZ8UbuVmg2D0 5fLXjbOk4WCjWjisKaHgGY1lfah5w4mJqE6Ig= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711481322; x=1712086122; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oMhhYxPXIMzKgR+yyLw0jVFOM6anKrGN9I2uAN6d+Fk=; b=iz9s8DolEHDZkfM49zBPJ5jcHBMBlfd6KKFWYtUPECsDPRIaCf3knAgmD1KoDQ/8j8 6rSVLJYvKaZbOzvXXH2ER3Ih3ROSK+s8gtAmkZRnjc3YUSUlBZIt7u6uHNiHNHbYF1NA 81sOxIasIrhClBsG64FUEw9bcI0XMIfHJrObEziK6dWUtLpUNrLKEAbUKVRD6GbtvEM7 /vFscO+azfPs3lV7G6oW6UVCXv2sSpXF32I1WXC6SPww1dCXlNAj7dZeanMGgSt4nL/u oqWvL/tqknWMzJzQP0ZGJWxgbuqsAIGFIw0cRtPXpty+aa7BQTU7CnJJnJn1iKQCr49c n9Bg== X-Forwarded-Encrypted: i=1; AJvYcCV8kr41tOreRpnRlW1eMQfWmx3mVyVk/UeGx7RUN9Ky/tP7w1DRnxvzz3h0yOKh3ZPofNgvZ8M7MZ2eLWfqmXMV+u5gkF3WFdSEx7+H X-Gm-Message-State: AOJu0YxENgj7GOpKRl+5a13vve5W+ndQcp+/STTjB+fRCSC0WIE55Q/F yHX+4i2A4Q8SiMIcRR8A9l3Wc+HfEQt3PRmDHImK5wE8s6/rD4Rc3s4e//pTsws= X-Received: by 2002:a05:6602:88:b0:7d0:2e1b:3135 with SMTP id h8-20020a056602008800b007d02e1b3135mr10946531iob.2.1711481322581; Tue, 26 Mar 2024 12:28:42 -0700 (PDT) Received: from [192.168.1.128] ([38.175.170.29]) by smtp.gmail.com with ESMTPSA id g19-20020a056638061300b0047530552d85sm2890801jar.141.2024.03.26.12.28.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Mar 2024 12:28:42 -0700 (PDT) Message-ID: <0dbe701a-99c1-4606-915e-1f1c67802f64@linuxfoundation.org> Date: Tue, 26 Mar 2024 13:28:41 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftests/harness: Prevent infinite loop due to Assert in FIXTURE_TEARDOWN Content-Language: en-US To: Shengyu Li , shuah@kernel.org Cc: luto@amacapital.net, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, wad@chromium.org, Shuah Khan References: <20240314224323.23201-1-shengyu.li.evgeny@gmail.com> From: Shuah Khan In-Reply-To: <20240314224323.23201-1-shengyu.li.evgeny@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/14/24 16:43, Shengyu Li wrote: > This patch addresses an issue in the selftests/harness where an assertion within FIXTURE_TEARDOWN could trigger an infinite loop. The problem arises because the teardown procedure is meant to execute once, but the presence of failing assertions (ASSERT_EQ(0, 1)) leads to repeated attempts to execute teardown due to the long jump mechanism used by the harness for handling assertions. > > To resolve this, the patch ensures that the teardown process runs only once, regardless of assertion outcomes, preventing the infinite loop and allowing tests to fail. > Please make sure change log is formatted with 70-75 character long lines. Please include information on how you found this problem. Send v2 with that change. > Signed-off-by: Shengyu Li > --- > tools/testing/selftests/kselftest_harness.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h > index 4fd735e48ee7..230d62884885 100644 > --- a/tools/testing/selftests/kselftest_harness.h > +++ b/tools/testing/selftests/kselftest_harness.h > @@ -383,6 +383,7 @@ > FIXTURE_DATA(fixture_name) self; \ > pid_t child = 1; \ > int status = 0; \ > + bool jmp = false; \ > memset(&self, 0, sizeof(FIXTURE_DATA(fixture_name))); \ > if (setjmp(_metadata->env) == 0) { \ > /* Use the same _metadata. */ \ > @@ -399,8 +400,10 @@ > _metadata->exit_code = KSFT_FAIL; \ > } \ > } \ > + else \ > + jmp = true; \ > if (child == 0) { \ > - if (_metadata->setup_completed && !_metadata->teardown_parent) \ > + if (_metadata->setup_completed && !_metadata->teardown_parent && !jmp) \ > fixture_name##_teardown(_metadata, &self, variant->data); \ > _exit(0); \ > } \ thanks, -- Shuah