mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-24 15:11:19 +02:00
Add board option to au test harness so that this works for others without a default board and add ability to reference images without relative paths.
Change-Id: I4afa86fa7a6b772124de56114910a1ca5e3d4511 BUG= TEST=Ran through update harness code and ran loman. Review URL: http://codereview.chromium.org/3612004
This commit is contained in:
parent
2ffe2bed8b
commit
af33f8f8ae
@ -10,7 +10,7 @@ import sys
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../lib'))
|
sys.path.append(os.path.join(os.path.dirname(__file__), '../lib'))
|
||||||
from cros_build_lib import RunCommand, Info, Warning
|
from cros_build_lib import RunCommand, Info, Warning, ReinterpretPathForChroot
|
||||||
|
|
||||||
_KVM_PID_FILE = '/tmp/harness_pid'
|
_KVM_PID_FILE = '/tmp/harness_pid'
|
||||||
_SCRIPTS_DIR = os.path.join(os.path.dirname(__file__), '..')
|
_SCRIPTS_DIR = os.path.join(os.path.dirname(__file__), '..')
|
||||||
@ -18,6 +18,7 @@ _FULL_VDISK_SIZE = 6072
|
|||||||
_FULL_STATEFULFS_SIZE = 2048
|
_FULL_STATEFULFS_SIZE = 2048
|
||||||
|
|
||||||
global base_image_path
|
global base_image_path
|
||||||
|
global board
|
||||||
global target_image_path
|
global target_image_path
|
||||||
|
|
||||||
_VERIFY_SUITE = 'suite_Smoke'
|
_VERIFY_SUITE = 'suite_Smoke'
|
||||||
@ -106,9 +107,11 @@ class VirtualAUTest(unittest.TestCase, AUTest):
|
|||||||
Info('Qemu image not found, creating one.')
|
Info('Qemu image not found, creating one.')
|
||||||
RunCommand(['%s/image_to_vm.sh' % _SCRIPTS_DIR,
|
RunCommand(['%s/image_to_vm.sh' % _SCRIPTS_DIR,
|
||||||
'--full',
|
'--full',
|
||||||
'--from %s' % os.path.dirname(base_image_path),
|
'--from %s' % ReinterpretPathForChroot(
|
||||||
|
os.path.dirname(base_image_path)),
|
||||||
'--vdisk_size %s' % _FULL_VDISK_SIZE,
|
'--vdisk_size %s' % _FULL_VDISK_SIZE,
|
||||||
'--statefulfs_size %s' % _FULL_STATEFULFS_SIZE,
|
'--statefulfs_size %s' % _FULL_STATEFULFS_SIZE,
|
||||||
|
'--board %s' % board,
|
||||||
'--test_image'], enter_chroot=True)
|
'--test_image'], enter_chroot=True)
|
||||||
else:
|
else:
|
||||||
Info('Using existing VM image')
|
Info('Using existing VM image')
|
||||||
@ -153,6 +156,8 @@ if __name__ == '__main__':
|
|||||||
help='path to the base image.')
|
help='path to the base image.')
|
||||||
parser.add_option('-t', '--target_image',
|
parser.add_option('-t', '--target_image',
|
||||||
help='path to the target image')
|
help='path to the target image')
|
||||||
|
parser.add_option('-r', '--board',
|
||||||
|
help='board for the images')
|
||||||
# Set the usage to include flags.
|
# Set the usage to include flags.
|
||||||
parser.set_usage(parser.format_help())
|
parser.set_usage(parser.format_help())
|
||||||
# Parse existing sys.argv so we can pass rest to unittest.main.
|
# Parse existing sys.argv so we can pass rest to unittest.main.
|
||||||
@ -160,6 +165,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
base_image_path = options.base_image
|
base_image_path = options.base_image
|
||||||
target_image_path = options.target_image
|
target_image_path = options.target_image
|
||||||
|
board = options.board
|
||||||
|
|
||||||
if not base_image_path:
|
if not base_image_path:
|
||||||
parser.error('Need path to base image for vm.')
|
parser.error('Need path to base image for vm.')
|
||||||
@ -167,4 +173,7 @@ if __name__ == '__main__':
|
|||||||
if not target_image_path:
|
if not target_image_path:
|
||||||
parser.error('Need path to target image to update with.')
|
parser.error('Need path to target image to update with.')
|
||||||
|
|
||||||
|
if not board:
|
||||||
|
parser.error('Need board to convert base image to vm.')
|
||||||
|
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
14
bin/loman.py
14
bin/loman.py
@ -11,17 +11,7 @@ import optparse
|
|||||||
import os
|
import os
|
||||||
import xml.etree.ElementTree as ElementTree
|
import xml.etree.ElementTree as ElementTree
|
||||||
|
|
||||||
from cros_build_lib import Die
|
from cros_build_lib import Die, FindRepoDir
|
||||||
|
|
||||||
|
|
||||||
def _FindRepoDir():
|
|
||||||
cwd = os.getcwd()
|
|
||||||
while cwd != '/':
|
|
||||||
repo_dir = os.path.join(cwd, '.repo')
|
|
||||||
if os.path.isdir(repo_dir):
|
|
||||||
return repo_dir
|
|
||||||
cwd = os.path.dirname(cwd)
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
def _ReadManifest(manifest, err_not_found=False):
|
def _ReadManifest(manifest, err_not_found=False):
|
||||||
@ -96,7 +86,7 @@ class LocalManifest:
|
|||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
repo_dir = _FindRepoDir()
|
repo_dir = FindRepoDir()
|
||||||
if not repo_dir:
|
if not repo_dir:
|
||||||
Die("Unable to find repo dir.")
|
Die("Unable to find repo dir.")
|
||||||
|
|
||||||
|
@ -21,8 +21,7 @@ eval set -- "${FLAGS_ARGV}"
|
|||||||
|
|
||||||
# Check on the board that they are trying to set up.
|
# Check on the board that they are trying to set up.
|
||||||
if [ -z "$FLAGS_board" ] ; then
|
if [ -z "$FLAGS_board" ] ; then
|
||||||
echo "Error: --board required."
|
die "Error: --board required."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
|
IMAGES_DIR="${DEFAULT_BUILD_ROOT}/images/${FLAGS_board}"
|
||||||
|
@ -136,3 +136,36 @@ def Info(message):
|
|||||||
"""
|
"""
|
||||||
print >> sys.stderr, (
|
print >> sys.stderr, (
|
||||||
Color(_STDOUT_IS_TTY).Color(Color.BLUE, '\nINFO: ' + message))
|
Color(_STDOUT_IS_TTY).Color(Color.BLUE, '\nINFO: ' + message))
|
||||||
|
|
||||||
|
|
||||||
|
def FindRepoDir():
|
||||||
|
"""Returns the nearest higher-level repo dir from the cwd."""
|
||||||
|
cwd = os.getcwd()
|
||||||
|
while cwd != '/':
|
||||||
|
repo_dir = os.path.join(cwd, '.repo')
|
||||||
|
if os.path.isdir(repo_dir):
|
||||||
|
return repo_dir
|
||||||
|
cwd = os.path.dirname(cwd)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def ReinterpretPathForChroot(path):
|
||||||
|
"""Returns reinterpreted path from outside the chroot for use inside.
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
path: The path to reinterpret. Must be in src tree.
|
||||||
|
"""
|
||||||
|
root_path = os.path.join(FindRepoDir(), '..')
|
||||||
|
|
||||||
|
path_abs_path = os.path.abspath(path)
|
||||||
|
root_abs_path = os.path.abspath(root_path)
|
||||||
|
|
||||||
|
# Strip the repository root from the path and strip first /.
|
||||||
|
relative_path = path_abs_path.replace(root_abs_path, '')[1:]
|
||||||
|
|
||||||
|
if relative_path == path_abs_path:
|
||||||
|
raise Exception('Error: path is outside your src tree, cannot reinterpret.')
|
||||||
|
|
||||||
|
new_path = os.path.join('/home', os.getenv('USER'), 'trunk', relative_path)
|
||||||
|
return new_path
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user