summaryrefslogtreecommitdiffstats
path: root/tests/DumpRenderTree/assets
diff options
context:
space:
mode:
authorGuang Zhu <guangzhu@google.com>2009-06-01 11:36:03 -0700
committerGuang Zhu <guangzhu@google.com>2009-06-01 11:36:03 -0700
commit65455a1a46e3bec020befd27ff5ad6bfdab61a7d (patch)
tree072548a78697f3f81740dc0f89865e6ba5c31380 /tests/DumpRenderTree/assets
parent162c9d0e90eaa71adc8c7d1456d1a9a95e638c47 (diff)
downloadframeworks_base-65455a1a46e3bec020befd27ff5ad6bfdab61a7d.zip
frameworks_base-65455a1a46e3bec020befd27ff5ad6bfdab61a7d.tar.gz
frameworks_base-65455a1a46e3bec020befd27ff5ad6bfdab61a7d.tar.bz2
Update reliability test code. Use a separate activity with simpler calback mechanism.
Diffstat (limited to 'tests/DumpRenderTree/assets')
-rwxr-xr-xtests/DumpRenderTree/assets/run_reliability_tests.py76
1 files changed, 19 insertions, 57 deletions
diff --git a/tests/DumpRenderTree/assets/run_reliability_tests.py b/tests/DumpRenderTree/assets/run_reliability_tests.py
index a242293..c12c783 100755
--- a/tests/DumpRenderTree/assets/run_reliability_tests.py
+++ b/tests/DumpRenderTree/assets/run_reliability_tests.py
@@ -10,10 +10,8 @@
import logging
import optparse
-import random
import subprocess
import sys
-import time
TEST_LIST_FILE = "/sdcard/android/reliability_tests_list.txt"
TEST_STATUS_FILE = "/sdcard/android/reliability_running_test.txt"
@@ -41,40 +39,16 @@ def DumpRenderTreeFinished(adb_cmd):
return adb_output.strip() == "#DONE"
-def RandomPick(file_name, approx_size, num_needed):
- """Randomly pick lines from the text file specifed.
-
- Args:
- file_name: the text file where lines should be picked from
- approx_size: an approximate size of the text file
- num_needed: how many lines are needed from the file
-
- Returns:
- an array of string
- """
- p = float(num_needed) / approx_size
- num_picked = 0
- lines = []
- random.seed()
-
- while num_picked < num_needed:
- file_handle = open(file_name, "r")
- for line in file_handle:
- line = line.strip()
- if float(random.randint(0, approx_size)) / approx_size < p:
- lines.append(line)
- num_picked += 1
- if num_picked == num_needed:
- break
- file_handle.close()
- return lines
+def RemoveDeviceFile(adb_cmd, file_name):
+ shell_cmd_str = adb_cmd + " shell rm " + file_name
+ subprocess.Popen(shell_cmd_str,
+ shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE).communicate()
def main(options, args):
"""Send the url list to device and start testing, restart if crashed."""
- generate_url = False
-
# Set up logging format.
log_level = logging.INFO
if options.verbose:
@@ -84,34 +58,23 @@ def main(options, args):
# Include all tests if none are specified.
if not args:
- path = "/tmp/url_list_%d.txt" % time.time()
- generate_url = True
- logging.info("A URL list is not provided, will be automatically generated.")
+ print "Missing URL list file"
+ sys.exit(1)
else:
path = args[0]
if not options.crash_file:
- print "missing crash file name, use --crash-file to specify"
+ print "Missing crash file name, use --crash-file to specify"
sys.exit(1)
else:
crashed_file = options.crash_file
if not options.timeout_file:
- print "missing timeout file, use --timeout-file to specify"
+ print "Missing timeout file, use --timeout-file to specify"
sys.exit(1)
else:
timedout_file = options.timeout_file
- http = RandomPick(HTTP_URL_FILE, 500000, NUM_URLS)
- https = RandomPick(HTTPS_URL_FILE, 45000, NUM_URLS)
-
- if generate_url:
- file_handle = open(path, "w")
- for i in range(0, NUM_URLS):
- file_handle.write(http[i] + "\n")
- file_handle.write(https[i] + "\n")
- file_handle.close()
-
adb_cmd = "adb "
if options.adb_options:
adb_cmd += options.adb_options + " "
@@ -128,6 +91,10 @@ def main(options, args):
logging.error(adb_error)
sys.exit(1)
+ # clean up previous results
+ RemoveDeviceFile(adb_cmd, TEST_STATUS_FILE)
+ RemoveDeviceFile(adb_cmd, TEST_TIMEOUT_FILE)
+
logging.info("Running the test ...")
# Count crashed tests.
@@ -142,11 +109,10 @@ def main(options, args):
# Call ReliabilityTestsAutoTest#startReliabilityTests
test_cmd = (test_cmd_prefix + " -e class "
- "com.android.dumprendertree.ReliabilityTestsAutoTest#"
- "startReliabilityTests -e timeout " + timeout_ms
- + test_cmd_postfix)
+ "com.android.dumprendertree.ReliabilityTest#"
+ "runTest -e timeout %d %s" %
+ (timeout_ms, test_cmd_postfix))
- time_start = time.time()
adb_output = subprocess.Popen(test_cmd, shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0]
@@ -160,16 +126,12 @@ def main(options, args):
logging.info("Resuming reliability test runner...")
test_cmd = (test_cmd_prefix + " -e class "
- "com.android.dumprendertree.ReliabilityTestsAutoTest#"
- "resumeReliabilityTests -e timeout " + timeout_ms
- + test_cmd_postfix)
+ "com.android.dumprendertree.ReliabilityTest#"
+ "runTest -e timeout %d %s" %
+ (timeout_ms, test_cmd_postfix))
adb_output = subprocess.Popen(test_cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()[0]
- time_end = time.time()
- fp = open("time_stat", "a")
- fp.writelines("%.2f\n" % ((time_end - time_start) / NUM_URLS / 2))
- fp.close()
if (adb_output.find("INSTRUMENTATION_FAILED") != -1 or
adb_output.find("Process crashed.") != -1):
logging.error("Error happened : " + adb_output)