Loading tests/SystemMemoryTest/host/src/com/android/tests/sysmem/host/Cujs.java +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ public class Cujs { // Do an explicit GC in the system server process as part of the test // case to reduce GC-related sources of noise. // SIGUSR1 = 10 is the magic signal to trigger the GC. int pid = mDevice.getPidForProcess("system_server"); int pid = mDevice.getProcessPid("system_server"); mDevice.executeShellCommand("kill -10 " + pid); // Invoke the Device Cujs instrumentation to run the cujs. Loading tests/SystemMemoryTest/host/src/com/android/tests/sysmem/host/Device.java +7 −24 Original line number Diff line number Diff line Loading @@ -19,9 +19,6 @@ package com.android.tests.sysmem.host; import com.android.tradefed.device.DeviceNotAvailableException; import com.android.tradefed.device.ITestDevice; import java.util.InputMismatchException; import java.util.Scanner; /** * Wrapper around ITestDevice exposing useful device functions. */ Loading Loading @@ -58,29 +55,15 @@ class Device { /** * Returns the pid for the process with the given name. */ public int getPidForProcess(String name) throws TestException { String psout = executeShellCommand("ps -A -o PID,CMD"); Scanner sc = new Scanner(psout); public int getProcessPid(String name) throws TestException { try { // ps output is of the form: // PID CMD // 1 init // 2 kthreadd // ... // 9693 ps sc.nextLine(); while (sc.hasNextLine()) { int pid = sc.nextInt(); String cmd = sc.next(); if (name.equals(cmd)) { return pid; } String pid = mDevice.getProcessPid(name); if (pid == null) { throw new TestException("failed to get pid for " + name); } } catch (InputMismatchException e) { throw new TestException("unexpected ps output format: " + psout, e); return Integer.parseInt(pid); } catch (DeviceNotAvailableException e) { throw new TestException(e); } throw new TestException("failed to get pid for process " + name); } } tests/SystemMemoryTest/host/src/com/android/tests/sysmem/host/Metrics.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ class Metrics { // adb root access is required to get showmap mDevice.enableAdbRoot(); int pid = mDevice.getPidForProcess("system_server"); int pid = mDevice.getProcessPid("system_server"); // Read showmap for system server and add it as a test log String showmap = mDevice.executeShellCommand("showmap " + pid); Loading Loading
tests/SystemMemoryTest/host/src/com/android/tests/sysmem/host/Cujs.java +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ public class Cujs { // Do an explicit GC in the system server process as part of the test // case to reduce GC-related sources of noise. // SIGUSR1 = 10 is the magic signal to trigger the GC. int pid = mDevice.getPidForProcess("system_server"); int pid = mDevice.getProcessPid("system_server"); mDevice.executeShellCommand("kill -10 " + pid); // Invoke the Device Cujs instrumentation to run the cujs. Loading
tests/SystemMemoryTest/host/src/com/android/tests/sysmem/host/Device.java +7 −24 Original line number Diff line number Diff line Loading @@ -19,9 +19,6 @@ package com.android.tests.sysmem.host; import com.android.tradefed.device.DeviceNotAvailableException; import com.android.tradefed.device.ITestDevice; import java.util.InputMismatchException; import java.util.Scanner; /** * Wrapper around ITestDevice exposing useful device functions. */ Loading Loading @@ -58,29 +55,15 @@ class Device { /** * Returns the pid for the process with the given name. */ public int getPidForProcess(String name) throws TestException { String psout = executeShellCommand("ps -A -o PID,CMD"); Scanner sc = new Scanner(psout); public int getProcessPid(String name) throws TestException { try { // ps output is of the form: // PID CMD // 1 init // 2 kthreadd // ... // 9693 ps sc.nextLine(); while (sc.hasNextLine()) { int pid = sc.nextInt(); String cmd = sc.next(); if (name.equals(cmd)) { return pid; } String pid = mDevice.getProcessPid(name); if (pid == null) { throw new TestException("failed to get pid for " + name); } } catch (InputMismatchException e) { throw new TestException("unexpected ps output format: " + psout, e); return Integer.parseInt(pid); } catch (DeviceNotAvailableException e) { throw new TestException(e); } throw new TestException("failed to get pid for process " + name); } }
tests/SystemMemoryTest/host/src/com/android/tests/sysmem/host/Metrics.java +1 −1 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ class Metrics { // adb root access is required to get showmap mDevice.enableAdbRoot(); int pid = mDevice.getPidForProcess("system_server"); int pid = mDevice.getProcessPid("system_server"); // Read showmap for system server and add it as a test log String showmap = mDevice.executeShellCommand("showmap " + pid); Loading