Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp184024pxu; Wed, 2 Dec 2020 19:10:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzumHsTWDimey34SZspDP8lrkktmXPjnwiI9CUfXDiaqoKCz/cOwRiauPTxouayoziEwbLP X-Received: by 2002:a17:907:447d:: with SMTP id oo21mr748223ejb.367.1606965026722; Wed, 02 Dec 2020 19:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606965026; cv=none; d=google.com; s=arc-20160816; b=IyPwXPrZsS2Jhq/pcYko0/FEgMnFxzzhoDaOLQZPLZmUlKP4m2DqFYhV+NBIyHUCZ4 SSUVK2C4pnTlpb2Uj6qC4OP5Wbk37B/2Y8cD0Dbi5I+cw1blXAax1+UkoZj13dBbQoZv CnbyGbERckqZSygw+HNjUh1KvJypfbxW9ocZJt583/eKN/NeC4+efU14uNev3UwkoUcW 6yLeDfo+boruqSo1MnHAvOT9KGKsOIxnQK5afNTDkN8oOFBBxq9M5zWncND7a1y4yCie xioblXt31+nr1ODflEcubCDUtuyLfv9GpcUgH9B7FmLf48uq7SRe7ICmfJ6hLMM5k84/ qlGg== 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=S4QT6Rgw62DbFRwkl+4o96eZwY9j3Q8i5Y9bbEB2ur8=; b=zOK04Hd4EGtCGvNxsbnEGg0HtfpMx1TVwZ02nXxyxLAYaBNxbhARYm47Zf+LJAo4U5 S9IRdxNu2lL5oxyfa+53Pwbu6dyPmNE4tgvXo91iJpSwv2EK0Q2EzIEL3pvu6su84YMd aArAF489BNdphzqnhsePwg09otJZaOhn529KuqVxGMHWjuUfmf/jro7kn0/aVQm7rFK1 M0PQyqai/dGj/ISMwnGKylZEHLOcqgPHtmRQWYppa/p0ERJ2t3NVN/2FM1uwxBFDEr9M D/JEvndZGSp+yrNp1h7KOhVfq083BKN90H6fZTLX5n6+uL+Y419FKRllP1QAoamI5sHl 0HSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sEscObuH; 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 h1si175476edj.73.2020.12.02.19.10.03; Wed, 02 Dec 2020 19:10:26 -0800 (PST) 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=sEscObuH; 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 S1726977AbgLCDH0 (ORCPT + 99 others); Wed, 2 Dec 2020 22:07:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728063AbgLCDHZ (ORCPT ); Wed, 2 Dec 2020 22:07:25 -0500 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ED2CC061A4E for ; Wed, 2 Dec 2020 19:06:39 -0800 (PST) Received: by mail-lf1-x143.google.com with SMTP id j205so581606lfj.6 for ; Wed, 02 Dec 2020 19:06:39 -0800 (PST) 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=S4QT6Rgw62DbFRwkl+4o96eZwY9j3Q8i5Y9bbEB2ur8=; b=sEscObuHVUeG/B2h90LNy0OMIsrZSv4AbklZsKm0iVkmvH66ybD1szBgIlZe7lcHOW y5tZ4ln4YAiiy/EivHRY2SnvIN9oTRYvd+dovtM1HXHQQGm+7a0HhZpTuBJdWNTevXQa 3Dgki8PsFn/e3FQDVOw6lIukkv1iV3jbsfPoZ9sv3x1GwinJqMP0V3cnYQQiXWCp2VnS QnBb+OQDuClMXAuasFUyuRAUUZWCwAqTp2cfCr4GmpsZCXEJhVujh7zhb2huD19mb8Ng cD/tFXhLfmLZzxkr9DkI92gHjc/PZsqIL6OKUJZ0O3wF+fNgfa/Ljw4ze7FmAtlNBBCD 3vjw== 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=S4QT6Rgw62DbFRwkl+4o96eZwY9j3Q8i5Y9bbEB2ur8=; b=djgfSPzkKM59EZumrutF6H6PMez62CxURSzoMzTQRVI7WMZAyg+XcaydnxN1aK5cFP 6yQH9zbzYfk45GwMPHb29Ct6ZxzN45/HbJ2nHobY7OCyPZYana+JNDdLaWgpAeCbrpu4 Jp6Jv2cM3vc1V4aEdzUbGDowisAlPPwQ7+SFP7yD3ogoLTnyhzxYf7cNS20hoAyw1o5/ OEGLPiqzkvcVjFmyLQKCiQW2iUZCD7uvg6J42xFLZMZ4iXX+6Q2kVh4qu7UxHIZbzRT9 ZT5TNC8VsVxzPhQ7jr8hkFKeOvGBkLdq7mo2F4ym3sbe2EhG6bQ7RFiBBVY5l8Qteo1j tpJQ== X-Gm-Message-State: AOAM530RPI6hgHvvgWTzfC42NKBhtAX+iINvRDcSf3vus+Tmf5Vup86r R8gfwoWmXxPz5F5eNkc/q2i2xv1fqLGEuZNNmh9W8A== X-Received: by 2002:a19:5e5e:: with SMTP id z30mr424001lfi.277.1606964797974; Wed, 02 Dec 2020 19:06:37 -0800 (PST) MIME-Version: 1.0 References: <20201202190824.1309398-1-dlatypov@google.com> <20201202190824.1309398-4-dlatypov@google.com> In-Reply-To: <20201202190824.1309398-4-dlatypov@google.com> From: David Gow Date: Thu, 3 Dec 2020 11:06:26 +0800 Message-ID: Subject: Re: [PATCH v2 4/4] minor: kunit: tool: fix unit test so it can run from non-root dir To: Daniel Latypov Cc: Brendan Higgins , 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, Dec 3, 2020 at 3:09 AM Daniel Latypov wrote: > > Also take this time to rename get_absolute_path() to test_data_path(). > > 1. the name is currently a lie. It gives relative paths, e.g. if I run > from the same dir as the test file, it gives './test_data/' > > See https://docs.python.org/3/reference/import.html#__file__, which > doesn't stipulate that implementations provide absolute paths. > > 2. it's only used for generating paths to tools/testing/kunit/test_data/ > So we can tersen things by making it less general. > > Cache the absolute path to the test data files per suggestion from [1]. > Using relative paths, the tests break because of this code in kunit.py > if get_kernel_root_path(): > os.chdir(get_kernel_root_path()) > > [1] https://lore.kernel.org/linux-kselftest/CABVgOSnH0gz7z5JhRCGyG1wg0zDDBTLoSUCoB-gWMeXLgVTo2w@mail.gmail.com/ > > Fixes: 5578d008d9e0 ("kunit: tool: fix running kunit_tool from outside kernel tree") > Signed-off-by: Daniel Latypov > --- Thanks: I much prefer this to v1. Having it work the same way as test_tmpdir is a bonus. Reviewed-by: David Gow Cheers, -- David