apps: assign android log files to proper variable

When processing Android logs, they need to be assigned to the
logSummary.androidlog variable instead of the logSummary.netlog
variable.  Updated tests to check the log lines are assigned to the
proper variable.

Note:  Also fixed a test that was properly detecting the file type, but
did not have enough data in the simple log under test to verify that the
subsections of a system log were properly assigned.

BUG=chromium:576870
TEST=manually tested on Chrome OS, Brillo and Android logs
TEST=ran 'grunt test'

Change-Id: I5765b3ea9e0931e652eac47b40e41bfcd8e6b8c2
diff --git a/log_helper.js b/log_helper.js
index 21df171..4ca07f0 100644
--- a/log_helper.js
+++ b/log_helper.js
@@ -232,15 +232,14 @@
             .handler(logHolder, logLines, i + 2) + 1;
         break;
       }
-
     }
   }
 
   if (logHolder.fileType == 'unknown') {
     if (androidlogSummary.androidlogTypeCheck(logLines)) {
       // supplied file is an android log file
-      logHolder.fileType = 'androidlog';
-      logHolder.netlog = logLines;
+      logHolder.fileType = 'android_log';
+      logHolder.androidlog = logLines;
     } else if (netlogSummary.netlogTypeCheck(logLines)) {
       // supplied file is netlog
       logHolder.fileType = 'netlog';
diff --git a/test/spec/LogHelperSpec.js b/test/spec/LogHelperSpec.js
index a52f379..de93554 100644
--- a/test/spec/LogHelperSpec.js
+++ b/test/spec/LogHelperSpec.js
@@ -38,8 +38,18 @@
     ];
     log = logLines.concat(basicLog);
     log.push('---------- END ----------');
+    log.push('');
+    log.push('syslog=<multiline>');
+    log.push('---------- START ----------');
+    log.push(time1 + ' ERR shill[807]: [ERROR:wifi.cc(978)] Disconnected ' +
+        'due to inability to connect to the service.');
+    log.push('---------- END ----------');
     var logHolder = logHelper.detectFileType(log);
     expect(logHolder.fileType).toEqual('system_log');
+    expect(logHolder.androidlog).not.toBeDefined();
+    expect(logHolder.netlog.length).toEqual(3);
+    expect(logHolder.syslog.length).toEqual(1);
+    expect(logHolder.brillolog).not.toBeDefined();
   });
 
   it('should detect netlogs', function() {
@@ -54,6 +64,10 @@
     ];
     var logHolder = logHelper.detectFileType(basicLog);
     expect(logHolder.fileType).toEqual('netlog');
+    expect(logHolder.androidlog).not.toBeDefined();
+    expect(logHolder.netlog.length).toEqual(3);
+    expect(logHolder.syslog).not.toBeDefined();
+    expect(logHolder.brillolog).not.toBeDefined();
   });
 
   it('should detect brillo logs', function() {
@@ -68,6 +82,10 @@
     ];
     var logHolder = logHelper.detectFileType(brilloLog);
     expect(logHolder.fileType).toEqual('brillolog');
+    expect(logHolder.androidlog).not.toBeDefined();
+    expect(logHolder.netlog).not.toBeDefined();
+    expect(logHolder.syslog).not.toBeDefined();
+    expect(logHolder.brillolog.length).toEqual(3);
   });
 
   it('should detect an unknown file type', function() {
@@ -78,6 +96,10 @@
     ];
     var logHolder = logHelper.detectFileType(randomFile);
     expect(logHolder.fileType).toEqual('unknown');
+    expect(logHolder.androidlog).not.toBeDefined();
+    expect(logHolder.netlog).not.toBeDefined();
+    expect(logHolder.syslog).not.toBeDefined();
+    expect(logHolder.brillolog).not.toBeDefined();
   });
 
   it('should detect an android bug report file', function() {
@@ -86,6 +108,29 @@
         '== dumpstate: 2015-11-20 12:11:35',
         '========================================================',
         '',
+        '--------- beginning of main',
+        '11-20 12:08:06.463   489   897 D CommandListener: Setting iface cfg',
+        '11-20 12:08:06.521   903  2909 D ConnectivityService: Adding iface ' +
+            'wlan0 to network 169',
+        '[logcat: 0.530s elapsed]',
+        '',
+        '------ EVENT LOG (logcat -b events -v threadtime -d *:v) -----',
+    ];
+    var logHolder = logHelper.detectFileType(androidBugReport);
+    expect(logHolder.fileType).toEqual('android_log');
+    expect(logHolder.androidlog.length).toEqual(2);
+    expect(logHolder.netlog).not.toBeDefined();
+    expect(logHolder.syslog).not.toBeDefined();
+    expect(logHolder.brillolog).not.toBeDefined();
+  });
+
+  it('should ignore info outside main subsection of android bug report file',
+     function() {
+    var androidBugReport = [
+        '========================================================',
+        '== dumpstate: 2015-11-20 12:11:35',
+        '========================================================',
+        '',
         'Build: bullhead-userdebug 6.0.1 MMB29B 2387154 dev-keys',
         '11-20 12:08:02.926   903  2909 D ConnectivityService: ' +
             ' sendStickyBroadcast: action=android.net.conn.CONNECTIVITY_CHANGE',
@@ -100,23 +145,25 @@
     ];
     var logHolder = logHelper.detectFileType(androidBugReport);
     expect(logHolder.fileType).toEqual('android_log');
+    expect(logHolder.androidlog.length).toEqual(2);
+    expect(logHolder.netlog).not.toBeDefined();
+    expect(logHolder.syslog).not.toBeDefined();
+    expect(logHolder.brillolog).not.toBeDefined();
   });
 
   it('should detect an android logcat file', function() {
     var androidBugReport = [
         '',
-        '--------- beginning of system',
-        '03-13 07:44:33.593   345   345 I vold    : ' +
-            'Vold 3.0 (the awakening) firing up',
-        '11-25 14:34:38.797  6323  6628 V KeyValueBackupJob: ' +
-            'Scheduling k/v pass in 247 minutes',
-        '--------- beginning of main',
         '11-20 12:08:06.463   489   897 D CommandListener: Setting iface cfg',
         '11-20 12:08:06.521   903  2909 D ConnectivityService: Adding iface ' +
             'wlan0 to network 169'
     ];
     var logHolder = logHelper.detectFileType(androidBugReport);
     expect(logHolder.fileType).toEqual('android_log');
+    expect(logHolder.androidlog.length).toEqual(3);
+    expect(logHolder.netlog).not.toBeDefined();
+    expect(logHolder.syslog).not.toBeDefined();
+    expect(logHolder.brillolog).not.toBeDefined();
   });
 
   it('should properly determine log offsets', function() {