Gabriele Monaco <[email protected]> writes:
> The RVGenerator class can find the RV directory (kernel/trace/rv) in the
> kernel tree to do some auto patching. This works by assuming PWD is
> either the kernel tree or tools/verification, which isn't always the
> case (e.g. when running from selftests).
>
> Make discovery more robust by relying on the absolute path of the
> current script and traversing backwards the right number of times.
> This should work from any location if rvgen is in the kernel tree.

Agree.

> +        # find the kernel tree root relative to this file's location
> +        current_dir = os.path.dirname(os.path.abspath(__file__))
> +        kernel_root = os.path.abspath(os.path.join(current_dir, 
> "../../../.."))


The  "../../../.." makes me sad.

We can find the git project root instead. For example:

def getGitRoot():
    return subprocess.Popen(['git', 'rev-parse', '--show-toplevel'], 
stdout=subprocess.PIPE).communicate()[0].rstrip().decode('utf-8')

(stolen from 
https://stackoverflow.com/questions/22081209/find-the-root-of-the-git-repository-where-the-file-lives)

But that's not important, up to you.

Nam

Reply via email to