Files
OpenCellular/test/timer_calib.py
Vincent Palatin c4ac74a11d fix QEMU OS tests
- update strings which were modified by the message text "compression"
- updated QEMU which supports a couple of additional registers for LM4F
(getting internal oscillator calibration status and writing timer
counter through TAV)

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=chrome-os-partner:10008
TEST=make qemu-tests

Change-Id: Idf0ee13f354b4e14405e949861d426f3e4c3022b
Reviewed-on: https://gerrit.chromium.org/gerrit/24827
Reviewed-by: Vic Yang <victoryang@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-06-07 20:01:49 -07:00

55 lines
1.8 KiB
Python

# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Check timers behavior
#
import time
def one_pass(helper):
helper.wait_output("=== Timer calibration ===")
res = helper.wait_output("back-to-back get_time : (?P<lat>[0-9]+) us",
use_re=True)["lat"]
minlat = int(res)
helper.trace("get_time latency %d us\n" % minlat)
helper.wait_output("sleep 1s")
t0 = time.time()
second = helper.wait_output("done. delay = (?P<second>[0-9]+) us",
use_re=True)["second"]
t1 = time.time()
secondreal = t1 - t0
secondlat = int(second) - 1000000
helper.trace("1s timer latency %d us / real time %f s\n" % (secondlat,
secondreal))
us = {}
for pow2 in range(7):
delay = 1 << (7-pow2)
us[delay] = helper.wait_output("%d us => (?P<us>[0-9]+) us" % delay,
use_re=True)["us"]
helper.wait_output("Done.")
return minlat, secondlat, secondreal
def test(helper):
one_pass(helper)
helper.ec_command("reboot")
helper.wait_output("--- UART initialized")
# get the timing results on the second pass
# to avoid binary translation overhead
minlat, secondlat, secondreal = one_pass(helper)
# check that the timings somewhat make sense
if minlat > 220 or secondlat > 500 or abs(secondreal-1.0) > 0.200:
helper.fail("imprecise timings " +
"(get_time %d us sleep %d us / real time %.3f s)" %
(minlat, secondlat, secondreal))
return True # PASS !