am 95c3fff9: am f7206d96: am 6ab432b1: Merge "Report suite name to result server" into jb-mr1-dev
* commit '95c3fff94c8dad0009fffbb61f6fab89a20ca8e3':
Report suite name to result server
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
index 3c46d9b..95ec69f 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildHelper.java
@@ -32,6 +32,7 @@
static final String CTS_DIR_NAME = "android-cts";
static final String PTS_DIR_NAME = "android-pts";
static private boolean mCtsMode = true;
+ private final String mSuiteName;
/** The root location of the extracted CTS package */
private final File mRootDir;
/** the {@link CTS_DIR_NAME} directory */
@@ -49,6 +50,7 @@
*/
public CtsBuildHelper(File rootDir) {
mRootDir = rootDir;
+ mSuiteName = mCtsMode? "CTS" : "PTS";
mCtsDir = new File(mRootDir, mCtsMode ? CTS_DIR_NAME : PTS_DIR_NAME);
}
@@ -86,6 +88,10 @@
}
}
+ public String getSuiteName() {
+ return mSuiteName;
+ }
+
/**
* @return a {@link File} representing the parent folder of the CTS installation
*/
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
index c140b6f..a2a31e0 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
@@ -95,7 +95,7 @@
private TestResults mResults = new TestResults();
private TestPackageResult mCurrentPkgResult = null;
private boolean mIsDeviceInfoRun = false;
-
+ private ResultReporter mReporter;
private File mLogDir;
private static final String PTS_PERFORMANCE_EXCEPTION = "com.android.pts.util.PtsException";
@@ -115,12 +115,13 @@
throw new IllegalArgumentException("build info is not a IFolderBuildInfo");
}
IFolderBuildInfo ctsBuild = (IFolderBuildInfo)buildInfo;
+ CtsBuildHelper ctsBuildHelper = getBuildHelper(ctsBuild);
mDeviceSerial = buildInfo.getDeviceSerial() == null ? "unknown_device" :
buildInfo.getDeviceSerial();
if (mContinueSessionId != null) {
CLog.d("Continuing session %d", mContinueSessionId);
// reuse existing directory
- TestResultRepo resultRepo = new TestResultRepo(getBuildHelper(ctsBuild).getResultsDir());
+ TestResultRepo resultRepo = new TestResultRepo(ctsBuildHelper.getResultsDir());
mResults = resultRepo.getResult(mContinueSessionId);
if (mResults == null) {
throw new IllegalArgumentException(String.format("Could not find session %d",
@@ -131,7 +132,7 @@
mReportDir = resultRepo.getReportDir(mContinueSessionId);
} else {
if (mReportDir == null) {
- mReportDir = getBuildHelper(ctsBuild).getResultsDir();
+ mReportDir = ctsBuildHelper.getResultsDir();
}
// create a unique directory for saving results, using old cts host convention
// TODO: in future, consider using LogFileSaver to create build-specific directories
@@ -140,6 +141,9 @@
mStartTime = getTimestamp();
logResult("Created result dir %s", mReportDir.getName());
}
+
+ mReporter = new ResultReporter(mResultServer, ctsBuildHelper.getSuiteName());
+
// TODO: allow customization of log dir
// create a unique directory for saving logs, with same name as result dir
File rootLogDir = getBuildHelper(ctsBuild).getLogsDir();
@@ -283,8 +287,7 @@
zipResults(mReportDir);
try {
- ResultReporter reporter = new ResultReporter(mResultServer, reportFile);
- reporter.reportResult();
+ mReporter.reportResult(reportFile);
} catch (IOException e) {
CLog.e(e);
}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java
index 05192c9..199cbc5 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/ResultReporter.java
@@ -30,23 +30,23 @@
private static final int RESULT_XML_BYTES = 500 * 1024;
private final String mServerUrl;
+ private final String mSuiteName;
- private final File mReportFile;
-
- ResultReporter(String serverUrl, File reportFile) {
+ ResultReporter(String serverUrl, String suiteName) {
mServerUrl = serverUrl;
- mReportFile = reportFile;
+ mSuiteName = suiteName;
}
- public void reportResult() throws IOException {
+ public void reportResult(File reportFile) throws IOException {
if (isEmpty(mServerUrl)) {
return;
}
- InputStream input = new FileInputStream(mReportFile);
+ InputStream input = new FileInputStream(reportFile);
try {
byte[] data = IssueReporter.getBytes(input, RESULT_XML_BYTES);
new MultipartForm(mServerUrl)
+ .addFormValue("suite", mSuiteName)
.addFormFile("resultXml", "testResult.xml.gz", data)
.submit();
} finally {