Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp638458iob; Wed, 18 May 2022 09:36:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcU3F28BmaL/QVlu7EBbifAqtYu0bipQaZDiXyslsbbSIWfCbhXHmIcbArEINF10ETpoAZ X-Received: by 2002:aa7:9e88:0:b0:518:3681:f196 with SMTP id p8-20020aa79e88000000b005183681f196mr408677pfq.67.1652891808578; Wed, 18 May 2022 09:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652891808; cv=none; d=google.com; s=arc-20160816; b=NOprzTaA17d54Ss6NKgh6phwAuNMbEzBovuTDAx8YXU9jOlyBLrKJBKnTgbTnsiHyI URiBVnqBTXaAEFyb7spKZzD8PTzSdOAuF8GOuDXKnrwPpr0aLj95JDv9/sAPUwcA97m8 os+U2qkKWfEsr9iMWaR+ES7MXT1BSTZgpqvcbfMHlOUUGdZ1MOzMl8SXQvE+skjOUqva QCZCxSPGLyAAkp1teVdz15G8YXnVHubXRpV60hfX0mmBEQvN12RkTueTcvtgTe/tRVi6 uENuPI2rPXUh0cSBTql0+SotW/NrCXZAkDP4ZVByTS2SNhLlen//eykdnV2wzUMQ4tp4 6JZw== 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=r1oLO7O64SDRDNcmae9yhgZmG0/o3ZbaE07wdLh2WFQ=; b=b4IXoGLj82FF3Y1rWoBKWoaowPVVJ2TvyDogjNPfNoEjdRUUhPpIqi87KOMwHQ3M9H +SO38a8VfgLUALVQ8tqyomMUFWtVt6WbT/Jb4dNhpKx3kVIzDXrk7bayqujs86mmypAy Um7LHj9Zib72rg0FIxW1lr2t07p78xj/ZkRYpwu0O9HWDmqNqE4lXNZ5A7iz8yDEv4Uw 8E7C2FckjjVDVjJf379PWFrVQffxo6sonFjajyi6kUNbN4uq4OVphA6uEEq/wNfmDOAL unXrrFfqC+DFIw4sWVSLu1ZgefDBKTQ3OpFCLGlpXUK+vsORXbU+A+Q/bFqp+yWKCgaB HGFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=d3ftFDSE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d6-20020a170902728600b0015ed1a33028si3111109pll.495.2022.05.18.09.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 09:36:48 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=d3ftFDSE; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 643675BE4C; Wed, 18 May 2022 09:32:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240274AbiERQbv (ORCPT + 99 others); Wed, 18 May 2022 12:31:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240272AbiERQbp (ORCPT ); Wed, 18 May 2022 12:31:45 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D883366AC for ; Wed, 18 May 2022 09:31:34 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id ck4so613924ejb.8 for ; Wed, 18 May 2022 09:31:34 -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=r1oLO7O64SDRDNcmae9yhgZmG0/o3ZbaE07wdLh2WFQ=; b=d3ftFDSE2RnvF12jRgGG+txqJyBd/ppy2FzGUzh8ZdS5XsqYp41rNlyyk0uGlh1kG8 8+ipFezXKpEJqt0FbB9RD9nE01cndrmo9l3Z4xO6xhaHoNPhZ6+lHIAAQONJBRnL0XGz jAlRAlMGYgQyvsL7A4D0ExDfDOr4R8T/uMR/R0uZE/X2XsQh4ILJ6XhT11Ve/GNdcrry 64MapQem4AuA/rXiRqKblOHsX6Odiz6FjT1AJCslR14QCpdbWGfEfAOFsxcs+rOFpitC uFaSkhgLaE57WMDFBIZHHtJGWCeC5mkKS40RjuiB9x2QpvERtyH1dY6/MuK2JQcqq0sN CGog== 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=r1oLO7O64SDRDNcmae9yhgZmG0/o3ZbaE07wdLh2WFQ=; b=If/36NDw/tBe0X6X9JpKALblSbsdiE+xb+cg5qQrQ1TRioqv3oSBwqprrCi7QXrVtF 6DQTzWENt6ttik8G9UnaHeNEouKzUAxAlN8DfGgMsK0ofmNzzD8ss7yP0B1Hea18fTY1 pqZNBng51nonDAGR5D0Mneqpe9/QxYY8484epNJpgKlXH4F1+sZNst8mE2b2ch+Kwz4r +T/WAddECpgm99L/z0V2mPhy1hK/K4NeygZIK/Q9Q8PSC99Og3J5bvd7adQ9bRuB04T6 PYWRovl+UGPZh9FRGPuzsCL267n15GiNGFEkEp6WvRhXs5PKCpuNz18Epa44ELCevKRy RVlg== X-Gm-Message-State: AOAM531YAklrZhyPgzIcuLrHsK2AU7qQbeqV5JpIzLazALAxSGHqA5Bu pPRbf96kwNmjog2MP1z3TaV2lEPcZxrJSikaiJZ4DJXHaq8= X-Received: by 2002:a17:907:6ea2:b0:6fe:6da9:5d2a with SMTP id sh34-20020a1709076ea200b006fe6da95d2amr377345ejc.189.1652891492792; Wed, 18 May 2022 09:31:32 -0700 (PDT) MIME-Version: 1.0 References: <20220518091814.2028579-1-tzungbi@kernel.org> <20220518091814.2028579-5-tzungbi@kernel.org> In-Reply-To: <20220518091814.2028579-5-tzungbi@kernel.org> From: Guenter Roeck Date: Wed, 18 May 2022 09:31:21 -0700 Message-ID: Subject: Re: [PATCH 4/4] platform/chrome: cros_ec_proto: add Kunit tests for cros_ec_check_result() To: Tzung-Bi Shih Cc: Benson Leung , Guenter Roeck , chrome-platform@lists.linux.dev, linux-kernel , Doug Anderson Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 Wed, May 18, 2022 at 2:18 AM Tzung-Bi Shih wrote: > > cros_ec_check_result() is used to check if the EC communication success but > EC responded EC_RES_IN_PROGRESS. It should return 0 even if EC wasn't > happy about the host command. > > Add Kunit tests for cros_ec_check_result(). > > Signed-off-by: Tzung-Bi Shih Reviewed-by: Guenter Roeck > --- > drivers/platform/chrome/cros_ec_proto_test.c | 41 ++++++++++++++++++++ > 1 file changed, 41 insertions(+) > > diff --git a/drivers/platform/chrome/cros_ec_proto_test.c b/drivers/platform/chrome/cros_ec_proto_test.c > index 61abb18ac00b..25c4fca5c165 100644 > --- a/drivers/platform/chrome/cros_ec_proto_test.c > +++ b/drivers/platform/chrome/cros_ec_proto_test.c > @@ -132,6 +132,46 @@ static void cros_ec_proto_test_prepare_tx_bad_msg_outsize(struct kunit *test) > KUNIT_EXPECT_EQ(test, ret, -EINVAL); > } > > +static void cros_ec_proto_test_check_result(struct kunit *test) > +{ > + struct cros_ec_proto_test_priv *priv = test->priv; > + struct cros_ec_device *ec_dev = &priv->ec_dev; > + struct cros_ec_command *msg = priv->msg; > + int ret, i; > + static enum ec_status status[] = { > + EC_RES_SUCCESS, > + EC_RES_INVALID_COMMAND, > + EC_RES_ERROR, > + EC_RES_INVALID_PARAM, > + EC_RES_ACCESS_DENIED, > + EC_RES_INVALID_RESPONSE, > + EC_RES_INVALID_VERSION, > + EC_RES_INVALID_CHECKSUM, > + EC_RES_UNAVAILABLE, > + EC_RES_TIMEOUT, > + EC_RES_OVERFLOW, > + EC_RES_INVALID_HEADER, > + EC_RES_REQUEST_TRUNCATED, > + EC_RES_RESPONSE_TOO_BIG, > + EC_RES_BUS_ERROR, > + EC_RES_BUSY, > + EC_RES_INVALID_HEADER_VERSION, > + EC_RES_INVALID_HEADER_CRC, > + EC_RES_INVALID_DATA_CRC, > + EC_RES_DUP_UNAVAILABLE, > + }; > + > + for (i = 0; i < ARRAY_SIZE(status); ++i) { > + msg->result = status[i]; > + ret = cros_ec_check_result(ec_dev, msg); > + KUNIT_EXPECT_EQ(test, ret, 0); > + } > + > + msg->result = EC_RES_IN_PROGRESS; > + ret = cros_ec_check_result(ec_dev, msg); > + KUNIT_EXPECT_EQ(test, ret, -EAGAIN); > +} > + > static int cros_ec_proto_test_init(struct kunit *test) > { > struct cros_ec_proto_test_priv *priv; > @@ -159,6 +199,7 @@ static struct kunit_case cros_ec_proto_test_cases[] = { > KUNIT_CASE(cros_ec_proto_test_prepare_tx_legacy_bad_msg_outsize), > KUNIT_CASE(cros_ec_proto_test_prepare_tx_normal), > KUNIT_CASE(cros_ec_proto_test_prepare_tx_bad_msg_outsize), > + KUNIT_CASE(cros_ec_proto_test_check_result), > {} > }; > > -- > 2.36.0.550.gb090851708-goog >