Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1343915imm; Wed, 17 Oct 2018 18:34:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61e3isr9ZmHCUzaftN+BwOpjPPFpM9qwuIxHn48srJWkNngdU/8ItLHDdqdbamvE+/hT3So X-Received: by 2002:a17:902:8d85:: with SMTP id v5-v6mr7457295plo.33.1539826448816; Wed, 17 Oct 2018 18:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539826448; cv=none; d=google.com; s=arc-20160816; b=FzQQHqBLs2uBWFd8jJaR6gdIJvmT5eiYVEXYTTrJxnplDUZQCY+weQwJm5DsxhbhSj ODIXYaohHcjRpaRyBMhqpUaS64GFNTzv0SQ6T99shNDSKNnvk5ZNeNMKuBLNji/gM7VH 02dX5YsquRnnPyUEztlah9vNWkwjh8IeBzsRXO6WqSUHp/i9J35x39MQPIbCMlA/fLi1 UM96SuwcybDtC4e6EwZDAhlDqc+KiAG+emLrkVOavqKR1cLMCnnGCQpylRUEBlcADYRo JfHdepoFV44XsZTYCGCtmXYLp5WVKJWQxXgbrYQRolxkfxJqbrpU9rjf2qx2j1kW1x3/ ftRA== 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=ARWAj6381CPA1r2hjfrM+Gzrg9iwTEgDHx4ygvanqnM=; b=qSS+e5TFZYsdWzUPZZtK3ukNCr7KtkdQ+aP1oIed9bqjfQfpZ1IqOyMDiSlxf9oOKh +vFWg5WQjWyago88/yGVln5mYMbiva38IEK/LDz4P4XBrSxlE+uJ0rjeV7kAGJmQ5wBV p4nsIfpi7fxTBaEq09GD/F6040N9bQ8UqyununiPJex2IphaR1SDfWKgPvWcQgT7Pnq8 /wJ/7YMhHv1PKToZgaDxC79A70DAbG4jeld/LEMapNn0S10uoEYYAklfcMEKXB8ZkrNO UfwZc3yd6JxLK5c02cJWnxAPuMV5umIuyvC0VdmsnshlbeoV7Op9kacs2gxO3oGE/Wi7 oY5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TBSH052q; 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 j185-v6si20307154pfc.186.2018.10.17.18.33.52; Wed, 17 Oct 2018 18:34:08 -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=TBSH052q; 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 S1727019AbeJRJbI (ORCPT + 99 others); Thu, 18 Oct 2018 05:31:08 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:46608 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726706AbeJRJbI (ORCPT ); Thu, 18 Oct 2018 05:31:08 -0400 Received: by mail-ot1-f67.google.com with SMTP id o21so28165868otb.13 for ; Wed, 17 Oct 2018 18:32:40 -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=ARWAj6381CPA1r2hjfrM+Gzrg9iwTEgDHx4ygvanqnM=; b=TBSH052qjzYookIrhMq8gQ79WGBn+reDmaJ2Z0t0UeIEbL+EvbyQAu2/rMxehVuM2y MPB1/3KgjO3Oq2T9qOkwwd94LhNk3i4UHPwd4rOwUhgbkzz2WFL/eUsyw1oQbN7rWYJz QNtUXwraJp1dzo8SygSRuU/xlMrZ/z7sjIPPtUtHW2+EzofQAdBLmQX9p359W0fGKVBP Y8nTfRZtqLYWBBs0Tp5JZ+u1ilNSFjiHwxxOKFjX9Pc2BeqlER+BlIHh6xuTKTy+3cs6 siKAfrDOcqxxANY4bFQD2Fcz/YLYTvXwTC8hww1bdwzYuk/mguZtFVKDnngMyPIp4/0A qjeA== 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=ARWAj6381CPA1r2hjfrM+Gzrg9iwTEgDHx4ygvanqnM=; b=SzKjbXVuDYF/YCrEV2HAKV9ELlbXIe9dKFUPbuvZEblktIDidfyQHOhJ7P/xMlHsfO FEkN7vFRUQ7ncZia97YoJdJxmvvs4KKnWSeqJZTSKuCQHQfDJJmtNKJ74j2O9PGDcXGH 6XdzGVkDiS+rj4sSbGeic+3FOuytc6i1YGwLzYfut47OXr9VvmzBSRU8NLA3h5WkYxec BuBSOoq8jPItGwcNVTI7/G3A2FrPeVHjTB9hc347Tn1RQbJ5nfk33PxzsCQKOfrW/T4n zsW6degyyqQ0MU1dbC/ACtIA46aHLy9VWPFI82+ecNR5Xl+sTbtAWKmzYeyjKYWhlt8o e3Xg== X-Gm-Message-State: ABuFfoiKZ461evSsdhDpl3PspPCjiWVcmqtdKP9aGuLpiOmR4EykUX3X ogqXt70UBq4xP3p5zhZcs8OzRnPRXGzTeZXzu8w8Zg== X-Received: by 2002:a9d:6509:: with SMTP id i9mr2082151otl.338.1539826359244; Wed, 17 Oct 2018 18:32:39 -0700 (PDT) MIME-Version: 1.0 References: <20181016235120.138227-1-brendanhiggins@google.com> <20181016235120.138227-23-brendanhiggins@google.com> In-Reply-To: From: Brendan Higgins Date: Wed, 17 Oct 2018 18:32:27 -0700 Message-ID: Subject: Re: [RFC v1 22/31] kunit: mock: add the concept of spyable functions To: rob.herring@linaro.org Cc: Greg KH , Kees Cook , mcgrof@kernel.org, shuah@kernel.org, Joel Stanley , mpe@ellerman.id.au, joe@perches.com, brakmo@fb.com, rostedt@goodmis.org, Tim.Bird@sony.com, khilman@baylibre.com, Julia Lawall , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, Linux Kernel Mailing List , jdike@addtoit.com, richard@nod.at, linux-um@lists.infradead.org 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 17, 2018 at 3:47 PM Rob Herring wrote: > > On Tue, Oct 16, 2018 at 6:54 PM Brendan Higgins > wrote: > > > > Adds the concept of spying like in Mockito > > (http://static.javadoc.io/org.mockito/mockito-core/2.20.0/org/mockito/Mockito.html#spy-T-). > > This allows a function declaration to be labled as spyable which allows > > the function to be mocked *and* to allow the mock to invoke the original > > function definition. > > We can already hook into arbitrary functions ftrace. Wouldn't > utilizing that simplify features like this and avoid having to touch > existing code for testing? Not sure what it would take to enable > ftrace on UML. It is at least partially compiler dependent. Regardless of what we end up doing, this definitely needs more work. After looking at include/linux/ftrace.h, it does look feasible to use ftrace for spying. I totally agree that we don't want to reinvent this wheel if we can avoid it, but I have no idea what getting it working on UML would look like. Dependence on compiler features could be an issue: pretty much anyone who can build the kernel should be able to run our tests.