summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTetsui Ohkubo <tetsui@google.com>2015-10-06 17:42:22 +0900
committerTetsui Ohkubo <tetsui@google.com>2015-10-14 10:05:43 +0900
commit8a64160b924919a2ff80afeff73fe645d2995156 (patch)
tree0db79b71984c3b27be968a38ecdeae794d285292 /tests
parent8fbbc70563619f83cec64358fb3f230cdcc168c0 (diff)
downloadloganalysis-8a64160b924919a2ff80afeff73fe645d2995156.tar.gz
Add cpuinfo log collector to AUPT
Change-Id: I1daa01a9d1312c7356667ca80909487b9ce5df5c
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/loganalysis/parser/CpuInfoParserTest.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/src/com/android/loganalysis/parser/CpuInfoParserTest.java b/tests/src/com/android/loganalysis/parser/CpuInfoParserTest.java
new file mode 100644
index 0000000..b400db5
--- /dev/null
+++ b/tests/src/com/android/loganalysis/parser/CpuInfoParserTest.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.loganalysis.parser;
+
+import com.android.loganalysis.item.CpuInfoItem;
+
+import junit.framework.TestCase;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class CpuInfoParserTest extends TestCase {
+
+ public void testSingleLine() {
+ List<String> input = Arrays.asList(" 0.1% 170/surfaceflinger: 0% user + 0% kernel");
+
+ CpuInfoItem item = new CpuInfoParser().parse(input);
+
+ assertEquals(1, item.getPids().size());
+ assertEquals("surfaceflinger", item.getName(170));
+ assertEquals(0.1, item.getPercent(170), 0.0001);
+ }
+
+ public void testMultipleLines() {
+ List<String> input = Arrays.asList(
+ "CPU usage from 35935ms to 26370ms ago:",
+ " 57% 489/system_server: 37% user + 20% kernel / faults: 39754 minor 57 major",
+ " 34% 853/com.google.android.leanbacklauncher: 30% user + 4.6% kernel / faults: 7838 minor 14 major",
+ " 15% 19463/com.google.android.videos: 11% user + 3.3% kernel / faults: 21603 minor 141 major",
+ " 8.2% 170/surfaceflinger: 3.4% user + 4.8% kernel / faults: 1 minor");
+ CpuInfoItem item = new CpuInfoParser().parse(input);
+
+ assertEquals(4, item.getPids().size());
+ assertEquals("system_server", item.getName(489));
+ assertEquals(57.0, item.getPercent(489), 0.0001);
+ assertEquals("surfaceflinger", item.getName(170));
+ assertEquals(8.2, item.getPercent(170), 0.0001);
+ }
+
+}
+