Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp894667ybx; Thu, 31 Oct 2019 02:34:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1ZK9t9DDDt88m4ozpguhCme5eCji9kgnMStb2NfR/qEF60ZW59WTGUxsDNhydqtRz0gcN X-Received: by 2002:a50:9713:: with SMTP id c19mr4805428edb.206.1572514482608; Thu, 31 Oct 2019 02:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572514482; cv=none; d=google.com; s=arc-20160816; b=IqgZO8l2N3ssz+PkKcFA+EgRea5JnZ27F9682WvUGwYIlrBORuIN/9FzGWaUlmjLMr UmZycwh1M/gcpCafcGU1m9N79mgoJoulj3SL+lfmh3XgGAF7O2+e6iLUDsVAO5+m2YvN 2ZY4Rn21KjdjR4yZnBlKFjqkIfZJJLVFu125FNE71fRN+VxEQzqvsBXcs5neiOUB+jFe TMYYtJSQsFLCpO3n0hNd9Outn7X8gxWf3A1NUjSiV7oMugmKvrphRXwtY4hgee8pHhpz bhmEqnsU83N1Q/PDCtVDEyYITkIDyE6U0+Wh1hASTkaO6lz8yixS88croin+6ENo1ryM wXyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=UfGWBZAudfaqT290q3OdOipHzfk3TijoCmN+3Jz803Q=; b=FQJTo+7LBCtc7YioCcVSoarM0dsl8NMlUvjiKeJjgijrPf69jEG3GK7pYsME/b5pnS yBZAZXRm4E/Nun362L4wstILyfHIu+fvCUAhiGq35Yf9zI3kNi6XYgk3sDuKqQFtQFHN WmSq9cBK123DNWjIqrOOw9hhMD5bDl6J7ixKbv7pRfskgT7ClH3B9jXT93drZ3hk/Kzk 8GQCw4rWAPIHlTYuWdMCPLNBcrkeoBeyovdRH+zGAS2xItdmaPtQV2f2fLm0ew8d2tEq J7lICF8o5SIublP4r96wvNndGRBePj3ChXt+sJG7UR615uuEYOHFTjYX8NkkSIVQhebZ RYXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XhDF1lef; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id p5si3078442eja.141.2019.10.31.02.34.18; Thu, 31 Oct 2019 02:34:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XhDF1lef; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727175AbfJaJdp (ORCPT + 99 others); Thu, 31 Oct 2019 05:33:45 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:36461 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727009AbfJaJdp (ORCPT ); Thu, 31 Oct 2019 05:33:45 -0400 Received: by mail-pf1-f193.google.com with SMTP id v19so3980952pfm.3 for ; Thu, 31 Oct 2019 02:33:45 -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=UfGWBZAudfaqT290q3OdOipHzfk3TijoCmN+3Jz803Q=; b=XhDF1lefotT2UASMthSJUxNnb0mHTBcOYfkwpTSAY+w/HCQvebzTSdG9rU5FoZT5jB 7yGt6KeTaVrur2O+wQU1bqQTugrJbB69piT163uph4YXe867ADk73jYvYgJdMCASsaqO jJoZ9FwT67M6PC6GOB7CEWQH/Vaam0LdsvMGqVy4R2FyYjny8XLnDljIsrzwlWUecIxm lAAUkGPSwFcHfQ42lhykC7lDHXvf9WRF8TUolfSlHkao3dOb5o/E4oz1kPLmbIMJMZph 1nluWoVD9/ou08jb121tFfVKxG0vlpu9296vSX3JQpwJ0QYKoASioMWRqKHvSqwmsNB9 Skag== 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=UfGWBZAudfaqT290q3OdOipHzfk3TijoCmN+3Jz803Q=; b=G/vEDhTGMWNee6jDdGhe3ZjWXlXV3w6OVmHgm9gYlkm8EMMA9sYN4vJQvibg8YqDkk AOZBGSir3m50z6SXiiLLvQIoyGzKkBx74L3+q2KNV3igIGJpoU+FwivT2z6AhiP5gCoG 90KIzGJdmIajUMAzTus6heOLsn3WJ5jh19+8aUD4yz3krvXDaYpCR7Yl30EZoJLW43uf 2KFJYHRFqdec9F+82xhESGXAu9bDUeqectGlPc3nDDb3pnEptvLfxLlPdteOQJtb8AOJ m1UH6zD+pwk1Zs7EROAjiecRVAxU7kN+yDB7kGrEpUOH4VZ2VEOJrJHW62SPot/Cynz0 1eFg== X-Gm-Message-State: APjAAAW07UZVlLOjecxMm2NRHna3U6/jT5BQdDwD8EVQTwUAxpbA1GCm dxhkSbK8+HrecVXxTpeP2sMUp31rekdIiQkx+Meugg== X-Received: by 2002:a65:664e:: with SMTP id z14mr5281693pgv.201.1572514424176; Thu, 31 Oct 2019 02:33:44 -0700 (PDT) MIME-Version: 1.0 References: <20191018001816.94460-1-brendanhiggins@google.com> <20191018122949.GD11244@42.do-not-panic.com> <20191024101529.GK11244@42.do-not-panic.com> <201910301205.74EC2A226D@keescook> In-Reply-To: From: Brendan Higgins Date: Thu, 31 Oct 2019 02:33:32 -0700 Message-ID: Subject: Re: [PATCH linux-kselftest/test v1] apparmor: add AppArmor KUnit tests for policy unpack To: Iurii Zaikin Cc: Kees Cook , Luis Chamberlain , Alan Maguire , Matthias Maennich , shuah , John Johansen , jmorris@namei.org, serge@hallyn.com, David Gow , "Theodore Ts'o" , Linux Kernel Mailing List , linux-security-module@vger.kernel.org, KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Mike Salvatore Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 30, 2019 at 1:12 PM Iurii Zaikin wrote: > > > Why can't unit tests live with the code they're testing? They're already > > logically tied together; what's the harm there? This needn't be the case > > for ALL tests, etc. The test driver could still live externally. The > > test in the other .c would just have exported functions... ? > > > Curiously enough, this approach has been adopted by D 2.0 where unittests are > members of the class under test: https://digitalmars.com/d/2.0/unittest.html Thanks for pointing this out, Iurii, that actually looks pretty cool. I still personally prefer keeping tests and code separate, but if we decide to go the route of mixing tests and code, maybe we might want to use this as a model. > but such approach is not mainstream. > I personally like the idea of testing the lowest level bits in isolation even if > they are not a part of any interface. I think that specifying the > interface using > unit tests and ensuring implementation correctness are complementary but > I haven't had much luck arguing this with our esteemed colleagues. So I think this is a very subtle point which is very widely misunderstood. Most people write code and then write their tests, following this practice along with only testing public interfaces often causes people to just not test all of their code, which is wrong. The idea of only testing public interfaces is supposed to make people think more carefully about what the composite layers of the program is. If you are having difficulty getting decent coverage by only testing your public interfaces, then it likely tells you that you have one of two problems: 1) You have code that you don't need, and you should remove it. 2) One of the layers in your program is too think, and you should introduce a new layer with a new public interface that you can test through. I think the second point here is problematic with how C is written in the kernel. We don't really have any concept of public vs. private inside the kernel outside of static vs. not static, which is much more restricted.