From 8fa96e09ad86d44115fd778b638bd71513b3c4e5 Mon Sep 17 00:00:00 2001 From: Eric Rowe Date: Mon, 14 Dec 2015 14:32:31 -0800 Subject: Add support for more fields in procrank Bug: 26140048 Change-Id: I9b7e46ee9fb5eb34de56ff4832ec942947b5b2cc --- .../loganalysis/parser/ProcrankParserTest.java | 35 +++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/src/com/android/loganalysis/parser/ProcrankParserTest.java b/tests/src/com/android/loganalysis/parser/ProcrankParserTest.java index a5be424..c47b750 100644 --- a/tests/src/com/android/loganalysis/parser/ProcrankParserTest.java +++ b/tests/src/com/android/loganalysis/parser/ProcrankParserTest.java @@ -31,7 +31,7 @@ public class ProcrankParserTest extends TestCase { /** * Test that normal input is parsed. */ - public void testProcRankParser() { + public void testProcRankParserShortLine() { List inputBlock = Arrays.asList( " PID Vss Rss Pss Uss cmdline", " 178 87136K 81684K 52829K 50012K system_server", @@ -61,6 +61,39 @@ public class ProcrankParserTest extends TestCase { assertEquals(ArrayUtil.join("\n", inputBlock), procrank.getText()); } + /** + * Test that normal input is parsed. + */ + public void testProcRankParserLongLine() { + List inputBlock = Arrays.asList( + " PID Vss Rss Pss Uss Swap PSwap USwap ZSwap cmdline", + " 6711 3454396K 146300K 108431K 105524K 31540K 20522K 20188K 4546K com.google.android.GoogleCamera", + " 1515 2535920K 131984K 93750K 89440K 42676K 31792K 31460K 7043K system_server", + "19906 2439540K 130228K 85418K 69296K 11680K 353K 0K 78K com.android.chrome:sandboxed_process10", + "13790 2596308K 124424K 75673K 69680K 11336K 334K 0K 74K com.google.android.youtube", + " 9288 2437704K 119496K 74288K 69532K 11344K 334K 0K 74K com.google.android.videos", + " 51312K 22911K 20608K 0K 0K 0K invalid.format", + " ------ ------ ------ ------ ------ ------ ------", + " 1061237K 940460K 619796K 225468K 201688K 49950K TOTAL", + "ZRAM: 52892K physical used for 238748K in swap (520908K total swap)", + "RAM: 1857348K total, 51980K free, 3780K buffers, 456272K cached, 29220K shmem, 97560K slab", + "[/system/xbin/su: 3.260s elapsed]"); + + ProcrankItem procrank = new ProcrankParser().parse(inputBlock); + + // Ensures that only valid lines are parsed. Only 6 of the 11 lines under the header are + // valid. + assertEquals(5, procrank.getPids().size()); + + // Make sure all expected rows are present, and do a diagonal check of values + assertEquals((Integer) 3454396, procrank.getVss(6711)); + assertEquals((Integer) 146300, procrank.getRss(6711)); + assertEquals((Integer) 108431, procrank.getPss(6711)); + assertEquals((Integer) 105524, procrank.getUss(6711)); + assertEquals("com.google.android.GoogleCamera", procrank.getProcessName(6711)); + assertEquals(ArrayUtil.join("\n", inputBlock), procrank.getText()); + } + /** * Test that an empty input returns {@code null}. */ -- cgit v1.2.3