aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulien Desprez <jdesprez@google.com>2016-12-06 09:51:53 +0000
committerJulien Desprez <jdesprez@google.com>2016-12-14 10:04:37 +0000
commitcce7e1241d2a61aafba9ea8da665d42cc6017f52 (patch)
tree343009318bd54b9454496213a344b09e93e4b90c /src
parent8001fd7954bea2fb3a63c0999b493428e18cf81e (diff)
downloadcontrib-cce7e1241d2a61aafba9ea8da665d42cc6017f52.tar.gz
Address some code base usage
- close utility - cancel utility - deleteFile utility - logging of stacks Bug: 32101899 Change-Id: Id988f12ae6d05456cac3a397c01059b81cf64b02
Diffstat (limited to 'src')
-rw-r--r--src/com/android/media/tests/Camera2FrameworkStressTest.java9
-rw-r--r--src/com/android/media/tests/Camera2StressTest.java9
-rw-r--r--src/com/android/media/tests/CameraTestBase.java50
3 files changed, 36 insertions, 32 deletions
diff --git a/src/com/android/media/tests/Camera2FrameworkStressTest.java b/src/com/android/media/tests/Camera2FrameworkStressTest.java
index 139eda7..f9e949b 100644
--- a/src/com/android/media/tests/Camera2FrameworkStressTest.java
+++ b/src/com/android/media/tests/Camera2FrameworkStressTest.java
@@ -148,11 +148,14 @@ public class Camera2FrameworkStressTest extends CameraTestBase {
postMetrics.put(keyName, resultMap.get(KEY_ITERATION));
}
} catch (IOException e) {
- CLog.w("Couldn't parse the output log file: ", e);
+ CLog.w("Couldn't parse the output log file");
+ CLog.e(e);
} catch (DeviceNotAvailableException e) {
- CLog.w("Could not pull file: %s, error: %s", RESULT_DIR, e);
+ CLog.w("Could not pull file: %s, error:", RESULT_DIR);
+ CLog.e(e);
} catch (NumberFormatException e) {
- CLog.w("Could not find the key in file: %s, error: %s", KEY_NUM_ATTEMPTS, e);
+ CLog.w("Could not find the key in file: %s, error:", KEY_NUM_ATTEMPTS);
+ CLog.e(e);
}
return postMetrics;
}
diff --git a/src/com/android/media/tests/Camera2StressTest.java b/src/com/android/media/tests/Camera2StressTest.java
index b106f69..fec5b02 100644
--- a/src/com/android/media/tests/Camera2StressTest.java
+++ b/src/com/android/media/tests/Camera2StressTest.java
@@ -170,11 +170,14 @@ public class Camera2StressTest extends CameraTestBase {
// Post the number of iterations only with the test name as key.
testMetrics.put(testName, resultMap.get(KEY_ITERATION));
} catch (IOException e) {
- CLog.w("Couldn't parse the output log file: ", e);
+ CLog.w("Couldn't parse the output log file:");
+ CLog.e(e);
} catch (DeviceNotAvailableException e) {
- CLog.w("Could not pull file: %s, error: %s", RESULT_FILE, e);
+ CLog.w("Could not pull file: %s, error:", RESULT_FILE);
+ CLog.e(e);
} catch (NumberFormatException e) {
- CLog.w("Could not find the key in file: %s, error: %s", KEY_NUM_ATTEMPTS, e);
+ CLog.w("Could not find the key in file: %s, error:", KEY_NUM_ATTEMPTS);
+ CLog.e(e);
}
}
}
diff --git a/src/com/android/media/tests/CameraTestBase.java b/src/com/android/media/tests/CameraTestBase.java
index 81c07d5..e7eceb6 100644
--- a/src/com/android/media/tests/CameraTestBase.java
+++ b/src/com/android/media/tests/CameraTestBase.java
@@ -36,6 +36,7 @@ import com.android.tradefed.testtype.InstrumentationTest;
import com.android.tradefed.util.FileUtil;
import com.android.tradefed.util.IRunUtil;
import com.android.tradefed.util.RunUtil;
+import com.android.tradefed.util.StreamUtil;
import junit.framework.Assert;
@@ -360,11 +361,10 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
mListener.testLog(logName, LogDataType.TEXT, outputSource);
outputFile.delete();
} catch (FileNotFoundException e) {
- CLog.w("Failed to read meminfo log %s: %s", outputFile, e);
+ CLog.e("Failed to read meminfo log %s:", outputFile);
+ CLog.e(e);
} finally {
- if (outputSource != null) {
- outputSource.cancel();
- }
+ StreamUtil.cancel(outputSource);
}
}
if (shouldDumpThreadCount()) {
@@ -376,11 +376,10 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
mListener.testLog(logName, LogDataType.TEXT, outputSource);
outputFile.delete();
} catch (FileNotFoundException e) {
- CLog.w("Failed to read thread count log %s: %s", outputFile, e);
+ CLog.e("Failed to read thread count log %s", outputFile);
+ CLog.e(e);
} finally {
- if (outputSource != null) {
- outputSource.cancel();
- }
+ StreamUtil.cancel(outputSource);
}
}
}
@@ -512,7 +511,8 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
writer.flush();
writer.close();
} catch (IOException e) {
- CLog.w("Failed to create meminfo log file %s: %s", mOutputFile.getAbsolutePath(), e);
+ CLog.w("Failed to create meminfo log file %s:", mOutputFile.getAbsolutePath());
+ CLog.e(e);
return null;
}
return mOutputFile;
@@ -527,7 +527,8 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
SHELL_TIMEOUT_MS, TimeUnit.MILLISECONDS, SHELL_MAX_ATTEMPTS);
printMeminfo(outputFile, receiver.getOutput());
} catch (DeviceNotAvailableException e) {
- CLog.w("Failed to dump meminfo: %s", e);
+ CLog.w("Failed to dump meminfo:");
+ CLog.e(e);
}
}
@@ -578,15 +579,10 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
writer.newLine();
writer.flush();
} catch (IOException e) {
- CLog.w("Failed to print meminfo to %s: %s", outputFile.getAbsolutePath(), e);
+ CLog.w("Failed to print meminfo to %s:", outputFile.getAbsolutePath());
+ CLog.e(e);
} finally {
- if (writer != null) {
- try {
- writer.close();
- } catch (IOException e) {
- CLog.w("Failed to close %s: %s", outputFile.getAbsolutePath(), e);
- }
- }
+ StreamUtil.close(writer);
}
}
@@ -659,8 +655,9 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
String.format("ps_%s", test.getTestName()), "txt");
new BufferedWriter(new FileWriter(mOutputFile, false)).close();
} catch (IOException e) {
- CLog.w("Failed to create processes and threads file %s: %s",
- mOutputFile.getAbsolutePath(), e);
+ CLog.w("Failed to create processes and threads file %s:",
+ mOutputFile.getAbsolutePath());
+ CLog.e(e);
return null;
}
return mOutputFile;
@@ -672,7 +669,8 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
result = getDevice().executeShellCommand(String.format(PGREP_COMMAND_FORMAT,
processName));
} catch (DeviceNotAvailableException e) {
- CLog.w("Failed to get pid %s: %s", processName, e);
+ CLog.w("Failed to get pid %s:", processName);
+ CLog.e(e);
}
return result;
}
@@ -706,10 +704,9 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
writer.newLine();
writer.flush();
writer.close();
- } catch (DeviceNotAvailableException e) {
- CLog.w("Failed to dump thread count: %s", e);
- } catch (IOException e) {
- CLog.w("Failed to dump thread count: %s", e);
+ } catch (DeviceNotAvailableException | IOException e) {
+ CLog.w("Failed to dump thread count:");
+ CLog.e(e);
}
}
}
@@ -728,7 +725,8 @@ public class CameraTestBase implements IDeviceTest, IRemoteTest, IConfigurationR
new ByteArrayInputStreamSource(result.getBytes()));
}
} catch (DeviceNotAvailableException e) {
- CLog.w("Failed to dump ION heaps: %s", e);
+ CLog.w("Failed to dump ION heaps:");
+ CLog.e(e);
}
}