Skip to content

Commit e82c8d4

Browse files
committed
Fixed multiple ---PROFILEDATA--- found in Gfxinfo framestats
- Remove sys.argv entries when test run by utrunner.py
1 parent 56b8db6 commit e82c8d4

File tree

4 files changed

+93
-19
lines changed

4 files changed

+93
-19
lines changed

.idea/runConfigurations/Unittests_in_DumpsysTests.xml

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/com/dtmilano/android/adb/dumpsys.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
@author: Diego Torres Milano
1818
'''
1919
import re
20+
from _warnings import warn
2021

21-
__version__ = '13.1.9'
22+
__version__ = '13.1.10'
2223

2324

2425
class Dumpsys:
@@ -45,8 +46,11 @@ def __init__(self, adbclient, subcommand, *args):
4546
args_str = ' '.join(args)
4647
else:
4748
args_str = ''
48-
cmd = 'dumpsys ' + subcommand + (' ' + args_str if args_str else '')
49-
self.parse(adbclient.shell(cmd), subcommand, *args)
49+
if adbclient:
50+
cmd = 'dumpsys ' + subcommand + (' ' + args_str if args_str else '')
51+
self.parse(adbclient.shell(cmd), subcommand, *args)
52+
else:
53+
warn('No adbclient specified')
5054

5155
@staticmethod
5256
def listSubCommands(adbclient):
@@ -104,21 +108,25 @@ def parseGfxinfo(self, out):
104108

105109
def parseGfxinfoFramestats(self, out):
106110
pd = '---PROFILEDATA---'
107-
m = re.search(r'%s.*?%s' % (pd, pd), out, re.DOTALL)
108-
if m:
109-
pdc = 0
110-
for d in m.group(0).splitlines():
111-
pda = d.split(',')
112-
if pda[0] == pd:
113-
continue
114-
if pda[0] == 'Flags':
115-
if pda[1] != 'IntendedVsync' and pda[13] != 'FrameCompleted':
116-
raise RuntimeError('Unsupported gfxinfo version')
111+
l = re.findall(r'%s.*?%s' % (pd, pd), out, re.DOTALL)
112+
if l:
113+
s = ''
114+
for e in l:
115+
if not e:
117116
continue
118-
if pda[0] == '0':
119-
# Only keep lines with Flags=0
120-
self.gfxProfileData.append(pda[:-1])
121-
self.framestats.append(int(pda[13]) - int(pda[1]))
117+
sl = e.splitlines()
118+
for s in sl:
119+
if s == pd:
120+
continue
121+
pda = s.split(',')
122+
if pda[0] == 'Flags':
123+
if pda[1] != 'IntendedVsync' and pda[13] != 'FrameCompleted':
124+
raise RuntimeError('Unsupported gfxinfo version')
125+
continue
126+
if pda[0] == '0':
127+
# Only keep lines with Flags=0
128+
self.gfxProfileData.append(pda[:-1])
129+
self.framestats.append(int(pda[13]) - int(pda[1]))
122130
else:
123131
raise RuntimeError('No profile data found')
124132

src/com/dtmilano/android/viewclient.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4494,6 +4494,9 @@ def setUp(self):
44944494
else:
44954495
raise RuntimeError('serial number missing')
44964496
i += 1
4497+
# remove the test runner arguments, otherwise they will be found by connectToDeviceOrExit()
4498+
sys.argv.remove(testname)
4499+
sys.argv.remove(testargs)
44974500

44984501
if self.serialno:
44994502
# serialno can be 1 serialno, multiple serialnos, 'all' or 'default'

tests/com/dtmilano/android/adb/dumpsystests2.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
from __future__ import absolute_import
22

3+
import os
34
import unittest
45

6+
import sys
7+
8+
try:
9+
sys.path.insert(0, os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
10+
except:
11+
pass
12+
513
from com.dtmilano.android.adb import adbclient
614
from com.dtmilano.android.adb.dumpsys import Dumpsys
715

@@ -47,8 +55,39 @@ def test_get_activities(self):
4755
def test_gfxinfo_1(self):
4856
self.assertGreater(len(self.dumpsysGfxinfo.gfxProfileData), 0)
4957

50-
def test_gfxinfo_2(self):
51-
self.assertGreater(len(self.dumpsysGfxinfo.gfxProfileDataDiff), 0)
58+
# def test_gfxinfo_2(self):
59+
# self.assertGreater(len(self.dumpsysGfxinfo.gfxProfileDataDiff), 0)
60+
61+
def test_parseGfxinfoFramestats(self):
62+
out = '''\
63+
Something
64+
Something
65+
Something
66+
Something
67+
68+
---PROFILEDATA---
69+
Flags,IntendedVsync,Vsync,OldestInputEvent,NewestInputEvent,HandleInputStart,AnimationStart,PerformTraversalsStart,DrawStart,SyncQueued,SyncStart,IssueDrawCommandsStart,SwapBuffers,FrameCompleted,
70+
0,1538750837982,1539034171304,9223372036854775807,0,1539047401632,1539047424965,1539047516299,1539047541049,1539047873632,1539048042382,1539048073215,1539085917465,1539087148465,
71+
0,1808866542439,1808899875771,9223372036854775807,0,1808909338401,1808909869234,1808911205068,1808911288234,1808911729484,1808911906651,1808912287651,1808920894568,1808922659568,
72+
---PROFILEDATA---
73+
74+
Something
75+
Something
76+
Something
77+
Something
78+
Something
79+
80+
---PROFILEDATA---
81+
Flags,IntendedVsync,Vsync,OldestInputEvent,NewestInputEvent,HandleInputStart,AnimationStart,PerformTraversalsStart,DrawStart,SyncQueued,SyncStart,IssueDrawCommandsStart,SwapBuffers,FrameCompleted,
82+
1,1538295812863,1538495812855,9223372036854775807,0,1538506027632,1538506079049,1538506994882,1538517724382,1538550285632,1538550403216,1538550458966,1538559445132,1538561759382,
83+
---PROFILEDATA---
84+
85+
86+
87+
88+
'''
89+
dumpsys = Dumpsys(None, None)
90+
dumpsys.parseGfxinfoFramestats(out)
5291

5392

5493
if __name__ == '__main__':

0 commit comments

Comments
 (0)