Skip to content

Commit 51b35d2

Browse files
committed
Fix detection of encode complete in test
The -d argument was thought to delete the existing Android logs. However, this was not the case. As a result, the python tests were concluding that the file being encoded finished near immediately, and concluded that the incomplete file existed so the test passed. This change uses the -t argument of logcat to gather all logs since a given time, and will pass in the time the test started. This way, the python test will properly wait until the encoding has completed before pulling the file. Further, it will not conclude that encoding was successful if it never even started.
1 parent cdb79d8 commit 51b35d2

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

app/src/test/shell/test.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import collections
77
import time
8+
from datetime import datetime
89

910
ASSETS = os.path.dirname(os.path.realpath(__file__)) + os.sep + "assets"
1011

@@ -18,11 +19,8 @@ def adb(args):
1819
if result != 0:
1920
raise Exception("adb failed with " + str(result) + ": " + str(cmd))
2021

21-
def clearLogcat():
22-
adb(["shell", "logcat", "-c"])
23-
24-
def logcat():
25-
p = subprocess.Popen(["adb", "logcat", "-d"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
22+
def logcat(sinceTime):
23+
p = subprocess.Popen(["adb", "logcat", "-t", sinceTime], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2624
stdout, stderr = p.communicate()
2725
rc = p.wait()
2826
if rc != 0:
@@ -40,12 +38,12 @@ def pushAsset(filename):
4038

4139
def encodeVideoTest(test, output):
4240
pushAsset(test.filename)
43-
clearLogcat()
41+
startTime = datetime.now().strftime('%m-%d %H:%M:%S.000')
4442
encodeVideo(test.filename, output, test.mediaContainer, test.videoCodec, test.videoBitrateK, test.resolution, test.fps, test.audioCodec, test.audioSampleRate, test.audioBitrateK, test.audioChannel)
4543

4644
logs = None
4745
for count in range(1, 300):
48-
logs = logcat()
46+
logs = logcat(startTime)
4947
if "Encode result" in logs:
5048
break
5149
time.sleep(1)
@@ -122,12 +120,12 @@ def encodeVideo(filename, output, mediaContainer, videoCodec, videoBitrateK, res
122120

123121
def encodeAudioTest(test, output):
124122
pushAsset(test.filename)
125-
clearLogcat()
123+
startTime = datetime.now().strftime('%m-%d %H:%M:%S.000')
126124
encodeAudio(test.filename, output, test.mediaContainer, test.audioCodec, test.audioSampleRate, test.audioBitrateK, test.audioChannel)
127125

128126
logs = None
129127
for count in range(1, 300):
130-
logs = logcat()
128+
logs = logcat(startTime)
131129
if "Encode result" in logs:
132130
break
133131
time.sleep(1)

0 commit comments

Comments
 (0)