Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp976834ybl; Fri, 24 Jan 2020 13:03:41 -0800 (PST) X-Google-Smtp-Source: APXvYqyK6oOsRu9C4mrAtkWnneZIgpk9zQ0UZCWj4KDNDcAiLYOiSKqbndpQuSLHBgW4bTwBtVHL X-Received: by 2002:aca:5083:: with SMTP id e125mr560777oib.96.1579899821788; Fri, 24 Jan 2020 13:03:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579899821; cv=none; d=google.com; s=arc-20160816; b=q2IjaD7VhXmPEVvmeHyOyoRfWntng/JXdROveE2Ji0l9pHvKREXUoP6eSqNrxtjxhS AnZYc+0jcWnWYYwSTOcvK8ybsvNBRhnu7SjNWmClbc2p7EtHuokuMmpfvpABXpTgOzEl 9tlCYvo53Zc0vHvUjb0pvEoKL1wwnXvZF7ZseZCNFMRGcoGVvYuOt4ausxNCfPt37TMh H7EnnhfqIaSOA8piggfXARFE/UHLFY2y129nAg5JfadqYv5RAbQPokRcpS2UePaX0uB9 MhPzv2k33QxJ3JLqkX+KH3PsBqbHQJEGcCTp4uRY4FsRKTB0KlbyKU99+9afTiGIwDDr 4u4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=ysPE3p2XWj7/TrBPX839YWYofjGrv+ukgcnjipDcxD8=; b=P+X86ARlzHu7dsZAcmJZwNuOo6IBQOMsLnVsfOsVkWO4e61d/ewg/q8UFB4SfGgPEo 2csR8C5DqCrOD+bm1XyHs0YtxhCvAbxtZZSCPk6/wCgig/lnp2aSoPKxNdDEr2jgYFyu 6DESPSz4V8rDcaaGyjOHksvBDCrjSb4Sg22lw/gVoNmd8DpzgsyUqvhYsIGUgigH+cG0 788ciOzlaoGsefF02leGsj6+G0M65J9oyYea8okbiaK+xq7DOypMSgqLn3DRR7oMy5lA nJfJTh6vYpj1Mz36Fm4CkfMhOjvqcZ8tO4d+2BWaSaAP/NNZ7KW9+7e3bfv+TL6sM9Bp K0Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="aCZohpD/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i25si310446oii.259.2020.01.24.13.03.29; Fri, 24 Jan 2020 13:03:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="aCZohpD/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392290AbgAXTqH (ORCPT + 99 others); Fri, 24 Jan 2020 14:46:07 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:46362 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391472AbgAXTqG (ORCPT ); Fri, 24 Jan 2020 14:46:06 -0500 Received: by mail-pf1-f202.google.com with SMTP id i6so1842071pfa.13 for ; Fri, 24 Jan 2020 11:46:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=ysPE3p2XWj7/TrBPX839YWYofjGrv+ukgcnjipDcxD8=; b=aCZohpD/BNjKcM0p5BeVlgSIAu0Fky6Y7QlkpQiQf9vAdhay2bbYnRC33O8zXWenq+ ldnpRcpscbd3/HIraLq4gNlexORFSjxyCzZ5fnQSJWQWyMjVq1dRqRUEo8QXJqBsLe0j NoRYG+9BMIPCxApCuMuDLIP7nAfnW0qPG7KJtUvyOLVCD07qjOgpmcGlaGQkWeTgwdE0 jjLEJyKnRfS4QSNobPBxTCDQmyS/DFHVNHwpALgT3oQ9NYxsuoO3WY9pWVAUZwu+6297 k+bxm6TQ4QCwfLDJhq3cr+KxSNphoknTX0eoHX99oDIOkWkkv3B3YLhhaGTbEUy/v/8p EqUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=ysPE3p2XWj7/TrBPX839YWYofjGrv+ukgcnjipDcxD8=; b=pH846WNWJvstPfscBlYeSjRCse9bxfxSJZc5pq91LVJcjHKk0sklDk7fA/PjDYiXMd Otg1mA1fmk8pRp/Ub6qLIPghVbfcxNcZsgRbaWsf26Co1zgaZDb+aeR8WcA0Q9vEcIuz w5Tu+PH8zEJ6RPC80P7rlERJBFmqbbcg8XnhdzHBKuOcs6HQBtzAE8gZOaJczHuRwHBG 8fnOfWvhWxy4aWYzxmx2JaOV5VJwXHb1NULSpwDkUmTOvqCeVGuvvWUgZ9os3TiJBPMm AGQ4D3bDcD7SjIN5rdYboUcazqVdMhp+T37NtmiDy2F9tY8OdTyGwaoUSp2wxmwt8BB9 T4sg== X-Gm-Message-State: APjAAAX1DZhluiFi35KHgrhD6SrQCje4TtDf9VzO9FDxCQ6Ar6bvOIBM bF+Kca3+j2kMD1xZUULhCLfV69DH1W2srg== X-Received: by 2002:a63:778c:: with SMTP id s134mr5650896pgc.451.1579895165698; Fri, 24 Jan 2020 11:46:05 -0800 (PST) Date: Fri, 24 Jan 2020 11:45:08 -0800 Message-Id: <20200124194507.34121-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog Subject: [PATCH] Fix linked-list KUnit test when run multiple times From: David Gow To: brendanhiggins@google.com, shuah@kernel.org Cc: kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, alan.maguire@oracle.com, David Gow Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A few of the lists used in the linked-list KUnit tests (the for_each_entry{,_reverse} tests) are declared 'static', and so are not-reinitialised if the test runs multiple times. This was not a problem when KUnit tests were run once on startup, but when tests are able to be run manually (e.g. from debugfs[1]), this is no longer the case. Making these lists no longer 'static' causes the lists to be reinitialised, and the test passes each time it is run. While there may be some value in testing that initialising static lists works, the for_each_entry_* tests are unlikely to be the right place for it. Signed-off-by: David Gow --- lib/list-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/list-test.c b/lib/list-test.c index 76babb1df889..ee09505df16f 100644 --- a/lib/list-test.c +++ b/lib/list-test.c @@ -659,7 +659,7 @@ static void list_test_list_for_each_prev_safe(struct kunit *test) static void list_test_list_for_each_entry(struct kunit *test) { struct list_test_struct entries[5], *cur; - static LIST_HEAD(list); + LIST_HEAD(list); int i = 0; for (i = 0; i < 5; ++i) { @@ -680,7 +680,7 @@ static void list_test_list_for_each_entry(struct kunit *test) static void list_test_list_for_each_entry_reverse(struct kunit *test) { struct list_test_struct entries[5], *cur; - static LIST_HEAD(list); + LIST_HEAD(list); int i = 0; for (i = 0; i < 5; ++i) { -- 2.25.0.341.g760bfbb309-goog