All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vaittinen, Matti" <Matti.Vaittinen@fi.rohmeurope.com>
To: "brendanhiggins@google.com" <brendanhiggins@google.com>
Cc: "tglx@linutronix.de" <tglx@linutronix.de>,
	"dan.j.williams@intel.com" <dan.j.williams@intel.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"talgi@mellanox.com" <talgi@mellanox.com>,
	"olteanv@gmail.com" <olteanv@gmail.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"davidgow@google.com" <davidgow@google.com>,
	"broonie@kernel.org" <broonie@kernel.org>,
	"herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
	"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"rdunlap@infradead.org" <rdunlap@infradead.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"yamada.masahiro@socionext.com" <yamada.masahiro@socionext.com>,
	"Mutanen, Mikko" <Mikko.Mutanen@fi.rohmeurope.com>,
	"bp@suse.de" <bp@suse.de>,
	"mhiramat@kernel.org" <mhiramat@kernel.org>,
	"krzk@kernel.org" <krzk@kernel.org>,
	"mazziesaccount@gmail.com" <mazziesaccount@gmail.com>,
	"andy.shevchenko@gmail.com" <andy.shevchenko@gmail.com>,
	"andriy.shevchenko@linux.intel.com" 
	<andriy.shevchenko@linux.intel.com>,
	"skhan@linuxfoundation.org" <skhan@linuxfoundation.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"Laine, Markus" <Markus.Laine@fi.rohmeurope.com>,
	"vincenzo.frascino@arm.com" <vincenzo.frascino@arm.com>,
	"sre@kernel.org" <sre@kernel.org>,
	"linus.walleij@linaro.org" <linus.walleij@linaro.org>,
	"zaslonko@linux.ibm.com" <zaslonko@linux.ibm.com>,
	"uwe@kleine-koenig.org" <uwe@kleine-koenig.org>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>
Subject: Re: [PATCH v7 04/10] lib/test_linear_ranges: add a test for the 'linear_ranges'
Date: Wed, 1 Apr 2020 08:45:05 +0000	[thread overview]
Message-ID: <4f915b8b8bee36a61ebea62ebf34c61845170ad5.camel@fi.rohmeurope.com> (raw)
In-Reply-To: <CAFd5g460hY9uOtwicWHK2rhgLdL+gStbKGmLN5KLWi5JXDQEog@mail.gmail.com>

Hello Brendan,

Thanks for taking a look at this :) Much appreciated! I have always
admired you guys who have the patience to do all the reviewing... It's
definitely not my favourite job :/

On Tue, 2020-03-31 at 11:08 -0700, Brendan Higgins wrote:
> On Tue, Mar 31, 2020 at 5:23 AM Matti Vaittinen
> <matti.vaittinen@fi.rohmeurope.com> wrote:
> >     Add a KUnit test for the linear_ranges helper.
> > 
> > Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
> 
> One minor nit, other than that:
> 
> Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
> 
> > ---
> > 

/// Snip

> > +
> > +/* First things first. I deeply dislike unit-tests. I have seen
> > all the hell
> > + * breaking loose when people who think the unit tests are "the
> > silver bullet"
> > + * to kill bugs get to decide how a company should implement
> > testing strategy...
> > + *
> > + * Believe me, it may get _really_ ridiculous. It is tempting to
> > think that
> > + * walking through all the possible execution branches will nail
> > down 100% of
> > + * bugs. This may lead to ideas about demands to get certain % of
> > "test
> > + * coverage" - measured as line coverage. And that is one of the
> > worst things
> > + * you can do.
> > + *
> > + * Ask people to provide line coverage and they do. I've seen
> > clever tools
> > + * which generate test cases to test the existing functions - and
> > by default
> > + * these tools expect code to be correct and just generate checks
> > which are
> > + * passing when ran against current code-base. Run this generator
> > and you'll get
> > + * tests that do not test code is correct but just verify nothing
> > changes.
> > + * Problem is that testing working code is pointless. And if it is
> > not
> > + * working, your test must not assume it is working. You won't
> > catch any bugs
> > + * by such tests. What you can do is to generate a huge amount of
> > tests.
> > + * Especially if you were are asked to proivde 100% line-coverage
> > x_x. So what
> > + * does these tests - which are not finding any bugs now - do?
> 
> I don't entirely disagree. I have worked on projects that do testing
> well where it actually makes development faster, and I have worked on
> projects that do testing poorly where it never improves code quality
> and is just an encumbrance, and I have never seen a project get to
> 100% coverage (nor would I want to).
> 
> Do you feel differently about incremental coverage vs. absolute
> coverage? I have found incremental coverage to be a lot more valuable
> in my experiences.

I think I have only been dealing with projects measuring absolute
coverage. I think seeing a coverage as %-number is mostly not
interesting to me. What I think could be interesting is showing the
code-paths test has walked through. I believe that code spots that
should be tested should be hand picked by a human. When we look at any
%-number, we do not know what kind of code the test has tested.

> You seem pretty passionate about this. Would you like to be included
> in our unit testing discussions in the future?

I think it would be nice :) I don't expect I will be active talker
there but I really like to know what direction things are proceeding in
general. And who knows, maybe I will have a word to say at times :) So
please, include me if it is not a big thing for you.

//Snip

> > +
> > +static void range_test_get_value(struct kunit *test)
> > +{
> > +       int ret, i;
> > +       unsigned int sel, val;
> > +
> > +       for (i = 0; i < RANGE1_NUM_VALS; i++) {
> > +               sel = range1_sels[i];
> > +               ret = linear_range_get_value_array(&testr[0], 2,
> > sel, &val);
> > +               KUNIT_EXPECT_EQ(test, 0, ret);
> 
> nit: It looks like the next line might crash if this expectation
> fails. If this is the case, you might want to use a KUNIT_ASSERT_*
> here.

Huh. I re-read this and almost agreed with you. Then I re-re-read this
and disagreed. Perhaps we should write an unit-test to test this ;)

The range1_sels and range1_vals arrays should always be of same size.
Thus the crash should not occur here. If RANGE1_NUM_VALS was bad then
we would get the crash already at

> > +               sel = range1_sels[i];

The linear_range_get_value_array() may return non zero value if value
contained in range1_sels[i] is not in the range - but range1_vals[i]
should still be valid memory.

Best Regards
	--Matti



> > --
> > Matti Vaittinen, Linux device drivers
> > ROHM Semiconductors, Finland SWDC
> > Kiviharjunlenkki 1E
> > 90220 OULU
> > FINLAND
> > 
> > ~~~ "I don't think so," said Rene Descartes. Just then he vanished
> > ~~~
> > Simon says - in Latin please.
> > ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> > Thanks to Simon Glass for the translation =]


  reply	other threads:[~2020-04-01  8:45 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 12:20 [PATCH v7 00/10] Support ROHM BD99954 charger IC Matti Vaittinen
2020-03-31 12:21 ` [PATCH v7 01/10] dt-bindings: battery: add new battery parameters Matti Vaittinen
2020-03-31 12:22 ` [PATCH v7 02/10] dt_bindings: ROHM BD99954 Charger Matti Vaittinen
2020-03-31 12:23 ` [PATCH v7 03/10] lib: add linear ranges helpers Matti Vaittinen
2020-03-31 14:05   ` Andy Shevchenko
2020-04-01 10:09     ` [SPF Softfail] " Vaittinen, Matti
2020-04-01 12:39       ` Andy Shevchenko
2020-04-01 13:18         ` Vaittinen, Matti
2020-04-01 14:42           ` Andy Shevchenko
2020-04-02  4:03             ` Vaittinen, Matti
2020-03-31 12:23 ` [PATCH v7 04/10] lib/test_linear_ranges: add a test for the 'linear_ranges' Matti Vaittinen
2020-03-31 18:08   ` Brendan Higgins
2020-04-01  8:45     ` Vaittinen, Matti [this message]
2020-04-01 18:48       ` Brendan Higgins
2020-04-02 15:39         ` Vaittinen, Matti
2020-03-31 12:24 ` [PATCH v7 05/10] power: supply: bd70528: rename linear_range to avoid collision Matti Vaittinen
2020-03-31 12:24 ` [PATCH v7 00/10] Support ROHM BD99954 charger IC Ard Biesheuvel
2020-03-31 14:02   ` Vaittinen, Matti
2020-03-31 14:21     ` andriy.shevchenko
2020-03-31 12:25 ` [PATCH v7 06/10] regulator: use linear_ranges helper Matti Vaittinen
2020-04-01 10:17   ` Mark Brown
2020-03-31 12:26 ` [PATCH v7 07/10] power: supply: bd70528: use linear ranges Matti Vaittinen
2020-03-31 12:26 ` [PATCH v7 08/10] power: supply: add battery parameters Matti Vaittinen
2020-03-31 12:28 ` [PATCH v7 09/10] power: supply: Support ROHM bd99954 charger Matti Vaittinen
2020-03-31 14:19   ` Andy Shevchenko
2020-04-01  8:08     ` Vaittinen, Matti
2020-03-31 12:29 ` [PATCH v7 10/10] power: supply: Fix Kconfig help text indentiation Matti Vaittinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4f915b8b8bee36a61ebea62ebf34c61845170ad5.camel@fi.rohmeurope.com \
    --to=matti.vaittinen@fi.rohmeurope.com \
    --cc=Markus.Laine@fi.rohmeurope.com \
    --cc=Mikko.Mutanen@fi.rohmeurope.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bp@suse.de \
    --cc=brendanhiggins@google.com \
    --cc=broonie@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=davidgow@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=krzk@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mazziesaccount@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=olteanv@gmail.com \
    --cc=rdunlap@infradead.org \
    --cc=robh+dt@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=sre@kernel.org \
    --cc=talgi@mellanox.com \
    --cc=tglx@linutronix.de \
    --cc=uwe@kleine-koenig.org \
    --cc=vincenzo.frascino@arm.com \
    --cc=yamada.masahiro@socionext.com \
    --cc=zaslonko@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.