Add methods to run vm tests on x86-pre-flight-queue.

Right now we're leaving error_ok=True until the tests are shown to work on builder.

Change-Id: I6b8c690a0da30948389fd4312032c78d87115364

BUG=6906
TEST=Ran through it locally.

Review URL: http://codereview.chromium.org/3591002
This commit is contained in:
Chris Sosa 2010-09-30 14:25:25 -07:00
parent e3049de00f
commit c2db26c796
4 changed files with 60 additions and 5 deletions

View File

@ -208,6 +208,20 @@ def _UprevAllPackages(buildroot):
'--tracking_branch="cros/master"'],
cwd=cwd, enter_chroot=True)
def _GetVMConstants(buildroot):
"""Returns minimum (vdisk_size, statefulfs_size) recommended for VM's."""
cwd = os.path.join(buildroot, 'src', 'scripts', 'lib')
source_cmd = 'source %s/cros_vm_constants.sh' % cwd
vdisk_size = RunCommand([
'/bin/bash', '-c', '%s && echo $MIN_VDISK_SIZE_FULL' % source_cmd],
redirect_stdout=True)
statefulfs_size = RunCommand([
'/bin/bash', '-c', '%s && echo $MIN_STATEFUL_FS_SIZE_FULL' % source_cmd],
redirect_stdout=True)
return (vdisk_size.strip(), statefulfs_size.strip())
# =========================== Main Commands ===================================
def _FullCheckout(buildroot, rw_checkout=True, retries=_DEFAULT_RETRIES):
@ -244,20 +258,43 @@ def _Build(buildroot):
cwd = os.path.join(buildroot, 'src', 'scripts')
RunCommand(['./build_packages'], cwd=cwd, enter_chroot=True)
def _WipeOldOutput(buildroot):
RunCommand(['rm', '-rf', 'src/build/images'], cwd=buildroot)
def _BuildImage(buildroot):
_WipeOldOutput(buildroot)
cwd = os.path.join(buildroot, 'src', 'scripts')
RunCommand(['./build_image', '--replace'], cwd=cwd, enter_chroot=True)
def _BuildVMImageForTesting(buildroot):
(vdisk_size, statefulfs_size) = _GetVMConstants(buildroot)
cwd = os.path.join(buildroot, 'src', 'scripts')
RunCommand(['./image_to_vm.sh',
'--test_image',
'--full',
'--vdisk_size %s' % vdisk_size,
'--statefulfs_size %s' % statefulfs_size,
], cwd=cwd, enter_chroot=True)
def _RunUnitTests(buildroot):
cwd = os.path.join(buildroot, 'src', 'scripts')
RunCommand(['./cros_run_unit_tests'], cwd=cwd, enter_chroot=True)
def _RunSmokeSuite(buildroot):
cwd = os.path.join(buildroot, 'src', 'scripts')
RunCommand(['bin/cros_run_vm_test',
'--no_graphics',
'--test_case',
'suite_Smoke',
], cwd=cwd, error_ok=True)
def _UprevPackages(buildroot, revisionfile, board):
"""Uprevs a package based on given revisionfile.
@ -383,6 +420,11 @@ def main():
_RunUnitTests(buildroot)
_BuildImage(buildroot)
if buildconfig['smoke_bvt']:
_BuildVMImageForTesting(buildroot)
_RunSmokeSuite(buildroot)
if buildconfig['uprev']:
if buildconfig['master']:
# Master bot needs to check if the other slaves completed.

View File

@ -18,6 +18,7 @@ important -- Master bot uses important bots to determine overall status.
hostname -- Needed for 'important' slaves. The hostname of the bot. Should
match hostname in slaves.cfg in buildbot checkout.
unittests -- Runs unittests for packages.
smoke_bvt -- Runs the test smoke suite in a qemu-based VM using KVM.
"""
@ -29,6 +30,7 @@ config['default'] = {
'master' : False,
'important' : False,
'unittests' : False,
'smoke_bvt' : False,
}
config['x86-generic-pre-flight-queue'] = {
'board' : 'x86-generic',
@ -37,6 +39,7 @@ config['x86-generic-pre-flight-queue'] = {
'important' : False,
'hostname' : 'chromeosbuild2',
'unittests' : True,
'smoke_bvt' : True,
}
config['x86_pineview_bin'] = {
'board' : 'x86-pineview',
@ -45,6 +48,7 @@ config['x86_pineview_bin'] = {
'important' : False,
'hostname' : 'codf200.jail',
'unittests': True,
'smoke_bvt' : True,
}
config['arm_tegra2_bin'] = {
'board' : 'tegra2',

View File

@ -4,11 +4,21 @@
"""Common python commands used by various build scripts."""
import inspect
import os
import subprocess
import sys
_STDOUT_IS_TTY = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
# TODO(sosa): Move logging to logging module.
def GetCallerName():
"""Returns the name of the calling module with __main__."""
top_frame = inspect.stack()[-1][0]
return os.path.basename(top_frame.f_code.co_filename)
def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
exit_code=False, redirect_stdout=False, redirect_stderr=False,
cwd=None, input=None, enter_chroot=False):
@ -44,7 +54,8 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
# Print out the command before running.
if print_cmd:
Info('RunCommand: %s' % ' '.join(cmd))
Info('PROGRAM(%s) -> RunCommand: %s in dir %s' %
(GetCallerName(), ' '.join(cmd), cwd))
try:
proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
@ -56,7 +67,7 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
if not error_ok and proc.returncode:
raise Exception('Command "%s" failed.\n' % (' '.join(cmd)) +
(error_message or error or output or ''))
except Exception,e:
except Exception, e:
if not error_ok:
raise
else:

View File

@ -4,8 +4,6 @@
#
# Common vm functions for use in crosutils.
. "$(dirname "$0")/cros_vm_constants.sh"
DEFINE_string kvm_pid "" \
"Use this pid file. If it exists and is set, use the vm specified by pid."
DEFINE_boolean no_graphics ${FLAGS_FALSE} "Runs the KVM instance silently."
@ -48,7 +46,7 @@ function start_kvm() {
snapshot="-snapshot"
fi
sudo kvm -m ${DEFAULT_MEM} \
sudo kvm -m 1024 \
-vga std \
-pidfile "${KVM_PID_FILE}" \
-daemonize \