-
Notifications
You must be signed in to change notification settings - Fork 169
/
cmd-kola
executable file
·70 lines (56 loc) · 2.34 KB
/
cmd-kola
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
#!/usr/bin/env python3
import argparse
import re
import subprocess
import os
import platform
import sys
# Just test these boot to start with. In the future we should at least
# do ostree upgrades with uefi etc. But we don't really need the *full*
# suite...if podman somehow broke with nvme or uefi I'd be amazed and impressed.
arch = platform.machine()
cosa_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, cosa_dir)
from cosalib import cmdlib
basearch = cmdlib.get_basearch()
# Parse args and dispatch
parser = argparse.ArgumentParser()
parser.add_argument("--build", help="Build ID")
parser.add_argument("--output-dir", help="Output directory")
parser.add_argument("--upgrades", help="Run upgrade tests", action='store_true')
parser.add_argument("subargs", help="Remaining arguments for kola", nargs='*',
default=[])
args, unknown_args = parser.parse_known_args()
default_output_dir_base = os.environ.get('ARTIFACT_DIR', 'tmp')
if args.upgrades:
default_cmd = 'run-upgrade'
default_output_dir = os.path.join(default_output_dir_base, "kola-upgrade")
else:
default_cmd = 'run'
default_output_dir = os.path.join(default_output_dir_base, "kola")
# XXX: teach to kola to auto-detect based on prefix; see discussions in
# https://github.com/coreos/coreos-assembler/pull/85
kolaargs = ['kola']
r = re.compile("-p(=.+)?|--platform(=.+)?")
platformargs = list(filter(r.match, unknown_args))
if os.getuid() != 0 and len(platformargs) == 0:
kolaargs.extend(['-p', 'qemu'])
if args.build is not None:
kolaargs.extend(['--build', args.build])
outputdir = args.output_dir or default_output_dir
subargs = args.subargs or [default_cmd]
kolaargs.extend(subargs)
kolaargs.extend(unknown_args)
if args.upgrades:
kolaargs.extend(['--output-dir', outputdir])
if '--qemu-image-dir' not in unknown_args:
os.makedirs('tmp/kola-qemu-cache', exist_ok=True)
kolaargs.extend(['--qemu-image-dir', 'tmp/kola-qemu-cache'])
kolaargs.extend(['-v', '--find-parent-image'])
print(subprocess.list2cmdline(kolaargs), flush=True, file=sys.stderr)
os.execvp('kola', kolaargs)
else:
kolaargs.extend(['--output-dir', outputdir])
# flush before exec; see https://docs.python.org/3.7/library/os.html#os.execvpe
print(subprocess.list2cmdline(kolaargs), flush=True, file=sys.stderr)
os.execvp('kola', kolaargs)