Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5822603pxu; Thu, 22 Oct 2020 11:56:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqg7LtnU6PE9F9lfxxoSrsJ9hKb7v4RkWafCwO0BAwjc2eDRcoHdm6LQcmP3MBAcXAxw/7 X-Received: by 2002:a50:e38e:: with SMTP id b14mr3661568edm.63.1603393007374; Thu, 22 Oct 2020 11:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603393007; cv=none; d=google.com; s=arc-20160816; b=mkeeP8VklPDfsCNTogNAQUp29jv655bSLr+dJNq1P1V9UenLR9ydBqb0jbZEzm+Jmu VqDNE9M955oWPgybH1AWP0lhQo+GuFCEJpkuz9Qr8AQ3s+Tn8wqE/gw/FzMApIzRYShv Fl91tnaYplgw2WUXL53UGZG+LYdgbmyivTeuj8TqlIh8QeBz6n+rLX5KcAWlXzP91Szu Kblr8Bi+WgVHIY0uQT/PMlVop65kr5WV+YwbvcljoBpx7LfRYbYpyxBShg/+1F+rj3fC OPJLUoa/ryioFUpdObYBXfrJCEVs6dt6zS5QB4juxzk9rYguysXbEuzcI7p+JIlrQGxr 1M6Q== 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=Kgzi+g1ki8/8D0IVfdBW9d0VukE2gz0oMmxOEAh2jy0=; b=Binth3V6CmPgXIWUughPOsSqAMGUjzxmuzNxyB42O+RTV1f+2bgf+yhN0xYI1ur9+g URLQMXAIbXwGJSOaAKEOeGkgnJCe2OSykO6rd4lTaw5XfHH9VGkZXxD1JGYb2tZCgjn6 bbE6R8RXAHMB2X9/9jAoPtUxbN7udZ5TpbfcEnuoymmz7EiPhxpTH2Aod0MLYc+sxIQ+ VjgwZC6o11lgEn1fWN1eYqcC/lkJnbKUCkaIVN3Rb7vvrkZJt390d/H/1O6Gsx/tbBwW P3aL+r8NiEcuXVAB7T7uUyy6QGNMMUvYJVgqi2k0G9NigCDgx3s7DOv6Muo3Et+wm88w kRqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RLsEyXfQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id d2si1492182eds.5.2020.10.22.11.56.24; Thu, 22 Oct 2020 11:56:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RLsEyXfQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S369784AbgJVSyC (ORCPT + 99 others); Thu, 22 Oct 2020 14:54:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2902353AbgJVSyC (ORCPT ); Thu, 22 Oct 2020 14:54:02 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AD35C0613D2 for ; Thu, 22 Oct 2020 11:54:02 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id e10so1739268pfj.1 for ; Thu, 22 Oct 2020 11:54:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Kgzi+g1ki8/8D0IVfdBW9d0VukE2gz0oMmxOEAh2jy0=; b=RLsEyXfQqINT56bd+1ghDSJy/112xAsquJHcPYpL8rpw6gfrYXws7WLQf3HRsb46HW 9kfE6Ss/NsZd/+pqBGNuDdOBEGOo/tJ99p/1P3aylPmASezmvMrXGj5x/yVHwUK74P20 LevQtLmGQcK5svBypPaci4LQCMU1uVX0SoMO/R+SFiMvqkAbMJXvYj/jyIaHcbo2oDbK 70AzOyunOzKb1tUQAyuqIuddZCw3KA/2dzhUt4+oRm9pcAFz4z4XxHnYjn6DngMvO6v2 67MUAdJ0k4cubC08bM79nUadhQzqwqqZNSvhnKQV1NcGaKJDuG/WO8bQldQsrBtvCy4z l+TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Kgzi+g1ki8/8D0IVfdBW9d0VukE2gz0oMmxOEAh2jy0=; b=Aqihi/dI58EPUq1eMB5ScBpXQ58GVJXgn8xtatC07Ig8aB9R4P/8OBwcky4QYagcG4 sOkzYLXSuqB6TsuE2FmCj6L9pKdl6Uv5DtdV2YCBztgVfj4aZEjStphI5qrPAZEHl9AP 6hEl0jesHfqKywY6kxUFlagpvQgjf5TuMsyAwLn4c5EekP5tLnM/dhFcqDJMT86P/A+9 oFY6fLV49pwH14ab00I9opUugD16Gyj+qgfLRrorVjLG/yXe0wF5J0zP5QeZae5l52ox 4lfJIk2GKKL4D4oRc9kMUbNf883gAKYEbD2XZG6KXC10u2DNqHBt38jLXLiHM1Lo143I vJQw== X-Gm-Message-State: AOAM5324w7+9hfqS8hNGVl6ujTAAxp0qtAqXO44Kp76FLsoUUEy1dhI/ K/BOsvg2BwArrFzsmAV5eTWeHfm0RydswKRD4AdIYQ== X-Received: by 2002:a17:90a:3e4e:: with SMTP id t14mr3665884pjm.217.1603392841690; Thu, 22 Oct 2020 11:54:01 -0700 (PDT) MIME-Version: 1.0 References: <20201019224556.3536790-1-dlatypov@google.com> <20201022150648.GH4077@smile.fi.intel.com> In-Reply-To: <20201022150648.GH4077@smile.fi.intel.com> From: Brendan Higgins Date: Thu, 22 Oct 2020 11:53:50 -0700 Message-ID: Subject: Re: [PATCH] lib: add basic KUnit test for lib/math To: Andy Shevchenko Cc: Daniel Latypov , David Gow , Linux Kernel Mailing List , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 22, 2020 at 8:06 AM Andy Shevchenko wrote: > > On Wed, Oct 21, 2020 at 10:47:50AM -0700, Daniel Latypov wrote: > > On Tue, Oct 20, 2020 at 8:40 PM David Gow wrote: > > > On Tue, Oct 20, 2020 at 6:46 AM Daniel Latypov wrote: > > > > > > > > Add basic test coverage for files that don't require any config options: > > > > * gcd.c > > > > * lcm.c > > > > * int_sqrt.c > > > > * reciprocal_div.c > > > > (Ignored int_pow.c since it's a simple textbook algorithm.) > > > > > > > I don't see a particular reason why int_pow.c being a simple algorithm > > > means it shouldn't be tested. I'm not saying it has to be tested by > > > this particular change -- and I doubt the test would be > > > earth-shatteringly interesting -- but there's no real reason against > > > testing it. > > > > Agreed on principle, but int_pow() feels like a special case. > > I've written it the exact same way (modulo variable names+types) > > several times in personal projects. > > Even the spacing matched exactly in a few of those... > > But if you would like to *teach* somebody by this exemplary piece of code, you > better do it close to ideal. > > > > > These tests aren't particularly interesting, but > > > > * they're chosen as easy to understand examples of how to write tests > > > > * provides a place to add tests for any new files in this dir > > > > * written so adding new test cases to cover edge cases should be easy > > > > > > I think these tests can stand on their own merits, rather than just as > > > examples (though I do think they do make good additional examples for > > > how to test these sorts of functions). > > > So, I'd treat this as an actual test of the maths functions (and > > > you've got what seems to me a decent set of test cases for that, > > > though there are a couple of comments below) first, and any use it > > > gains as an example is sort-of secondary to that (anything that makes > > > it a better example is likely to make it a better test anyway). > > > > > > In any case, modulo the comments below, this seems good to me. > > > > Ack. > > I'll wait on Andy's input before deciding whether or not to push out a > > v2 with the changes. > > You need to put detailed comments in the code to have it as real example how to > create the KUnit test. But hey, it will mean that documentation sucks. So, > please update documentation to cover issues that you found and which motivated > you to create these test cases. I don't entirely disagree; leaning too heavily on code examples can be detrimental to docs. That being said, when I use other people's code, I often don't even look at the docs. So, I think the ideal is to have both. > Summarize this, please create usable documentation first.