From patchwork Thu Feb 2 15:54:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 650447 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6537C64ED8 for ; Thu, 2 Feb 2023 15:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233089AbjBBPzD (ORCPT ); Thu, 2 Feb 2023 10:55:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233150AbjBBPy7 (ORCPT ); Thu, 2 Feb 2023 10:54:59 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2567C65F20 for ; Thu, 2 Feb 2023 07:54:48 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id g16so927222ilr.1 for ; Thu, 02 Feb 2023 07:54:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=QviJa5qI39tAiH+EiEAx1tSCEeoDFb1KygwG46vo/pc=; b=IByEkE/QTfZyYgc54DudkJ9C4OzJ7wrd15HwWBREBzET6HrzJl4/tJH6pm+20aGdjB 4Un4q1V99zCeU+B0LEJqJr94BIJcpbx9ey/qAAsZUOwmDjtbYwVWmUNKc7WytVwT+6t4 wYbv24H6hq1cCRKWKen2A1Gk+5xIW4Ofvspjg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QviJa5qI39tAiH+EiEAx1tSCEeoDFb1KygwG46vo/pc=; b=7QaWLY0GKRPbf7UYC1s0HmJ+WuBkc+GxiKWGddgeVqQCvh6OAHbnL+AXqvNm1RwYEZ A8WQAG6U4LimSdQOnLmHJpr/jfhl35GwEU/i1qi4+j7jAd1P1isFC5NeBwjkJMEZ+WJm Wk4ExeY7EKNywFUQeZi4msTuxPivUklKNHOaiiGxSF9UkPIHF6iEHbFTUAybbmFxhlIm BbthJVGaLYYtBHmc+6zaXdRNXnxViFMa89Rzdo4iQxaZpVK8m5gP10FBEol3dgsg/PMH vtirgb6ON8O2VkjDLMl4Zs7rgR7JgXuv+RjOmp7S6hqnHE7moQZxpM2zyF1BI2rm0mS+ mlJQ== X-Gm-Message-State: AO0yUKWk1bS/lOkcUxiTQLgKqJG6Q2WvD/oNu2xSOwGLAwBiJ8vF8CbY qcQol8ngx6LIjkEpeSMXBnWyTw== X-Google-Smtp-Source: AK7set9aAW6w80jF/hDK5HoNXYRly8m8EogWAmAnxNP+3TiB5O07eQGyh9B95hKOfJt0zfnDjInVMw== X-Received: by 2002:a05:6e02:152:b0:310:cc70:a152 with SMTP id j18-20020a056e02015200b00310cc70a152mr4451064ilr.2.1675353287260; Thu, 02 Feb 2023 07:54:47 -0800 (PST) Received: from [192.168.1.128] ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id d191-20020a0262c8000000b00346a98b0a76sm23084jac.77.2023.02.02.07.54.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Feb 2023 07:54:46 -0800 (PST) Message-ID: <3e3c7d22-6338-87e0-314a-883429ba8ff0@linuxfoundation.org> Date: Thu, 2 Feb 2023 08:54:45 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US To: Linus Torvalds Cc: Shuah Khan , Brendan Higgins , David Gow , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah From: Shuah Khan Subject: [GIT PULL] KUnit fixes update for Linux 6.2-rc7 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Hi Linus, Please pull the following KUnit fixes update for Linux 6.2-rc7. This KUnit fixes update for Linux 6.2-rc7 consists of 3 fixes to bugs that cause kernel crash, link error during build, and a third to fix kunit_test_init_section_suites() extra indirection issue. diff is attached. thanks, -- Shuah ---------------------------------------------------------------- The following changes since commit 88603b6dc419445847923fcb7fe5080067a30f98: Linux 6.2-rc2 (2023-01-01 13:53:16 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-kunit-fixes-6.2-rc7 for you to fetch changes up to 254c71374a70051a043676b67ba4f7ad392b5fe6: kunit: fix kunit_test_init_section_suites(...) (2023-01-31 09:10:38 -0700) ---------------------------------------------------------------- linux-kselftest-kunit-fixes-6.2-rc7 This KUnit fixes update for Linux 6.2-rc7 consists of 3 fixes to bugs that cause kernel crash, link error during build, and a third to fix kunit_test_init_section_suites() extra indirection issue. ---------------------------------------------------------------- Arnd Bergmann (1): kunit: Export kunit_running() Brendan Higgins (1): kunit: fix kunit_test_init_section_suites(...) Rae Moar (1): kunit: fix bug in KUNIT_EXPECT_MEMEQ include/kunit/test.h | 6 +++--- lib/kunit/assert.c | 40 +++++++++++++++++++++++++--------------- lib/kunit/test.c | 1 + 3 files changed, 29 insertions(+), 18 deletions(-) ---------------------------------------------------------------- diff --git a/include/kunit/test.h b/include/kunit/test.h index 87ea90576b50..08d3559dd703 100644 --- a/include/kunit/test.h +++ b/include/kunit/test.h @@ -303,7 +303,6 @@ static inline int kunit_run_all_tests(void) */ #define kunit_test_init_section_suites(__suites...) \ __kunit_test_suites(CONCATENATE(__UNIQUE_ID(array), _probe), \ - CONCATENATE(__UNIQUE_ID(suites), _probe), \ ##__suites) #define kunit_test_init_section_suite(suite) \ @@ -683,8 +682,9 @@ do { \ .right_text = #right, \ }; \ \ - if (likely(memcmp(__left, __right, __size) op 0)) \ - break; \ + if (likely(__left && __right)) \ + if (likely(memcmp(__left, __right, __size) op 0)) \ + break; \ \ _KUNIT_FAILED(test, \ assert_type, \ diff --git a/lib/kunit/assert.c b/lib/kunit/assert.c index f5b50babe38d..05a09652f5a1 100644 --- a/lib/kunit/assert.c +++ b/lib/kunit/assert.c @@ -241,24 +241,34 @@ void kunit_mem_assert_format(const struct kunit_assert *assert, mem_assert = container_of(assert, struct kunit_mem_assert, assert); - string_stream_add(stream, - KUNIT_SUBTEST_INDENT "Expected %s %s %s, but\n", - mem_assert->text->left_text, - mem_assert->text->operation, - mem_assert->text->right_text); + if (!mem_assert->left_value) { + string_stream_add(stream, + KUNIT_SUBTEST_INDENT "Expected %s is not null, but is\n", + mem_assert->text->left_text); + } else if (!mem_assert->right_value) { + string_stream_add(stream, + KUNIT_SUBTEST_INDENT "Expected %s is not null, but is\n", + mem_assert->text->right_text); + } else { + string_stream_add(stream, + KUNIT_SUBTEST_INDENT "Expected %s %s %s, but\n", + mem_assert->text->left_text, + mem_assert->text->operation, + mem_assert->text->right_text); - string_stream_add(stream, KUNIT_SUBSUBTEST_INDENT "%s ==\n", - mem_assert->text->left_text); - kunit_assert_hexdump(stream, mem_assert->left_value, - mem_assert->right_value, mem_assert->size); + string_stream_add(stream, KUNIT_SUBSUBTEST_INDENT "%s ==\n", + mem_assert->text->left_text); + kunit_assert_hexdump(stream, mem_assert->left_value, + mem_assert->right_value, mem_assert->size); - string_stream_add(stream, "\n"); + string_stream_add(stream, "\n"); - string_stream_add(stream, KUNIT_SUBSUBTEST_INDENT "%s ==\n", - mem_assert->text->right_text); - kunit_assert_hexdump(stream, mem_assert->right_value, - mem_assert->left_value, mem_assert->size); + string_stream_add(stream, KUNIT_SUBSUBTEST_INDENT "%s ==\n", + mem_assert->text->right_text); + kunit_assert_hexdump(stream, mem_assert->right_value, + mem_assert->left_value, mem_assert->size); - kunit_assert_print_msg(message, stream); + kunit_assert_print_msg(message, stream); + } } EXPORT_SYMBOL_GPL(kunit_mem_assert_format); diff --git a/lib/kunit/test.c b/lib/kunit/test.c index c9ebf975e56b..890ba5b3a981 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -21,6 +21,7 @@ #include "try-catch-impl.h" DEFINE_STATIC_KEY_FALSE(kunit_running); +EXPORT_SYMBOL_GPL(kunit_running); #if IS_BUILTIN(CONFIG_KUNIT) /*