blob: 9313e5ed0f73d44caf577fdc61eb28419545be34 [file] [log] [blame]
Matthew Barthccb7f852016-11-23 17:43:02 -06001#!/usr/bin/env python
2
3"""
4This script determines the given package's openbmc dependencies from its
5configure.ac file where it downloads, configures, builds, and installs each of
6these dependencies. Then the given package is configured, built, and installed
7prior to executing its unit tests.
8"""
9
Matthew Barthd1810372016-12-19 16:57:21 -060010from git import Repo
Matthew Barthccb7f852016-11-23 17:43:02 -060011from urlparse import urljoin
Andrew Jefferya4e31c62018-03-08 13:45:28 +103012from subprocess import check_call, call, CalledProcessError
Matthew Barthccb7f852016-11-23 17:43:02 -060013import os
14import sys
Matthew Barth33df8792016-12-19 14:30:17 -060015import argparse
William A. Kennington IIIa2156732018-06-30 18:38:09 -070016import multiprocessing
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -050017import re
William A. Kennington III4e1d0a12018-07-16 12:04:03 -070018import platform
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -050019
20
21class DepTree():
22 """
23 Represents package dependency tree, where each node is a DepTree with a
24 name and DepTree children.
25 """
26
27 def __init__(self, name):
28 """
29 Create new DepTree.
30
31 Parameter descriptions:
32 name Name of new tree node.
33 """
34 self.name = name
35 self.children = list()
36
37 def AddChild(self, name):
38 """
39 Add new child node to current node.
40
41 Parameter descriptions:
42 name Name of new child
43 """
44 new_child = DepTree(name)
45 self.children.append(new_child)
46 return new_child
47
48 def AddChildNode(self, node):
49 """
50 Add existing child node to current node.
51
52 Parameter descriptions:
53 node Tree node to add
54 """
55 self.children.append(node)
56
57 def RemoveChild(self, name):
58 """
59 Remove child node.
60
61 Parameter descriptions:
62 name Name of child to remove
63 """
64 for child in self.children:
65 if child.name == name:
66 self.children.remove(child)
67 return
68
69 def GetNode(self, name):
70 """
71 Return node with matching name. Return None if not found.
72
73 Parameter descriptions:
74 name Name of node to return
75 """
76 if self.name == name:
77 return self
78 for child in self.children:
79 node = child.GetNode(name)
80 if node:
81 return node
82 return None
83
84 def GetParentNode(self, name, parent_node=None):
85 """
86 Return parent of node with matching name. Return none if not found.
87
88 Parameter descriptions:
89 name Name of node to get parent of
90 parent_node Parent of current node
91 """
92 if self.name == name:
93 return parent_node
94 for child in self.children:
95 found_node = child.GetParentNode(name, self)
96 if found_node:
97 return found_node
98 return None
99
100 def GetPath(self, name, path=None):
101 """
102 Return list of node names from head to matching name.
103 Return None if not found.
104
105 Parameter descriptions:
106 name Name of node
107 path List of node names from head to current node
108 """
109 if not path:
110 path = []
111 if self.name == name:
112 path.append(self.name)
113 return path
114 for child in self.children:
115 match = child.GetPath(name, path + [self.name])
116 if match:
117 return match
118 return None
119
120 def GetPathRegex(self, name, regex_str, path=None):
121 """
122 Return list of node paths that end in name, or match regex_str.
123 Return empty list if not found.
124
125 Parameter descriptions:
126 name Name of node to search for
127 regex_str Regex string to match node names
128 path Path of node names from head to current node
129 """
130 new_paths = []
131 if not path:
132 path = []
133 match = re.match(regex_str, self.name)
134 if (self.name == name) or (match):
135 new_paths.append(path + [self.name])
136 for child in self.children:
137 return_paths = None
138 full_path = path + [self.name]
139 return_paths = child.GetPathRegex(name, regex_str, full_path)
140 for i in return_paths:
141 new_paths.append(i)
142 return new_paths
143
144 def MoveNode(self, from_name, to_name):
145 """
146 Mode existing from_name node to become child of to_name node.
147
148 Parameter descriptions:
149 from_name Name of node to make a child of to_name
150 to_name Name of node to make parent of from_name
151 """
152 parent_from_node = self.GetParentNode(from_name)
153 from_node = self.GetNode(from_name)
154 parent_from_node.RemoveChild(from_name)
155 to_node = self.GetNode(to_name)
156 to_node.AddChildNode(from_node)
157
158 def ReorderDeps(self, name, regex_str):
159 """
160 Reorder dependency tree. If tree contains nodes with names that
161 match 'name' and 'regex_str', move 'regex_str' nodes that are
162 to the right of 'name' node, so that they become children of the
163 'name' node.
164
165 Parameter descriptions:
166 name Name of node to look for
167 regex_str Regex string to match names to
168 """
169 name_path = self.GetPath(name)
170 if not name_path:
171 return
172 paths = self.GetPathRegex(name, regex_str)
173 is_name_in_paths = False
174 name_index = 0
175 for i in range(len(paths)):
176 path = paths[i]
177 if path[-1] == name:
178 is_name_in_paths = True
179 name_index = i
180 break
181 if not is_name_in_paths:
182 return
183 for i in range(name_index + 1, len(paths)):
184 path = paths[i]
185 if name in path:
186 continue
187 from_name = path[-1]
188 self.MoveNode(from_name, name)
189
190 def GetInstallList(self):
191 """
192 Return post-order list of node names.
193
194 Parameter descriptions:
195 """
196 install_list = []
197 for child in self.children:
198 child_install_list = child.GetInstallList()
199 install_list.extend(child_install_list)
200 install_list.append(self.name)
201 return install_list
202
203 def PrintTree(self, level=0):
204 """
205 Print pre-order node names with indentation denoting node depth level.
206
207 Parameter descriptions:
208 level Current depth level
209 """
210 INDENT_PER_LEVEL = 4
211 print ' ' * (level * INDENT_PER_LEVEL) + self.name
212 for child in self.children:
213 child.PrintTree(level + 1)
Matthew Barth33df8792016-12-19 14:30:17 -0600214
215
216def check_call_cmd(dir, *cmd):
217 """
218 Verbose prints the directory location the given command is called from and
219 the command, then executes the command using check_call.
220
221 Parameter descriptions:
222 dir Directory location command is to be called from
223 cmd List of parameters constructing the complete command
224 """
225 printline(dir, ">", " ".join(cmd))
226 check_call(cmd)
Matthew Barthccb7f852016-11-23 17:43:02 -0600227
228
229def clone_pkg(pkg):
Matthew Barth33df8792016-12-19 14:30:17 -0600230 """
231 Clone the given openbmc package's git repository from gerrit into
232 the WORKSPACE location
233
234 Parameter descriptions:
235 pkg Name of the package to clone
236 """
Andrew Jeffery7be94ca2018-03-08 13:15:33 +1030237 pkg_dir = os.path.join(WORKSPACE, pkg)
238 if os.path.exists(os.path.join(pkg_dir, '.git')):
239 return pkg_dir
Matthew Barthccb7f852016-11-23 17:43:02 -0600240 pkg_repo = urljoin('https://gerrit.openbmc-project.xyz/openbmc/', pkg)
Andrew Jeffery7be94ca2018-03-08 13:15:33 +1030241 os.mkdir(pkg_dir)
242 printline(pkg_dir, "> git clone", pkg_repo, "./")
243 return Repo.clone_from(pkg_repo, pkg_dir).working_dir
Matthew Barth33df8792016-12-19 14:30:17 -0600244
245
246def get_deps(configure_ac):
247 """
248 Parse the given 'configure.ac' file for package dependencies and return
249 a list of the dependencies found.
250
251 Parameter descriptions:
252 configure_ac Opened 'configure.ac' file object
253 """
254 line = ""
Brad Bishopebb49112017-02-13 11:07:26 -0500255 dep_pkgs = set()
Matthew Barth33df8792016-12-19 14:30:17 -0600256 for cfg_line in configure_ac:
257 # Remove whitespace & newline
258 cfg_line = cfg_line.rstrip()
259 # Check for line breaks
260 if cfg_line.endswith('\\'):
261 line += str(cfg_line[:-1])
262 continue
263 line = line+cfg_line
264
265 # Find any defined dependency
Brad Bishopebb49112017-02-13 11:07:26 -0500266 line_has = lambda x: x if x in line else None
267 macros = set(filter(line_has, DEPENDENCIES.iterkeys()))
268 if len(macros) == 1:
269 macro = ''.join(macros)
270 deps = filter(line_has, DEPENDENCIES[macro].iterkeys())
271 dep_pkgs.update(map(lambda x: DEPENDENCIES[macro][x], deps))
272
Matthew Barth33df8792016-12-19 14:30:17 -0600273 line = ""
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500274 deps = list(dep_pkgs)
Matthew Barth33df8792016-12-19 14:30:17 -0600275
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500276 return deps
Matthew Barthccb7f852016-11-23 17:43:02 -0600277
278
William A. Kennington IIIa2156732018-06-30 18:38:09 -0700279make_parallel = [
280 'make',
281 # Run enough jobs to saturate all the cpus
282 '-j', str(multiprocessing.cpu_count()),
283 # Don't start more jobs if the load avg is too high
284 '-l', str(multiprocessing.cpu_count()),
285 # Synchronize the output so logs aren't intermixed in stdout / stderr
286 '-O',
287]
288
William A. Kennington III780ec092018-12-06 14:46:50 -0800289def build_and_install(pkg):
290 """
291 Builds and installs the package in the environment. Optionally
292 builds the examples and test cases for package.
293
294 Parameter description:
295 pkg The package we are building
296 """
297 pkgdir = os.path.join(WORKSPACE, pkg)
298 # Build & install this package
299 conf_flags = [
300 '--disable-silent-rules',
301 '--enable-tests',
302 '--enable-code-coverage',
303 '--enable-valgrind'
304 ]
305 os.chdir(pkgdir)
306 # Add any necessary configure flags for package
307 if CONFIGURE_FLAGS.get(pkg) is not None:
308 conf_flags.extend(CONFIGURE_FLAGS.get(pkg))
William A. Kennington IIIe91b7742018-12-04 22:48:15 -0800309 for bootstrap in ['bootstrap.sh', 'bootstrap', 'autogen.sh']:
310 if os.path.exists(bootstrap):
311 check_call_cmd(pkgdir, './' + bootstrap)
312 break
William A. Kennington III780ec092018-12-06 14:46:50 -0800313 check_call_cmd(pkgdir, './configure', *conf_flags)
314 check_call_cmd(pkgdir, *make_parallel)
William A. Kennington IIIbe6aab22018-12-06 15:01:54 -0800315 check_call_cmd(pkgdir, 'sudo', '-n', '--', *(make_parallel + [ 'install' ]))
William A. Kennington III780ec092018-12-06 14:46:50 -0800316
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500317def install_deps(dep_list):
Matthew Barthccb7f852016-11-23 17:43:02 -0600318 """
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500319 Install each package in the ordered dep_list.
Matthew Barthccb7f852016-11-23 17:43:02 -0600320
321 Parameter descriptions:
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500322 dep_list Ordered list of dependencies
Matthew Barthccb7f852016-11-23 17:43:02 -0600323 """
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500324 for pkg in dep_list:
William A. Kennington III780ec092018-12-06 14:46:50 -0800325 build_and_install(pkg)
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500326
327def build_dep_tree(pkg, pkgdir, dep_added, head, dep_tree=None):
328 """
329 For each package(pkg), starting with the package to be unit tested,
330 parse its 'configure.ac' file from within the package's directory(pkgdir)
331 for each package dependency defined recursively doing the same thing
332 on each package found as a dependency.
333
334 Parameter descriptions:
335 pkg Name of the package
336 pkgdir Directory where package source is located
337 dep_added Current list of dependencies and added status
338 head Head node of the dependency tree
339 dep_tree Current dependency tree node
340 """
341 if not dep_tree:
342 dep_tree = head
343 os.chdir(pkgdir)
344 # Open package's configure.ac
William A. Kennington IIIbe6aab22018-12-06 15:01:54 -0800345 with open("/tmp/depcache", "r") as depcache:
Andrew Jeffery2cb0c7a2018-03-08 13:19:08 +1030346 cached = depcache.readline()
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500347 with open("configure.ac", "rt") as configure_ac:
348 # Retrieve dependency list from package's configure.ac
349 configure_ac_deps = get_deps(configure_ac)
350 for dep_pkg in configure_ac_deps:
Andrew Jeffery2cb0c7a2018-03-08 13:19:08 +1030351 if dep_pkg in cached:
352 continue
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500353 # Dependency package not already known
354 if dep_added.get(dep_pkg) is None:
355 # Dependency package not added
356 new_child = dep_tree.AddChild(dep_pkg)
357 dep_added[dep_pkg] = False
Andrew Jeffery7be94ca2018-03-08 13:15:33 +1030358 dep_pkgdir = clone_pkg(dep_pkg)
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500359 # Determine this dependency package's
360 # dependencies and add them before
361 # returning to add this package
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500362 dep_added = build_dep_tree(dep_pkg,
Andrew Jeffery7be94ca2018-03-08 13:15:33 +1030363 dep_pkgdir,
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500364 dep_added,
365 head,
366 new_child)
367 else:
368 # Dependency package known and added
369 if dep_added[dep_pkg]:
370 continue
371 else:
372 # Cyclic dependency failure
373 raise Exception("Cyclic dependencies found in "+pkg)
374
375 if not dep_added[pkg]:
376 dep_added[pkg] = True
377
378 return dep_added
Matthew Barthccb7f852016-11-23 17:43:02 -0600379
William A. Kennington III0f0a6802018-07-16 11:52:33 -0700380def make_target_exists(target):
381 """
382 Runs a check against the makefile in the current directory to determine
383 if the target exists so that it can be built.
384
385 Parameter descriptions:
386 target The make target we are checking
387 """
388 try:
389 cmd = [ 'make', '-n', target ]
390 with open(os.devnull, 'w') as devnull:
391 check_call(cmd, stdout=devnull, stderr=devnull)
392 return True
393 except CalledProcessError:
394 return False
395
396def run_unit_tests(top_dir):
397 """
398 Runs the unit tests for the package via `make check`
399
400 Parameter descriptions:
401 top_dir The root directory of our project
402 """
403 try:
404 cmd = make_parallel + [ 'check' ]
405 for i in range(0, args.repeat):
406 check_call_cmd(top_dir, *cmd)
407 except CalledProcessError:
408 for root, _, files in os.walk(top_dir):
409 if 'test-suite.log' not in files:
410 continue
411 check_call_cmd(root, 'cat', os.path.join(root, 'test-suite.log'))
412 raise Exception('Unit tests failed')
413
Patrick Venturead4354e2018-10-12 16:59:54 -0700414def run_cppcheck(top_dir):
415 try:
416 # http://cppcheck.sourceforge.net/manual.pdf
417 ignore_list = ['-i%s' % path for path in os.listdir(top_dir) \
418 if path.endswith('-src') or path.endswith('-build')]
419 ignore_list.extend(('-itest', '-iscripts'))
420 params = ['cppcheck', '-j', str(multiprocessing.cpu_count()),
421 '--enable=all']
422 params.extend(ignore_list)
423 params.append('.')
424
425 check_call_cmd(top_dir, *params)
426 except CalledProcessError:
427 raise Exception('Cppcheck failed')
William A. Kennington III0f0a6802018-07-16 11:52:33 -0700428
429def maybe_run_valgrind(top_dir):
430 """
431 Potentially runs the unit tests through valgrind for the package
432 via `make check-valgrind`. If the package does not have valgrind testing
433 then it just skips over this.
434
435 Parameter descriptions:
436 top_dir The root directory of our project
437 """
William A. Kennington III4e1d0a12018-07-16 12:04:03 -0700438 # Valgrind testing is currently broken by an aggressive strcmp optimization
439 # that is inlined into optimized code for POWER by gcc 7+. Until we find
440 # a workaround, just don't run valgrind tests on POWER.
441 # https://github.com/openbmc/openbmc/issues/3315
442 if re.match('ppc64', platform.machine()) is not None:
443 return
William A. Kennington III0f0a6802018-07-16 11:52:33 -0700444 if not make_target_exists('check-valgrind'):
445 return
446
447 try:
448 cmd = make_parallel + [ 'check-valgrind' ]
449 check_call_cmd(top_dir, *cmd)
450 except CalledProcessError:
451 for root, _, files in os.walk(top_dir):
452 for f in files:
453 if re.search('test-suite-[a-z]+.log', f) is None:
454 continue
455 check_call_cmd(root, 'cat', os.path.join(root, f))
456 raise Exception('Valgrind tests failed')
457
458def maybe_run_coverage(top_dir):
459 """
460 Potentially runs the unit tests through code coverage for the package
461 via `make check-code-coverage`. If the package does not have code coverage
462 testing then it just skips over this.
463
464 Parameter descriptions:
465 top_dir The root directory of our project
466 """
467 if not make_target_exists('check-code-coverage'):
468 return
469
470 # Actually run code coverage
471 try:
472 cmd = make_parallel + [ 'check-code-coverage' ]
473 check_call_cmd(top_dir, *cmd)
474 except CalledProcessError:
475 raise Exception('Code coverage failed')
Matthew Barthccb7f852016-11-23 17:43:02 -0600476
477if __name__ == '__main__':
478 # CONFIGURE_FLAGS = [GIT REPO]:[CONFIGURE FLAGS]
479 CONFIGURE_FLAGS = {
Adriana Kobylak43c31e82017-02-13 09:28:35 -0600480 'phosphor-objmgr': ['--enable-unpatched-systemd'],
Matthew Barth1d1c6732017-03-24 10:00:28 -0500481 'sdbusplus': ['--enable-transaction'],
482 'phosphor-logging':
483 ['--enable-metadata-processing',
Deepak Kodihalli3a4e1b42017-06-08 09:52:35 -0500484 'YAML_DIR=/usr/local/share/phosphor-dbus-yaml/yaml']
Matthew Barthccb7f852016-11-23 17:43:02 -0600485 }
486
487 # DEPENDENCIES = [MACRO]:[library/header]:[GIT REPO]
488 DEPENDENCIES = {
489 'AC_CHECK_LIB': {'mapper': 'phosphor-objmgr'},
Matthew Barth710f3f02017-01-18 15:20:19 -0600490 'AC_CHECK_HEADER': {
491 'host-ipmid': 'phosphor-host-ipmid',
Patrick Ventureb41a4462018-10-03 17:27:38 -0700492 'blobs-ipmid': 'phosphor-ipmi-blobs',
Matthew Barth710f3f02017-01-18 15:20:19 -0600493 'sdbusplus': 'sdbusplus',
William A. Kennington IIIb4f730a2018-09-12 11:21:20 -0700494 'sdeventplus': 'sdeventplus',
Patrick Venture22329962018-09-14 10:23:04 -0700495 'gpioplus': 'gpioplus',
Saqib Khan66145052017-02-14 12:02:07 -0600496 'phosphor-logging/log.hpp': 'phosphor-logging',
Patrick Williamseab8a372017-01-30 11:21:32 -0600497 },
Brad Bishopebb49112017-02-13 11:07:26 -0500498 'AC_PATH_PROG': {'sdbus++': 'sdbusplus'},
Patrick Williamseab8a372017-01-30 11:21:32 -0600499 'PKG_CHECK_MODULES': {
Matthew Barth19e261e2017-02-01 12:55:22 -0600500 'phosphor-dbus-interfaces': 'phosphor-dbus-interfaces',
Patrick Williamsf128b402017-03-29 06:45:59 -0500501 'openpower-dbus-interfaces': 'openpower-dbus-interfaces',
Matt Spinler7be19032018-04-13 09:43:14 -0500502 'ibm-dbus-interfaces': 'ibm-dbus-interfaces',
Brad Bishopebb49112017-02-13 11:07:26 -0500503 'sdbusplus': 'sdbusplus',
William A. Kennington IIIb4f730a2018-09-12 11:21:20 -0700504 'sdeventplus': 'sdeventplus',
Patrick Venture22329962018-09-14 10:23:04 -0700505 'gpioplus': 'gpioplus',
Brad Bishopebb49112017-02-13 11:07:26 -0500506 'phosphor-logging': 'phosphor-logging',
Marri Devender Raoa3eee8a2018-08-13 05:34:27 -0500507 'phosphor-snmp': 'phosphor-snmp',
Brad Bishopebb49112017-02-13 11:07:26 -0500508 },
Matthew Barthccb7f852016-11-23 17:43:02 -0600509 }
510
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500511 # DEPENDENCIES_REGEX = [GIT REPO]:[REGEX STRING]
512 DEPENDENCIES_REGEX = {
Patrick Ventured37b8052018-10-16 16:03:03 -0700513 'phosphor-logging': r'\S+-dbus-interfaces$'
Leonel Gonzaleza62a1a12017-03-24 11:03:47 -0500514 }
515
Matthew Barth33df8792016-12-19 14:30:17 -0600516 # Set command line arguments
517 parser = argparse.ArgumentParser()
518 parser.add_argument("-w", "--workspace", dest="WORKSPACE", required=True,
519 help="Workspace directory location(i.e. /home)")
520 parser.add_argument("-p", "--package", dest="PACKAGE", required=True,
521 help="OpenBMC package to be unit tested")
522 parser.add_argument("-v", "--verbose", action="store_true",
523 help="Print additional package status messages")
Andrew Jeffery468309d2018-03-08 13:46:33 +1030524 parser.add_argument("-r", "--repeat", help="Repeat tests N times",
525 type=int, default=1)
Matthew Barth33df8792016-12-19 14:30:17 -0600526 args = parser.parse_args(sys.argv[1:])
527 WORKSPACE = args.WORKSPACE
528 UNIT_TEST_PKG = args.PACKAGE
529 if args.verbose:
530 def printline(*line):
531 for arg in line:
532 print arg,
533 print
534 else:
535 printline = lambda *l: None
Matthew Barthccb7f852016-11-23 17:43:02 -0600536
James Feist878df5c2018-07-26 14:54:28 -0700537 # First validate code formatting if repo has style formatting files.
Adriana Kobylakbcee22b2018-01-10 16:58:27 -0600538 # The format-code.sh checks for these files.
Andrew Geisslera28286d2018-01-10 11:00:00 -0800539 CODE_SCAN_DIR = WORKSPACE + "/" + UNIT_TEST_PKG
Adriana Kobylakbcee22b2018-01-10 16:58:27 -0600540 check_call_cmd(WORKSPACE, "./format-code.sh", CODE_SCAN_DIR)
Andrew Geisslera28286d2018-01-10 11:00:00 -0800541
James Feist878df5c2018-07-26 14:54:28 -0700542 # Automake
543 if os.path.isfile(CODE_SCAN_DIR + "/configure.ac"):
544 prev_umask = os.umask(000)
545 # Determine dependencies and add them
546 dep_added = dict()
547 dep_added[UNIT_TEST_PKG] = False
548 # Create dependency tree
549 dep_tree = DepTree(UNIT_TEST_PKG)
550 build_dep_tree(UNIT_TEST_PKG,
551 os.path.join(WORKSPACE, UNIT_TEST_PKG),
552 dep_added,
553 dep_tree)
554
555 # Reorder Dependency Tree
556 for pkg_name, regex_str in DEPENDENCIES_REGEX.iteritems():
557 dep_tree.ReorderDeps(pkg_name, regex_str)
558 if args.verbose:
559 dep_tree.PrintTree()
560 install_list = dep_tree.GetInstallList()
561 # install reordered dependencies
562 install_deps(install_list)
563 top_dir = os.path.join(WORKSPACE, UNIT_TEST_PKG)
564 os.chdir(top_dir)
565 # Refresh dynamic linker run time bindings for dependencies
William A. Kennington IIIbe6aab22018-12-06 15:01:54 -0800566 check_call_cmd(top_dir, 'sudo', '-n', '--', 'ldconfig')
James Feist878df5c2018-07-26 14:54:28 -0700567 # Run package unit tests
568 run_unit_tests(top_dir)
569 maybe_run_valgrind(top_dir)
570 maybe_run_coverage(top_dir)
Patrick Venturead4354e2018-10-12 16:59:54 -0700571 run_cppcheck(top_dir)
James Feist878df5c2018-07-26 14:54:28 -0700572
573 os.umask(prev_umask)
574
575 # Cmake
576 elif os.path.isfile(CODE_SCAN_DIR + "/CMakeLists.txt"):
577 top_dir = os.path.join(WORKSPACE, UNIT_TEST_PKG)
578 os.chdir(top_dir)
579 check_call_cmd(top_dir, 'cmake', '.')
580 check_call_cmd(top_dir, 'cmake', '--build', '.', '--', '-j',
581 str(multiprocessing.cpu_count()))
582 if make_target_exists('test'):
583 check_call_cmd(top_dir, 'ctest', '.')
584 maybe_run_valgrind(top_dir)
585 maybe_run_coverage(top_dir)
Patrick Venturead4354e2018-10-12 16:59:54 -0700586 run_cppcheck(top_dir)
James Feist878df5c2018-07-26 14:54:28 -0700587
588 else:
Andrew Geissler71a7cc12018-01-31 14:18:37 -0800589 print "Not a supported repo for CI Tests, exit"
590 quit()