drgn/vmtest/asynciosubprocess.py
Omar Sandoval 841a3dae88 Move vmtest assets to GitHub releases
As noted by commit 738261290f ("CI: temporarily disable vmtest"),
vmtest was generating too much traffic to the Dropbox shared folder that
hosted vmtest kernels. Instead, we can store kernel packages as GitHub
release assets. Update the code for downloading and uploading vmtest
assets, and also add a scheduled GitHub action to build new kernels
every Monday so I don't have to remember to do it manually.

This also drops vmtest support for 5.6-5.9, which now fail to build with
newer binutils due to the issue fixed in Linux kernel commit
1d489151e9f9 ("objtool: Don't fail on missing symbol table").

Signed-off-by: Omar Sandoval <osandov@osandov.com>
2021-05-05 00:28:56 -07:00

47 lines
1.4 KiB
Python

# Copyright (c) Facebook, Inc. and its affiliates.
# SPDX-License-Identifier: GPL-3.0-or-later
import asyncio
from contextlib import contextmanager
import os
from subprocess import CalledProcessError as CalledProcessError
from typing import Any, Iterator, Tuple
async def check_call(*args: Any, **kwds: Any) -> None:
proc = await asyncio.create_subprocess_exec(*args, **kwds)
returncode = await proc.wait()
if returncode != 0:
raise CalledProcessError(returncode, args)
async def check_output(*args: Any, **kwds: Any) -> bytes:
kwds["stdout"] = asyncio.subprocess.PIPE
proc = await asyncio.create_subprocess_exec(*args, **kwds)
stdout = (await proc.communicate())[0]
if proc.returncode:
raise CalledProcessError(proc.returncode, args)
return stdout
async def check_output_shell(cmd: str, **kwds: Any) -> bytes:
kwds["stdout"] = asyncio.subprocess.PIPE
proc = await asyncio.create_subprocess_shell(cmd, **kwds)
stdout = (await proc.communicate())[0]
if proc.returncode:
raise CalledProcessError(proc.returncode, cmd)
return stdout
@contextmanager
def pipe_context() -> Iterator[Tuple[int, int]]:
pipe_r = pipe_w = None
try:
pipe_r, pipe_w = os.pipe()
yield pipe_r, pipe_w
finally:
if pipe_r is not None:
os.close(pipe_r)
if pipe_w is not None:
os.close(pipe_w)