Report suite name to result server

Send an additional form value indicating what test suite the XML is for.
The test plan name could suffice, but it could get confusing if we run
shorter plans that aren't called CTS. Thus, send an additional parameter
that is separate from the XML.

Change-Id: Iade46dbbf8a16c4883cee9fee434bf296bab8bef
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 {