| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ | 6 """ |
| 7 Unit tests for the contents of device_utils.py (mostly DeviceUtils). | 7 Unit tests for the contents of device_utils.py (mostly DeviceUtils). |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 # pylint: disable=C0321 | 10 # pylint: disable=C0321 |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 with self.assertCalls( | 613 with self.assertCalls( |
| 614 (self.call.adb.Shell(cmd), self.ShellError('', None)), | 614 (self.call.adb.Shell(cmd), self.ShellError('', None)), |
| 615 (mock.call.pylib.utils.device_temp_file.DeviceTempFile(self.adb), | 615 (mock.call.pylib.utils.device_temp_file.DeviceTempFile(self.adb), |
| 616 temp_file), | 616 temp_file), |
| 617 (self.call.adb.Shell(cmd_redirect)), | 617 (self.call.adb.Shell(cmd_redirect)), |
| 618 (self.call.device.ReadFile(mock.ANY), 'something')): | 618 (self.call.device.ReadFile(mock.ANY), 'something')): |
| 619 self.assertEquals(['something'], | 619 self.assertEquals(['something'], |
| 620 self.device.RunShellCommand(cmd, check_return=True)) | 620 self.device.RunShellCommand(cmd, check_return=True)) |
| 621 | 621 |
| 622 | 622 |
| 623 class DeviceUtilsRunPipedShellCommandTest(DeviceUtilsTest): |
| 624 |
| 625 def testRunPipedShellCommand_success(self): |
| 626 with self.assertCall( |
| 627 self.call.device.RunShellCommand( |
| 628 'ps | grep foo; echo "PIPESTATUS: ${PIPESTATUS[@]}"', |
| 629 check_return=True), |
| 630 ['This line contains foo', 'PIPESTATUS: 0 0']): |
| 631 self.assertEquals(['This line contains foo'], |
| 632 self.device._RunPipedShellCommand('ps | grep foo')) |
| 633 |
| 634 def testRunPipedShellCommand_firstCommandFails(self): |
| 635 with self.assertCall( |
| 636 self.call.device.RunShellCommand( |
| 637 'ps | grep foo; echo "PIPESTATUS: ${PIPESTATUS[@]}"', |
| 638 check_return=True), |
| 639 ['PIPESTATUS: 1 0']): |
| 640 with self.assertRaises(device_errors.AdbShellCommandFailedError) as ec: |
| 641 self.device._RunPipedShellCommand('ps | grep foo') |
| 642 self.assertEquals([1, 0], ec.exception.status) |
| 643 |
| 644 def testRunPipedShellCommand_secondCommandFails(self): |
| 645 with self.assertCall( |
| 646 self.call.device.RunShellCommand( |
| 647 'ps | grep foo; echo "PIPESTATUS: ${PIPESTATUS[@]}"', |
| 648 check_return=True), |
| 649 ['PIPESTATUS: 0 1']): |
| 650 with self.assertRaises(device_errors.AdbShellCommandFailedError) as ec: |
| 651 self.device._RunPipedShellCommand('ps | grep foo') |
| 652 self.assertEquals([0, 1], ec.exception.status) |
| 653 |
| 654 def testRunPipedShellCommand_outputCutOff(self): |
| 655 with self.assertCall( |
| 656 self.call.device.RunShellCommand( |
| 657 'ps | grep foo; echo "PIPESTATUS: ${PIPESTATUS[@]}"', |
| 658 check_return=True), |
| 659 ['foo.bar'] * 256 + ['foo.ba']): |
| 660 with self.assertRaises(device_errors.AdbShellCommandFailedError) as ec: |
| 661 self.device._RunPipedShellCommand('ps | grep foo') |
| 662 self.assertIs(None, ec.exception.status) |
| 663 |
| 664 |
| 623 class DeviceUtilsGetDevicePieWrapper(DeviceUtilsTest): | 665 class DeviceUtilsGetDevicePieWrapper(DeviceUtilsTest): |
| 624 | 666 |
| 625 def testGetDevicePieWrapper_jb(self): | 667 def testGetDevicePieWrapper_jb(self): |
| 626 with self.assertCall( | 668 with self.assertCall( |
| 627 self.call.device.build_version_sdk(), | 669 self.call.device.build_version_sdk(), |
| 628 constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): | 670 constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN): |
| 629 self.assertEqual('', self.device.GetDevicePieWrapper()) | 671 self.assertEqual('', self.device.GetDevicePieWrapper()) |
| 630 | 672 |
| 631 def testGetDevicePieWrapper_ics(self): | 673 def testGetDevicePieWrapper_ics(self): |
| 632 with self.assertCalls( | 674 with self.assertCalls( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 647 self.device.KillAll('test_process') | 689 self.device.KillAll('test_process') |
| 648 | 690 |
| 649 def testKillAll_noMatchingProcessesQuiet(self): | 691 def testKillAll_noMatchingProcessesQuiet(self): |
| 650 with self.assertCall(self.call.device.GetPids('test_process'), {}): | 692 with self.assertCall(self.call.device.GetPids('test_process'), {}): |
| 651 self.assertEqual(0, self.device.KillAll('test_process', quiet=True)) | 693 self.assertEqual(0, self.device.KillAll('test_process', quiet=True)) |
| 652 | 694 |
| 653 def testKillAll_nonblocking(self): | 695 def testKillAll_nonblocking(self): |
| 654 with self.assertCalls( | 696 with self.assertCalls( |
| 655 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), | 697 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), |
| 656 (self.call.adb.Shell('kill -9 1234'), '')): | 698 (self.call.adb.Shell('kill -9 1234'), '')): |
| 657 self.assertEquals(1, | 699 self.assertEquals( |
| 658 self.device.KillAll('some.process', blocking=False)) | 700 1, self.device.KillAll('some.process', blocking=False)) |
| 659 | 701 |
| 660 def testKillAll_blocking(self): | 702 def testKillAll_blocking(self): |
| 661 with self.assertCalls( | 703 with self.assertCalls( |
| 662 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), | 704 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), |
| 663 (self.call.adb.Shell('kill -9 1234'), ''), | 705 (self.call.adb.Shell('kill -9 1234'), ''), |
| 664 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), | 706 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), |
| 665 (self.call.device.GetPids('some.process'), {})): | 707 (self.call.device.GetPids('some.process'), [])): |
| 666 self.assertEquals(1, | 708 self.assertEquals( |
| 667 self.device.KillAll('some.process', blocking=True)) | 709 1, self.device.KillAll('some.process', blocking=True)) |
| 668 | 710 |
| 669 def testKillAll_root(self): | 711 def testKillAll_root(self): |
| 670 with self.assertCalls( | 712 with self.assertCalls( |
| 671 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), | 713 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), |
| 672 (self.call.device.NeedsSU(), True), | 714 (self.call.device.NeedsSU(), True), |
| 673 (self.call.adb.Shell("su -c sh -c 'kill -9 1234'"), '')): | 715 (self.call.adb.Shell("su -c sh -c 'kill -9 1234'"), '')): |
| 674 self.assertEquals(1, | 716 self.assertEquals( |
| 675 self.device.KillAll('some.process', as_root=True)) | 717 1, self.device.KillAll('some.process', as_root=True)) |
| 676 | 718 |
| 677 def testKillAll_sigterm(self): | 719 def testKillAll_sigterm(self): |
| 678 with self.assertCalls( | 720 with self.assertCalls( |
| 679 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), | 721 (self.call.device.GetPids('some.process'), {'some.process': '1234'}), |
| 680 (self.call.adb.Shell('kill -15 1234'), '')): | 722 (self.call.adb.Shell('kill -15 1234'), '')): |
| 681 self.assertEquals(1, | 723 self.assertEquals( |
| 682 self.device.KillAll('some.process', signum=device_signal.SIGTERM)) | 724 1, self.device.KillAll('some.process', signum=device_signal.SIGTERM)) |
| 683 | 725 |
| 684 | 726 |
| 685 class DeviceUtilsStartActivityTest(DeviceUtilsTest): | 727 class DeviceUtilsStartActivityTest(DeviceUtilsTest): |
| 686 | 728 |
| 687 def testStartActivity_actionOnly(self): | 729 def testStartActivity_actionOnly(self): |
| 688 test_intent = intent.Intent(action='android.intent.action.VIEW') | 730 test_intent = intent.Intent(action='android.intent.action.VIEW') |
| 689 with self.assertCall( | 731 with self.assertCall( |
| 690 self.call.adb.Shell('am start ' | 732 self.call.adb.Shell('am start ' |
| 691 '-a android.intent.action.VIEW'), | 733 '-a android.intent.action.VIEW'), |
| 692 'Starting: Intent { act=android.intent.action.VIEW }'): | 734 'Starting: Intent { act=android.intent.action.VIEW }'): |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 with self.assertRaises(device_errors.CommandFailedError): | 1142 with self.assertRaises(device_errors.CommandFailedError): |
| 1101 self.device._ReadFileWithPull('/path/to/device/file') | 1143 self.device._ReadFileWithPull('/path/to/device/file') |
| 1102 | 1144 |
| 1103 def testReadFile_exists(self): | 1145 def testReadFile_exists(self): |
| 1104 with self.assertCalls( | 1146 with self.assertCalls( |
| 1105 (self.call.device.RunShellCommand( | 1147 (self.call.device.RunShellCommand( |
| 1106 ['ls', '-l', '/read/this/test/file'], | 1148 ['ls', '-l', '/read/this/test/file'], |
| 1107 as_root=False, check_return=True), | 1149 as_root=False, check_return=True), |
| 1108 ['-rw-rw---- root foo 256 1970-01-01 00:00 file']), | 1150 ['-rw-rw---- root foo 256 1970-01-01 00:00 file']), |
| 1109 (self.call.device.RunShellCommand( | 1151 (self.call.device.RunShellCommand( |
| 1110 ['cat', '/read/this/test/file'], as_root=False, check_return=True), | 1152 ['cat', '/read/this/test/file'], |
| 1153 as_root=False, check_return=True), |
| 1111 ['this is a test file'])): | 1154 ['this is a test file'])): |
| 1112 self.assertEqual('this is a test file\n', | 1155 self.assertEqual('this is a test file\n', |
| 1113 self.device.ReadFile('/read/this/test/file')) | 1156 self.device.ReadFile('/read/this/test/file')) |
| 1114 | 1157 |
| 1115 def testReadFile_doesNotExist(self): | 1158 def testReadFile_doesNotExist(self): |
| 1116 with self.assertCall( | 1159 with self.assertCall( |
| 1117 self.call.device.RunShellCommand( | 1160 self.call.device.RunShellCommand( |
| 1118 ['ls', '-l', '/this/file/does.not.exist'], | 1161 ['ls', '-l', '/this/file/does.not.exist'], |
| 1119 as_root=False, check_return=True), | 1162 as_root=False, check_return=True), |
| 1120 self.CommandError('File does not exist')): | 1163 self.CommandError('File does not exist')): |
| 1121 with self.assertRaises(device_errors.CommandFailedError): | 1164 with self.assertRaises(device_errors.CommandFailedError): |
| 1122 self.device.ReadFile('/this/file/does.not.exist') | 1165 self.device.ReadFile('/this/file/does.not.exist') |
| 1123 | 1166 |
| 1167 def testReadFile_zeroSize(self): |
| 1168 with self.assertCalls( |
| 1169 (self.call.device.RunShellCommand( |
| 1170 ['ls', '-l', '/this/file/has/zero/size'], |
| 1171 as_root=False, check_return=True), |
| 1172 ['-r--r--r-- root foo 0 1970-01-01 00:00 zero_size_file']), |
| 1173 (self.call.device._ReadFileWithPull('/this/file/has/zero/size'), |
| 1174 'but it has contents\n')): |
| 1175 self.assertEqual('but it has contents\n', |
| 1176 self.device.ReadFile('/this/file/has/zero/size')) |
| 1177 |
| 1124 def testReadFile_withSU(self): | 1178 def testReadFile_withSU(self): |
| 1125 with self.assertCalls( | 1179 with self.assertCalls( |
| 1126 (self.call.device.RunShellCommand( | 1180 (self.call.device.RunShellCommand( |
| 1127 ['ls', '-l', '/this/file/can.be.read.with.su'], | 1181 ['ls', '-l', '/this/file/can.be.read.with.su'], |
| 1128 as_root=True, check_return=True), | 1182 as_root=True, check_return=True), |
| 1129 ['-rw------- root root 256 1970-01-01 00:00 can.be.read.with.su']), | 1183 ['-rw------- root root 256 1970-01-01 00:00 can.be.read.with.su']), |
| 1130 (self.call.device.RunShellCommand( | 1184 (self.call.device.RunShellCommand( |
| 1131 ['cat', '/this/file/can.be.read.with.su'], | 1185 ['cat', '/this/file/can.be.read.with.su'], |
| 1132 as_root=True, check_return=True), | 1186 as_root=True, check_return=True), |
| 1133 ['this is a test file', 'read with su'])): | 1187 ['this is a test file', 'read with su'])): |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 with self.assertCalls( | 1426 with self.assertCalls( |
| 1373 (self.call.adb.Shell('setprop test.property new_value'), ''), | 1427 (self.call.adb.Shell('setprop test.property new_value'), ''), |
| 1374 (self.call.adb.Shell('getprop test.property'), 'old_value')): | 1428 (self.call.adb.Shell('getprop test.property'), 'old_value')): |
| 1375 with self.assertRaises(device_errors.CommandFailedError): | 1429 with self.assertRaises(device_errors.CommandFailedError): |
| 1376 self.device.SetProp('test.property', 'new_value', check=True) | 1430 self.device.SetProp('test.property', 'new_value', check=True) |
| 1377 | 1431 |
| 1378 | 1432 |
| 1379 class DeviceUtilsGetPidsTest(DeviceUtilsTest): | 1433 class DeviceUtilsGetPidsTest(DeviceUtilsTest): |
| 1380 | 1434 |
| 1381 def testGetPids_noMatches(self): | 1435 def testGetPids_noMatches(self): |
| 1382 with self.assertCall(self.call.adb.Shell('ps'), | 1436 with self.assertCall( |
| 1383 'USER PID PPID VSIZE RSS WCHAN PC NAME\n' | 1437 self.call.device._RunPipedShellCommand('ps | grep -F does.not.match'), |
| 1384 'user 1000 100 1024 1024 ffffffff 00000000 no.match\n'): | 1438 []): |
| 1385 self.assertEqual({}, self.device.GetPids('does.not.match')) | 1439 self.assertEqual({}, self.device.GetPids('does.not.match')) |
| 1386 | 1440 |
| 1387 def testGetPids_oneMatch(self): | 1441 def testGetPids_oneMatch(self): |
| 1388 with self.assertCall(self.call.adb.Shell('ps'), | 1442 with self.assertCall( |
| 1389 'USER PID PPID VSIZE RSS WCHAN PC NAME\n' | 1443 self.call.device._RunPipedShellCommand('ps | grep -F one.match'), |
| 1390 'user 1000 100 1024 1024 ffffffff 00000000 not.a.match\n' | 1444 ['user 1001 100 1024 1024 ffffffff 00000000 one.match']): |
| 1391 'user 1001 100 1024 1024 ffffffff 00000000 one.match\n'): | |
| 1392 self.assertEqual({'one.match': '1001'}, self.device.GetPids('one.match')) | 1445 self.assertEqual({'one.match': '1001'}, self.device.GetPids('one.match')) |
| 1393 | 1446 |
| 1394 def testGetPids_mutlipleMatches(self): | 1447 def testGetPids_mutlipleMatches(self): |
| 1395 with self.assertCall(self.call.adb.Shell('ps'), | 1448 with self.assertCall( |
| 1396 'USER PID PPID VSIZE RSS WCHAN PC NAME\n' | 1449 self.call.device._RunPipedShellCommand('ps | grep -F match'), |
| 1397 'user 1000 100 1024 1024 ffffffff 00000000 not\n' | 1450 ['user 1001 100 1024 1024 ffffffff 00000000 one.match', |
| 1398 'user 1001 100 1024 1024 ffffffff 00000000 one.match\n' | 1451 'user 1002 100 1024 1024 ffffffff 00000000 two.match', |
| 1399 'user 1002 100 1024 1024 ffffffff 00000000 two.match\n' | 1452 'user 1003 100 1024 1024 ffffffff 00000000 three.match']): |
| 1400 'user 1003 100 1024 1024 ffffffff 00000000 three.match\n'): | |
| 1401 self.assertEqual( | 1453 self.assertEqual( |
| 1402 {'one.match': '1001', 'two.match': '1002', 'three.match': '1003'}, | 1454 {'one.match': '1001', 'two.match': '1002', 'three.match': '1003'}, |
| 1403 self.device.GetPids('match')) | 1455 self.device.GetPids('match')) |
| 1404 | 1456 |
| 1405 def testGetPids_exactMatch(self): | 1457 def testGetPids_exactMatch(self): |
| 1406 with self.assertCall(self.call.adb.Shell('ps'), | 1458 with self.assertCall( |
| 1407 'USER PID PPID VSIZE RSS WCHAN PC NAME\n' | 1459 self.call.device._RunPipedShellCommand('ps | grep -F exact.match'), |
| 1408 'user 1000 100 1024 1024 ffffffff 00000000 not.exact.match\n' | 1460 ['user 1000 100 1024 1024 ffffffff 00000000 not.exact.match', |
| 1409 'user 1234 100 1024 1024 ffffffff 00000000 exact.match\n'): | 1461 'user 1234 100 1024 1024 ffffffff 00000000 exact.match']): |
| 1410 self.assertEqual( | 1462 self.assertEqual( |
| 1411 {'not.exact.match': '1000', 'exact.match': '1234'}, | 1463 {'not.exact.match': '1000', 'exact.match': '1234'}, |
| 1412 self.device.GetPids('exact.match')) | 1464 self.device.GetPids('exact.match')) |
| 1413 | 1465 |
| 1466 def testGetPids_quotable(self): |
| 1467 with self.assertCall( |
| 1468 self.call.device._RunPipedShellCommand("ps | grep -F 'my$process'"), |
| 1469 ['user 1234 100 1024 1024 ffffffff 00000000 my$process']): |
| 1470 self.assertEqual( |
| 1471 {'my$process': '1234'}, self.device.GetPids('my$process')) |
| 1472 |
| 1414 | 1473 |
| 1415 class DeviceUtilsTakeScreenshotTest(DeviceUtilsTest): | 1474 class DeviceUtilsTakeScreenshotTest(DeviceUtilsTest): |
| 1416 | 1475 |
| 1417 def testTakeScreenshot_fileNameProvided(self): | 1476 def testTakeScreenshot_fileNameProvided(self): |
| 1418 with self.assertCalls( | 1477 with self.assertCalls( |
| 1419 (mock.call.pylib.utils.device_temp_file.DeviceTempFile( | 1478 (mock.call.pylib.utils.device_temp_file.DeviceTempFile( |
| 1420 self.adb, suffix='.png'), | 1479 self.adb, suffix='.png'), |
| 1421 MockTempFile('/tmp/path/temp-123.png')), | 1480 MockTempFile('/tmp/path/temp-123.png')), |
| 1422 (self.call.adb.Shell('/system/bin/screencap -p /tmp/path/temp-123.png'), | 1481 (self.call.adb.Shell('/system/bin/screencap -p /tmp/path/temp-123.png'), |
| 1423 ''), | 1482 ''), |
| 1424 self.call.device.PullFile('/tmp/path/temp-123.png', | 1483 self.call.device.PullFile('/tmp/path/temp-123.png', |
| 1425 '/test/host/screenshot.png')): | 1484 '/test/host/screenshot.png')): |
| 1426 self.device.TakeScreenshot('/test/host/screenshot.png') | 1485 self.device.TakeScreenshot('/test/host/screenshot.png') |
| 1427 | 1486 |
| 1428 | 1487 |
| 1429 class DeviceUtilsGetMemoryUsageForPidTest(DeviceUtilsTest): | 1488 class DeviceUtilsGetMemoryUsageForPidTest(DeviceUtilsTest): |
| 1430 | 1489 |
| 1431 def setUp(self): | 1490 def setUp(self): |
| 1432 super(DeviceUtilsGetMemoryUsageForPidTest, self).setUp() | 1491 super(DeviceUtilsGetMemoryUsageForPidTest, self).setUp() |
| 1433 | 1492 |
| 1434 def testGetMemoryUsageForPid_validPid(self): | 1493 def testGetMemoryUsageForPid_validPid(self): |
| 1435 with self.assertCalls( | 1494 with self.assertCalls( |
| 1436 (self.call.device.RunShellCommand( | 1495 (self.call.device._RunPipedShellCommand( |
| 1437 ['showmap', '1234'], as_root=True, check_return=True), | 1496 'showmap 1234 | grep TOTAL', as_root=True), |
| 1438 ['100 101 102 103 104 105 106 107 TOTAL']), | 1497 ['100 101 102 103 104 105 106 107 TOTAL']), |
| 1439 (self.call.device.ReadFile('/proc/1234/status', as_root=True), | 1498 (self.call.device.ReadFile('/proc/1234/status', as_root=True), |
| 1440 'VmHWM: 1024 kB\n')): | 1499 'VmHWM: 1024 kB\n')): |
| 1441 self.assertEqual( | 1500 self.assertEqual( |
| 1442 { | 1501 { |
| 1443 'Size': 100, | 1502 'Size': 100, |
| 1444 'Rss': 101, | 1503 'Rss': 101, |
| 1445 'Pss': 102, | 1504 'Pss': 102, |
| 1446 'Shared_Clean': 103, | 1505 'Shared_Clean': 103, |
| 1447 'Shared_Dirty': 104, | 1506 'Shared_Dirty': 104, |
| 1448 'Private_Clean': 105, | 1507 'Private_Clean': 105, |
| 1449 'Private_Dirty': 106, | 1508 'Private_Dirty': 106, |
| 1450 'VmHWM': 1024 | 1509 'VmHWM': 1024 |
| 1451 }, | 1510 }, |
| 1452 self.device.GetMemoryUsageForPid(1234)) | 1511 self.device.GetMemoryUsageForPid(1234)) |
| 1453 | 1512 |
| 1454 def testGetMemoryUsageForPid_noSmaps(self): | 1513 def testGetMemoryUsageForPid_noSmaps(self): |
| 1455 with self.assertCalls( | 1514 with self.assertCalls( |
| 1456 (self.call.device.RunShellCommand( | 1515 (self.call.device._RunPipedShellCommand( |
| 1457 ['showmap', '4321'], as_root=True, check_return=True), | 1516 'showmap 4321 | grep TOTAL', as_root=True), |
| 1458 ['cannot open /proc/4321/smaps: No such file or directory']), | 1517 ['cannot open /proc/4321/smaps: No such file or directory']), |
| 1459 (self.call.device.ReadFile('/proc/4321/status', as_root=True), | 1518 (self.call.device.ReadFile('/proc/4321/status', as_root=True), |
| 1460 'VmHWM: 1024 kb\n')): | 1519 'VmHWM: 1024 kb\n')): |
| 1461 self.assertEquals({'VmHWM': 1024}, self.device.GetMemoryUsageForPid(4321)) | 1520 self.assertEquals({'VmHWM': 1024}, self.device.GetMemoryUsageForPid(4321)) |
| 1462 | 1521 |
| 1463 def testGetMemoryUsageForPid_noStatus(self): | 1522 def testGetMemoryUsageForPid_noStatus(self): |
| 1464 with self.assertCalls( | 1523 with self.assertCalls( |
| 1465 (self.call.device.RunShellCommand( | 1524 (self.call.device._RunPipedShellCommand( |
| 1466 ['showmap', '4321'], as_root=True, check_return=True), | 1525 'showmap 4321 | grep TOTAL', as_root=True), |
| 1467 ['100 101 102 103 104 105 106 107 TOTAL']), | 1526 ['100 101 102 103 104 105 106 107 TOTAL']), |
| 1468 (self.call.device.ReadFile('/proc/4321/status', as_root=True), | 1527 (self.call.device.ReadFile('/proc/4321/status', as_root=True), |
| 1469 self.CommandError())): | 1528 self.CommandError())): |
| 1470 self.assertEquals( | 1529 self.assertEquals( |
| 1471 { | 1530 { |
| 1472 'Size': 100, | 1531 'Size': 100, |
| 1473 'Rss': 101, | 1532 'Rss': 101, |
| 1474 'Pss': 102, | 1533 'Pss': 102, |
| 1475 'Shared_Clean': 103, | 1534 'Shared_Clean': 103, |
| 1476 'Shared_Dirty': 104, | 1535 'Shared_Dirty': 104, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1532 self.assertEqual(client_cache_one, {'test': 1}) | 1591 self.assertEqual(client_cache_one, {'test': 1}) |
| 1533 self.assertEqual(client_cache_two, {'test': 1}) | 1592 self.assertEqual(client_cache_two, {'test': 1}) |
| 1534 self.device._ClearCache() | 1593 self.device._ClearCache() |
| 1535 self.assertEqual(client_cache_one, {}) | 1594 self.assertEqual(client_cache_one, {}) |
| 1536 self.assertEqual(client_cache_two, {}) | 1595 self.assertEqual(client_cache_two, {}) |
| 1537 | 1596 |
| 1538 if __name__ == '__main__': | 1597 if __name__ == '__main__': |
| 1539 logging.getLogger().setLevel(logging.DEBUG) | 1598 logging.getLogger().setLevel(logging.DEBUG) |
| 1540 unittest.main(verbosity=2) | 1599 unittest.main(verbosity=2) |
| 1541 | 1600 |
| OLD | NEW |