~canonical-platform-qa/ubuntu-system-tests/shared-cpo-data

« back to all changes in this revision

Viewing changes to ubuntu_system_tests/host/command_line.py

  • Committer: Richard Huddie
  • Date: 2016-05-19 11:14:25 UTC
  • mfrom: (386.1.2 trunk)
  • Revision ID: richard.huddie@canonical.com-20160519111425-ci0fq25egmph2jty
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
import tempfile
30
30
 
31
31
from argparse import ArgumentParser
32
 
from ubuntu_system_tests import (
 
32
from ubuntu_system_tests.host import (
 
33
    results,
 
34
    testdesc
 
35
)
 
36
from ubuntu_system_tests.common import (
 
37
    clean_dir,
33
38
    config,
34
 
    results,
35
39
    ssh,
36
 
    testdesc
37
40
)
38
 
from ubuntu_system_tests.helpers.file_system import clean_dir
39
 
 
40
41
 
41
42
logger = logging.getLogger(__name__)
42
43
_ADT_RUN_SHORT_TIMEOUT = 600  # 10 minutes.
53
54
EXT_LOG_DIR = '/userdata/apt-cacher-ng/logs'
54
55
PERMISSION = '755'
55
56
 
 
57
# Installation path for shared files
 
58
INSTALLED_SHARE_DIR = '/usr/share/ubuntu-system-tests'
 
59
# Installation path for installed python scripts
 
60
INSTALLED_PYTHON_DIR = '/usr/lib/python'
 
61
 
56
62
 
57
63
def main(argv=None):
58
64
    if argv is None:
382
388
    return content.rstrip()
383
389
 
384
390
 
 
391
def _is_installed():
 
392
    """Return True if the suite is running from installed location."""
 
393
    return os.path.realpath(__file__).startswith(INSTALLED_PYTHON_DIR)
 
394
 
 
395
 
 
396
def _get_debian_path():
 
397
    """Return the path of the debian folder.
 
398
    This will depend on whether tests are running from installed location
 
399
    or local source directory.
 
400
    """
 
401
    return INSTALLED_SHARE_DIR if _is_installed() else os.getcwd()
 
402
 
 
403
 
385
404
def _build_basic_adt_run_test_command(config_stack, extra_depends, verbose):
386
405
    """ Build and return the first part of the adt-run """
387
406
    output_dir = config_stack.get('output_dir')
399
418
        # Regression tests can take up to 8 hours, no reason to cut short.
400
419
        '--timeout-test={}'.format(_ADT_RUN_TEST_TIMEOUT),
401
420
        '-B',
402
 
        '--unbuilt-tree={}'.format(os.getcwd()),
 
421
        '--unbuilt-tree={}'.format(_get_debian_path()),
403
422
        '--output-dir',
404
423
        output_dir,
405
424
        # Even if the config file on the host has a different name, on the
552
571
        'if ! ls /etc/apt/sources.list.d/canonical-platform-qa* > /dev/null '
553
572
        '2>&1; then '
554
573
        'apt-add-repository -y ppa:canonical-platform-qa/selenium; '
 
574
        'apt-add-repository -y ppa:canonical-platform-qa/ubuntu-system-tests; '
555
575
        'apt-get --no-list-cleanup update -o Dir::Etc::SourceList=/dev/null; '
556
576
        'fi',
557
577
        '--setup-commands',
657
677
    when the apt-get install does not install any package, the device is set
658
678
    as ro and exit, otherwise it is rebooted and will start as ro
659
679
    """
660
 
    dir_name = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
 
680
    dir_name = _get_debian_path()
661
681
    if install_tests:
662
682
        dependencies = testdesc.get_all_dependencies(dir_name, 'TMPINSTALL')
663
683
    else: