Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6025165iog; Thu, 23 Jun 2022 09:48:13 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tpwoALrfq0/RXqSUnpWrJGdeu3KLGyQxdWKcEoXbeDDuL1DAvqSW0Yq0Duo33/blK16cK6 X-Received: by 2002:a63:440d:0:b0:401:9e3e:7d2d with SMTP id r13-20020a63440d000000b004019e3e7d2dmr8298198pga.446.1656002893158; Thu, 23 Jun 2022 09:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656002893; cv=none; d=google.com; s=arc-20160816; b=eluvnroS2C4YYQ9a8YviDAI3PkCC9FMkRJWwH1062Pk3Gk/FQU1dJ/cgkl5YSJK7nb asuTQc3UUGLxqVXLbnHrWuw6yfLSiUQ5u8KzC4MgcZd2idIXdum9GTK4AkHmLCNS/EtD pZ3gz6a/zwREbNGz2zhu/d71tl/lANvgaDgM7EOCtEyqgthL6nTC6BNf6YDE9ImvLLL7 utKMVYKvptgicBD5J+Faae7zTV18TpBOS8UpQ3ANkYQ9XKWncaLcfBDU7916E9f1jGtY Q5PVE7pzX+XXa0P+TU+/uaTEq2QdWQj8VSg1wXnMeM13T9mjlzURxW+wgBUXTdAEid3b JiUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=AAlxQgMTHS8WASi4S9BFRIXGatijsC0zjEnIxlEzU0o=; b=JUdGW0a9r76jh7hVNtYbnLfG+36jeCrgRfXr3xi4R5B65sG+ydjfK8dSmEwn/r7Jke msS9JxUSQD0pW4ZTh1BdruAxCQmiPkzONb8F8pWOtvpwuFr19qIuTGoslmPFH3mp/A0q poGRuBL5bfcdjxNbdoF/442iBM7CrBMnAoTGzeQuN/HLmQlGEwp6x2i0WMFKF7SjGQkQ IH1myBECbePYENHOiCpwZkYF4rxH0sAcnOwbL1C+wj5bArHsU8CjsOSponP467DD3Ruc j5wgeI8e7nIdTZk33vUj4avj+nYxHCXq3Il9nfRD58/dDctBICzRSrqEypel7mJjkldU jc9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=c2Opogx1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h18-20020a056a001a5200b0050d8195100bsi31370155pfv.7.2022.06.23.09.47.58; Thu, 23 Jun 2022 09:48:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=c2Opogx1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232294AbiFWQig (ORCPT + 99 others); Thu, 23 Jun 2022 12:38:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232312AbiFWQiY (ORCPT ); Thu, 23 Jun 2022 12:38:24 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE08740E60 for ; Thu, 23 Jun 2022 09:38:23 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id c13so24888157eds.10 for ; Thu, 23 Jun 2022 09:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=AAlxQgMTHS8WASi4S9BFRIXGatijsC0zjEnIxlEzU0o=; b=c2Opogx1Bd/U//9VL4xN3Ue/JcsrrLE/FiXi6Nbwp8mDyOyTL6h8z0ZwfClfqhlC9Z 2E8Hecn/mkFBg/hGr9QnGk1foO5bOUbdW3QdCgYDxP4XNFppRM5x/z7uI1xK/cBIZftA JdMVGpjr50DGlgPiSrNX7Wb7Epu27mlZZCddPUprefJtNP1Fowd+wYwfaA1spO66tkuY XShc1+xoXPbCCYcWko7bva5VYupOwlJaBYwLVKLdYdJiwmGrNN+j0iOUwRZ6sFOVmu3c asBSS0K4EnJmQiTIQIkvXYnn1VnttUK4OK4Oq/ZIQByORMqVzlzVPDLNo4zXiQ1xRzD7 e/zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=AAlxQgMTHS8WASi4S9BFRIXGatijsC0zjEnIxlEzU0o=; b=T9o/X0E0ZVf17pqo7BXvUrKW384qOntTbTuXfghsD/cjcLabYx+f8Z90XMEBD6yLce 5lv0x5BTmilDVL8h/rZk3IVBsfl3+ty0wKmcBjepXsDLUsWZ5wcDZ/aHdgYJsfI4MvR5 claPnoBH+nyFDpA7/nLjaVH3f1mw37AjNt9cjXcgkeJU2LQ1Sg/31jFoTXWsmRFeLS7i nJd5YDWIg0UkI3JUE0GOFPpVvtosYCe/5YzkzAKoVY91YuAcrXJ1rR+JWnC9xmS/b6+G 23NiRVa5LZahiO6tnrwfRTKme5eepHmEp2hemlz0ZooBM1jSgxg8A4waNljhGVe8UfME 4hAw== X-Gm-Message-State: AJIora/AFQXbqsYQQdkcy9RnDKMUQPZp0u7GFq8qbqfBqXhQpsGTZd8L 3rACvOQAI7tf7PRwxl7as05h/eoro1MridY7qStQ1Njq8enBEWJm X-Received: by 2002:a05:6402:5193:b0:435:9a5f:50a8 with SMTP id q19-20020a056402519300b004359a5f50a8mr12033999edd.212.1656002302254; Thu, 23 Jun 2022 09:38:22 -0700 (PDT) MIME-Version: 1.0 References: <20220622041040.202737-1-tzungbi@kernel.org> <20220622041040.202737-5-tzungbi@kernel.org> In-Reply-To: <20220622041040.202737-5-tzungbi@kernel.org> From: Guenter Roeck Date: Thu, 23 Jun 2022 09:38:10 -0700 Message-ID: Subject: Re: [PATCH 4/7] platform/chrome: cros_ec_proto: add Kunit tests for get_host_event To: Tzung-Bi Shih Cc: Benson Leung , Guenter Roeck , "open list:CHROME HARDWARE PLATFORM SUPPORT" , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 21, 2022 at 9:11 PM Tzung-Bi Shih wrote: > > cros_ec_get_host_event() performs some sanity checks, parses > `ec_dev->event_data.data.host_event`, and returns bitmap of > EC_HOST_EVENT_*. > > Add Kunit tests for cros_ec_get_host_event(). > > Signed-off-by: Tzung-Bi Shih Reviewed-by: Guenter Roeck > --- > drivers/platform/chrome/cros_ec_proto_test.c | 59 ++++++++++++++++++++ > 1 file changed, 59 insertions(+) > > diff --git a/drivers/platform/chrome/cros_ec_proto_test.c b/drivers/platform/chrome/cros_ec_proto_test.c > index 64c4b79f7a0c..dce9fa3b9c8d 100644 > --- a/drivers/platform/chrome/cros_ec_proto_test.c > +++ b/drivers/platform/chrome/cros_ec_proto_test.c > @@ -2312,6 +2312,61 @@ static void cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked(struc > } > } > > +static void cros_ec_proto_test_get_host_event_no_mkbp_event(struct kunit *test) > +{ > + struct cros_ec_proto_test_priv *priv = test->priv; > + struct cros_ec_device *ec_dev = &priv->ec_dev; > + int ret; > + > + ec_dev->mkbp_event_supported = 0; > + > + ret = cros_ec_get_host_event(ec_dev); > + KUNIT_EXPECT_EQ(test, ret, 0); > +} > + > +static void cros_ec_proto_test_get_host_event_not_host_event(struct kunit *test) > +{ > + struct cros_ec_proto_test_priv *priv = test->priv; > + struct cros_ec_device *ec_dev = &priv->ec_dev; > + int ret; > + > + ec_dev->mkbp_event_supported = 1; > + ec_dev->event_data.event_type = EC_MKBP_EVENT_FINGERPRINT; > + > + ret = cros_ec_get_host_event(ec_dev); > + KUNIT_EXPECT_EQ(test, ret, 0); > +} > + > +static void cros_ec_proto_test_get_host_event_wrong_event_size(struct kunit *test) > +{ > + struct cros_ec_proto_test_priv *priv = test->priv; > + struct cros_ec_device *ec_dev = &priv->ec_dev; > + int ret; > + > + ec_dev->mkbp_event_supported = 1; > + ec_dev->event_data.event_type = EC_MKBP_EVENT_HOST_EVENT; > + ec_dev->event_size = 0xff; > + > + ret = cros_ec_get_host_event(ec_dev); > + KUNIT_EXPECT_EQ(test, ret, 0); > +} > + > +static void cros_ec_proto_test_get_host_event_normal(struct kunit *test) > +{ > + struct cros_ec_proto_test_priv *priv = test->priv; > + struct cros_ec_device *ec_dev = &priv->ec_dev; > + int ret; > + > + ec_dev->mkbp_event_supported = 1; > + ec_dev->event_data.event_type = EC_MKBP_EVENT_HOST_EVENT; > + ec_dev->event_size = sizeof(ec_dev->event_data.data.host_event); > + put_unaligned_le32(EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC), > + &ec_dev->event_data.data.host_event); > + > + ret = cros_ec_get_host_event(ec_dev); > + KUNIT_EXPECT_EQ(test, ret, EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC)); > +} > + > static void cros_ec_proto_test_release(struct device *dev) > { > } > @@ -2401,6 +2456,10 @@ static struct kunit_case cros_ec_proto_test_cases[] = { > KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_version2), > KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_host_event_rtc), > KUNIT_CASE(cros_ec_proto_test_get_next_event_mkbp_event_host_event_masked), > + KUNIT_CASE(cros_ec_proto_test_get_host_event_no_mkbp_event), > + KUNIT_CASE(cros_ec_proto_test_get_host_event_not_host_event), > + KUNIT_CASE(cros_ec_proto_test_get_host_event_wrong_event_size), > + KUNIT_CASE(cros_ec_proto_test_get_host_event_normal), > {} > }; > > -- > 2.37.0.rc0.104.g0611611a94-goog >