summaryrefslogtreecommitdiff
path: root/tests/cloud_tests/run_funcs.py
blob: 8ae911202634bb7c0e69e7eb9b3bc0c774082309 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# This file is part of cloud-init. See LICENSE file for license information.

"""Run functions."""

import os

from tests.cloud_tests import bddeb, collect, util, verify


def tree_collect(args):
    """Collect data using deb build from current tree.

    @param args: cmdline args
    @return_value: fail count
    """
    failed = 0
    tmpdir = util.TempDir(tmpdir=args.data_dir, preserve=args.preserve_data)

    with tmpdir as data_dir:
        args.data_dir = data_dir
        args.deb = os.path.join(tmpdir.tmpdir, 'cloud-init_all.deb')
        try:
            failed += bddeb.bddeb(args)
            failed += collect.collect(args)
        except Exception:
            failed += 1
            raise

    return failed


def tree_run(args):
    """Run test suite using deb build from current tree.

    @param args: cmdline args
    @return_value: fail count
    """
    failed = 0
    tmpdir = util.TempDir(tmpdir=args.data_dir, preserve=args.preserve_data)

    with tmpdir as data_dir:
        args.data_dir = data_dir
        args.deb = os.path.join(tmpdir.tmpdir, 'cloud-init_all.deb')
        try:
            failed += bddeb.bddeb(args)
            failed += collect.collect(args)
            failed += verify.verify(args)
        except Exception:
            failed += 1
            raise

    return failed


def run(args):
    """Run test suite.

    @param args: cmdline args
    @return_value: fail count
    """
    failed = 0
    tmpdir = util.TempDir(tmpdir=args.data_dir, preserve=args.preserve_data)

    with tmpdir as data_dir:
        args.data_dir = data_dir
        try:
            failed += collect.collect(args)
            failed += verify.verify(args)
        except Exception:
            failed += 1
            raise

    return failed

# vi: ts=4 expandtab