프로세스유틸

public final class ProcessUtil
extends Object

java.lang.객체
com.android.sts.common.ProcessUtil


장치에서 프로세스를 찾고 대기하고 종료하는 다양한 도우미

요약

중첩 클래스

class ProcessUtil.KillException

상수

long PROCESS_POLL_PERIOD_MS

long PROCESS_WAIT_TIMEOUT_MS

공개 방법

static Optional<IFileEntry> findFileLoadedByProcess (ITestDevice device, String process, String filenameSubstr)

지정된 이름을 가진 지정된 프로세스에 의해 로드된 첫 번째 파일의 파일 항목을 반환합니다.

static Optional<List<String>> findFilesLoadedByProcess (ITestDevice device, int pid, Pattern filePattern)

지정된 프로세스에 의해 로드된 지정된 파일의 파일 이름을 반환합니다.

static Optional<String> getProcessName (ITestDevice device, int pid)

/proc/pid/cmdline에서 내용을 가져옵니다.

static boolean killAll (ITestDevice device, String pgrepRegex, long timeoutMs, boolean expectExist)

패턴과 일치하는 모든 프로세스에 SIGKILL을 보냅니다.

static boolean killAll (ITestDevice device, String pgrepRegex, long timeoutMs)

패턴과 일치하는 모든 프로세스에 SIGKILL을 보냅니다.

static void killPid (ITestDevice device, int pid, long timeoutMs)

프로세스에 SIGKILL을 보내고 프로세스가 종료될 때까지 기다립니다.

static void killPid (ITestDevice device, int pid, int signal, long timeoutMs)

프로세스에 신호를 보내고 프로세스가 종료될 때까지 기다립니다.

static Optional<List<String>> listOpenFiles (ITestDevice device, int pid)

지정된 프로세스의 현재 열려 있는 파일 이름을 반환합니다.

static Optional<Integer> pidOf (ITestDevice device, String pgrepRegex)

`pgrep`에 전달된 패턴과 일치하는 단일 pid를 가져옵니다.

static Optional<Map<Integer, String>> pidsOf (ITestDevice device, String pgrepRegex)

`pgrep`에 전달된 패턴과 일치하는 pid를 가져옵니다.

static void waitPidExited (ITestDevice device, int pid)

프로세스가 종료될 때까지 기다리십시오.

static void waitPidExited (ITestDevice device, int pid, long timeoutMs)

프로세스가 종료될 때까지 기다리십시오.

static Map<Integer, String> waitProcessRunning (ITestDevice device, String pgrepRegex, long timeoutMs)

지정된 정규식에 대해 실행 중인 프로세스를 찾을 때까지 기다립니다.

static Map<Integer, String> waitProcessRunning (ITestDevice device, String pgrepRegex)

지정된 정규식에 대해 실행 중인 프로세스를 찾을 때까지 기다립니다.

static AutoCloseable withProcessKill (ITestDevice device, String pgrepRegex, Runnable beforeCloseKill, long timeoutMs)

테스트 시작과 끝에서 프로세스를 종료합니다.

static AutoCloseable withProcessKill (ITestDevice device, String pgrepRegex, Runnable beforeCloseKill)

테스트 시작과 끝에서 프로세스를 종료합니다.

상수

PROCESS_POLL_PERIOD_MS

public static final long PROCESS_POLL_PERIOD_MS

상수 값: 250(0x00000000000000fa)

PROCESS_WAIT_TIMEOUT_MS

public static final long PROCESS_WAIT_TIMEOUT_MS

상수 값: 10000(0x0000000000002710)

공개 방법

findFileLoadedByProcess

public static Optional<IFileEntry> findFileLoadedByProcess (ITestDevice device, 
                String process, 
                String filenameSubstr)

지정된 이름을 가진 지정된 프로세스에 의해 로드된 첫 번째 파일의 파일 항목을 반환합니다.

매개변수
device ITestDevice : 실행할 장치

process String : 찾을 프로세스의 pgrep 패턴

filenameSubstr String : 프로세스에 의해 로드된 파일 이름/경로의 일부

보고
Optional<IFileEntry> 존재하는 경우 장치에 있는 파일 경로의 IFileEntry 옵션입니다.

던지기
DeviceNotAvailableException

findFilesLoadedByProcess

public static Optional<List<String>> findFilesLoadedByProcess (ITestDevice device, 
                int pid, 
                Pattern filePattern)

지정된 프로세스에 의해 로드된 지정된 파일의 파일 이름을 반환합니다.

매개변수
device ITestDevice : 실행할 장치

pid int : 검색할 프로세스의 id

filePattern Pattern : 반환할 파일 이름의 패턴

보고
Optional<List<String>> 필터링된 파일의 선택적; 프로세스를 찾을 수 없거나 열려 있는 파일을 읽을 수 없으면 비어 있습니다.

던지기
DeviceNotAvailableException

getProcessName

public static Optional<String> getProcessName (ITestDevice device, 
                int pid)

/proc/pid/cmdline에서 내용을 가져옵니다.

매개변수
device ITestDevice : 사용할 장치

pid int : 이름을 얻기 위한 프로세스의 id

보고
Optional<String> /proc/pid/cmdline 내용의 선택적 문자열; pid를 찾을 수 없으면 비어 있습니다.

던지기
DeviceNotAvailableException

다 죽여

public static boolean killAll (ITestDevice device, 
                String pgrepRegex, 
                long timeoutMs, 
                boolean expectExist)

패턴과 일치하는 모든 프로세스에 SIGKILL을 보냅니다.

매개변수
device ITestDevice : 사용할 장치

pgrepRegex String : pgrep의 정규식을 나타내는 문자열

timeoutMs long : TimeoutException을 던지기 전에 대기하는 시간

expectExist boolean : 종료된 프로세스가 없을 때 예외를 발생시켜야 하는지 여부

보고
boolean 프로세스가 종료되었는지 여부

던지기
DeviceNotAvailableException
TimeoutException
ProcessUtil.KillException

다 죽여

public static boolean killAll (ITestDevice device, 
                String pgrepRegex, 
                long timeoutMs)

패턴과 일치하는 모든 프로세스에 SIGKILL을 보냅니다.

매개변수
device ITestDevice : 사용할 장치

pgrepRegex String : pgrep의 정규식을 나타내는 문자열

timeoutMs long : TimeoutException을 던지기 전에 대기하는 시간

보고
boolean 프로세스가 종료되었는지 여부

던지기
DeviceNotAvailableException
TimeoutException
ProcessUtil.KillException

killPid

public static void killPid (ITestDevice device, 
                int pid, 
                long timeoutMs)

프로세스에 SIGKILL을 보내고 프로세스가 종료될 때까지 기다립니다.

매개변수
device ITestDevice : 사용할 장치

pid int : 종료될 때까지 대기할 프로세스의 id

timeoutMs long : TimeoutException을 던지기 전에 대기하는 시간

던지기
DeviceNotAvailableException
TimeoutException
ProcessUtil.KillException

killPid

public static void killPid (ITestDevice device, 
                int pid, 
                int signal, 
                long timeoutMs)

프로세스에 신호를 보내고 프로세스가 종료될 때까지 기다립니다.

매개변수
device ITestDevice : 사용할 장치

pid int : 종료될 때까지 대기할 프로세스의 id

signal int : 프로세스에 보낼 신호

timeoutMs long : TimeoutException을 던지기 전에 대기하는 시간

던지기
DeviceNotAvailableException
TimeoutException
ProcessUtil.KillException

listOpenFiles

public static Optional<List<String>> listOpenFiles (ITestDevice device, 
                int pid)

지정된 프로세스의 현재 열려 있는 파일 이름을 반환합니다.

매개변수
device ITestDevice : 실행할 장치

pid int : 검색할 프로세스의 id

보고
Optional<List<String>> 열린 파일의 선택적; 프로세스를 찾을 수 없거나 열려 있는 파일을 읽을 수 없으면 비어 있습니다.

던지기
DeviceNotAvailableException

pidOf

public static Optional<Integer> pidOf (ITestDevice device, 
                String pgrepRegex)

`pgrep`에 전달된 패턴과 일치하는 단일 pid를 가져옵니다. 패턴과 일치하는 PID가 둘 이상인 경우 IllegalArgumentException 을 발생시킵니다.

매개변수
device ITestDevice : 사용할 장치

pgrepRegex String : pgrep의 정규식을 나타내는 문자열

보고
Optional<Integer> pid의 선택적 정수; pgrep이 EXIT_SUCCESS를 반환하지 않은 경우 비어 있음

던지기
DeviceNotAvailableException
IllegalArgumentException

pidsOf

public static Optional<Map<Integer, String>> pidsOf (ITestDevice device, 
                String pgrepRegex)

`pgrep`에 전달된 패턴과 일치하는 pid를 가져옵니다. /proc/pid/comm이 잘렸기 때문에 전체 명령줄을 확인하기 위해 `pgrep`이 `-f`와 함께 전달됩니다.

매개변수
device ITestDevice : 사용할 장치

pgrepRegex String : pgrep의 정규식을 나타내는 문자열

보고
Optional<Map<Integer, String>> 커맨드 라인에 대한 pid의 선택적 맵; pgrep이 EXIT_SUCCESS를 반환하지 않은 경우 비어 있음

던지기
DeviceNotAvailableException

waitPid 종료됨

public static void waitPidExited (ITestDevice device, 
                int pid)

프로세스가 종료될 때까지 기다리십시오. 이것은 그것이 변하기를 기다리는 것이 아니라 단순히 존재하지 않는 것입니다. pid가 투표 사이에 재사용되는 것은 가능하지만 가능성은 낮습니다.

매개변수
device ITestDevice : 사용할 장치

pid int : 종료될 때까지 대기할 프로세스의 id

던지기
TimeoutException
DeviceNotAvailableException
ProcessUtil.KillException

waitPid 종료됨

public static void waitPidExited (ITestDevice device, 
                int pid, 
                long timeoutMs)

프로세스가 종료될 때까지 기다리십시오. 이것은 그것이 변하기를 기다리는 것이 아니라 단순히 존재하지 않는 것입니다. pid가 투표 사이에 재사용되는 것은 가능하지만 가능성은 낮습니다.

매개변수
device ITestDevice : 사용할 장치

pid int : 종료될 때까지 대기할 프로세스의 id

timeoutMs long : TimeoutException을 던지기 전에 대기하는 시간

던지기
TimeoutException
DeviceNotAvailableException
ProcessUtil.KillException

waitProcess실행 중

public static Map<Integer, String> waitProcessRunning (ITestDevice device, 
                String pgrepRegex, 
                long timeoutMs)

지정된 정규식에 대해 실행 중인 프로세스를 찾을 때까지 기다립니다.

매개변수
device ITestDevice : 사용할 장치

pgrepRegex String : pgrep의 정규식을 나타내는 문자열

timeoutMs long : TimeoutException을 던지기 전에 대기하는 시간

보고
Map<Integer, String> pidsOf(...)에서 명령 맵으로의 pid

던지기
TimeoutException
DeviceNotAvailableException

waitProcess실행 중

public static Map<Integer, String> waitProcessRunning (ITestDevice device, 
                String pgrepRegex)

지정된 정규식에 대해 실행 중인 프로세스를 찾을 때까지 기다립니다.

매개변수
device ITestDevice : 사용할 장치

pgrepRegex String : pgrep의 정규식을 나타내는 문자열

보고
Map<Integer, String> pidsOf(...)에서 명령 맵으로의 pid

던지기
TimeoutException
DeviceNotAvailableException

withProcessKill

public static AutoCloseable withProcessKill (ITestDevice device, 
                String pgrepRegex, 
                Runnable beforeCloseKill, 
                long timeoutMs)

테스트 시작과 끝에서 프로세스를 종료합니다.

매개변수
device ITestDevice : 사용할 장치

pgrepRegex String : pgrep에 제공하기 위해 죽일 프로세스의 이름 패턴

beforeCloseKill Runnable : 일반 환경에서 테스트 종료 시 프로세스를 종료하기 전에 정리해야 하는 모든 작업에 대한 실행 가능 항목입니다. null일 수 있습니다.

timeoutMs long : 프로세스가 종료될 때까지 대기하는 시간(밀리초)

보고
AutoCloseable 프로세스가 닫힐 때 프로세스를 다시 종료하는 객체

던지기
DeviceNotAvailableException
TimeoutException
ProcessUtil.KillException

withProcessKill

public static AutoCloseable withProcessKill (ITestDevice device, 
                String pgrepRegex, 
                Runnable beforeCloseKill)

테스트 시작과 끝에서 프로세스를 종료합니다.

매개변수
device ITestDevice : 사용할 장치

pgrepRegex String : pgrep에 제공하기 위해 죽일 프로세스의 이름 패턴

beforeCloseKill Runnable : 일반 환경에서 테스트 종료 시 프로세스를 종료하기 전에 정리해야 하는 모든 작업에 대한 실행 가능 항목입니다. null일 수 있습니다.

보고
AutoCloseable 프로세스가 닫힐 때 프로세스를 다시 종료하는 객체

던지기
DeviceNotAvailableException
TimeoutException
ProcessUtil.KillException