Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp154729ybh; Tue, 14 Jul 2020 21:19:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztgDIbSok5A2DnjzeyG8H3d44ve0paPHUltDDkFkRlk5syESgTs6ZAXBtxesui/tNYa7T3 X-Received: by 2002:a50:a45d:: with SMTP id v29mr7657113edb.284.1594786787196; Tue, 14 Jul 2020 21:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594786787; cv=none; d=google.com; s=arc-20160816; b=LWVq4hQQvyQ01E6S8Sa5cxcx01t7JAviKjW2PuuhnaJm/qZJv2rTkUUCeTlKRN/gC5 5z2gOa+XYlFZW82PyYDCvEaTA4xk2301kRJ8D+zor0VXx7D/ahNaNF/t7QikcZVs51mQ TjNFYDC0Rqd93jnvGYUjolKblC/iqfmI5HRQmxerR6Y88U5q74XlZORq2aGe/O6zzvQs ga/7EQJG4ARK64ao9Bw1wb3Oobx5qKaTPXmSVmcawLRtrHF5ZkNsd6CQMZpofATNkgjA iSOoRnNpYrJ9hRLlDrob18MW74xVwrW2j3ao7Vqao5eEkQcYCpkOhnoQdAaPbbAcYW6E i+eg== 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=80hgB3Fq3XFIKiId7PbT4ZtffySmJWFsmTxk7R8Jg78=; b=LbTPpOjgPhJvhYUnsYiUL/BPhwBsvzNXyuWSjiwbBvXDnURdbZmnO90jcz0o5RXRHX sOGIWDpEntEwM7WYi4azCo70rUFOqSudTI2FBncNdk/Uz05ubGsG0X6UDXLvQUcSH8Ej 1g1OoAg0+9qee/QK1MtFfdt0bip9NfJDgjs5ela7W12F2bl1PKGwLDAE5CsQzSTS9Kqm 8TUOvwSAdP9UR9GAvvz0TtoUG869yvTuSnlYkwqb6uVONKDlQOvpbJioVsnsBguQ/62g RfFtXBbIyVNE6R+AIYkHP9+R5ejJOHkBq8RoKgrI7Swil1XbGIlw1JUXi7tpTdqJLHiM FyvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=b5kE0esf; 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 bi2si505676ejb.531.2020.07.14.21.19.24; Tue, 14 Jul 2020 21:19: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=b5kE0esf; 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 S1728202AbgGODrZ (ORCPT + 99 others); Tue, 14 Jul 2020 23:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726893AbgGODrY (ORCPT ); Tue, 14 Jul 2020 23:47:24 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B811BC061794 for ; Tue, 14 Jul 2020 20:47:24 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id f18so934064wrs.0 for ; Tue, 14 Jul 2020 20:47:24 -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=80hgB3Fq3XFIKiId7PbT4ZtffySmJWFsmTxk7R8Jg78=; b=b5kE0esfW+M+PVUtyf+1XnxZWg/JuNQGk9B30zFKSWwurrF2Da7rR/RbN+1Bsb5aak 6KCFwvBiX1KbZ/IogP3pgSu/O8PM6byEbFMOnbofAE3e1bqbESydmUgbJoT2RamHCP3e 7v/euNreVZcaLhwBYqZjk2NGFCoTAsl0SrlER1JeMtgBdpcy+r18pjhL7vJV/dsDXyoO FUrWxn5TvZREZUQE4uNfw4jrxhuCA4zh+n6XztLstMWmDrC+KPeKPxvwWVCLv2faVPb+ /nh1TAQA68sOIRN8bgOsMTmahPxi+zieMcpGMPPMLaHf9LVlWYr2Tb582/rfA9b77/Yz B/Wg== 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=80hgB3Fq3XFIKiId7PbT4ZtffySmJWFsmTxk7R8Jg78=; b=GknQn7qRXX3l0cRFWDI+q0LHKEZodxLzMH+US2e1BDbF40Z6/ROEey/ed5ZYaA1UYv NCdBXokwaAkyDSlXJAmKk4c6dSdZ5o3LRBemaVwLN+EZQk0SomuTwAv9fl7ZqGWCpnHQ CX4xqX+MGBugS1fjBYc9vD3pufkmP8dxuOMuD4dW1VLQMQ7sOl7kUiq68OkPD3VhxQMh KeHZb1Q/LQblw/VPs2wUoaTh4wvH9vTiik2nRK9JXXUZA59Z1vE1M7v6cB0rXxuClr7J V4HiOgBLg3cFP1BQzmIBtkaUtj+vWVDx8hBd9S6fjnTyBCqOojW86vKH9uTYX1WPEIhz EN0g== X-Gm-Message-State: AOAM530WNj2jckWVjx5m0LejryOmQpKW98/Xwv9qKF0My09V5S29PbOR /zKDJNYqdBiRFoaLFHPZ2dGgM77W8aQRjXezmop3+Q== X-Received: by 2002:a05:6000:cf:: with SMTP id q15mr9253893wrx.203.1594784843205; Tue, 14 Jul 2020 20:47:23 -0700 (PDT) MIME-Version: 1.0 References: <20200715031120.1002016-1-vitor@massaru.org> In-Reply-To: <20200715031120.1002016-1-vitor@massaru.org> From: David Gow Date: Wed, 15 Jul 2020 11:47:11 +0800 Message-ID: Subject: Re: [RFC 0/3] kunit: add support to use modules To: Vitor Massaru Iha Cc: KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Linux Kernel Mailing List , Brendan Higgins , Kees Cook , Shuah Khan , linux-kernel-mentees@lists.linuxfoundation.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, Jul 15, 2020 at 11:11 AM Vitor Massaru Iha wrote: > > Currently, KUnit does not allow the use of tests as a module. > This prevents the implementation of tests that require userspace. If this is what I think it is, thanks! I'll hopefully get a chance to play with it over the next few days. Can we clarify what this means: the current description is a little misleading, as KUnit tests can already be built and run as modules, and "tests that require userspace" is a bit broad. As I understand it, this patchset does three things: - Let kunit_tool install modules to a root filesystem and boot UML with that filesystem. - Have tests inherit the mm of the process that started them, which (if the test is in a module), provides a user-space memory context so that copy_{from,to}_user() works. - Port the test_user_copy.c tests to KUnit, using this new feature. A few comments from my quick glance over it: - The rootfs support is useful: I'm curious how it'll interact with non-UML architectures in [1]. It'd be nice for this to be extensible and to not explicitly state UML where possible. - The inheriting of the mm stuff still means that copy_{from,to}_user() will only work if loaded as a module. This really needs to be documented. (Ideally, we'd find a way of having this work even for built-in tests, but I don't have any real ideas as to how that could be done). - It'd be nice to split the test_user_copy.c test port into a separate commit. In fact, it may make sense to also split the kunit_tool changes and the mm changes into separate series, as they're both quite useful independently. Cheers, -- David > This patchset makes this possible by introducing the use of > the root filesystem in KUnit. And it allows the use of tests > that can be compiled as a module > > Vitor Massaru Iha (3): > kunit: tool: Add support root filesystem in kunit-tool > lib: Allows to borrow mm in userspace on KUnit > lib: Convert test_user_copy to KUnit test > > include/kunit/test.h | 1 + > lib/Kconfig.debug | 17 ++ > lib/Makefile | 2 +- > lib/kunit/try-catch.c | 15 +- > lib/{test_user_copy.c => user_copy_kunit.c} | 196 +++++++++----------- > tools/testing/kunit/kunit.py | 37 +++- > tools/testing/kunit/kunit_kernel.py | 105 +++++++++-- > 7 files changed, 238 insertions(+), 135 deletions(-) > rename lib/{test_user_copy.c => user_copy_kunit.c} (55%) > > > base-commit: 725aca9585956676687c4cb803e88f770b0df2b2 > prerequisite-patch-id: 582b6d9d28ce4b71628890ec832df6522ca68de0 > -- > 2.26.2 >