Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions test/buildbot/builders/testsuite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# RUN: python %s

# Lit Regression Tests for TestSuiteBuilder.getTestSuiteBuildFactory factory.

import sys

from buildbot.plugins import steps, util
import buildbot.process.properties

import zorg
from zorg.buildbot.builders import TestSuiteBuilder
from zorg.buildbot.process.factory import LLVMBuildFactory

from zorg.buildbot.tests import factory_has_num_steps, factory_has_step, DEFAULT_ENV

f = TestSuiteBuilder.getLlvmTestSuiteSteps(
cmake_definitions = {
"CMAKE_C_COMPILER" : "/home/buildbot/worker/temp/build/bin/clang",
"CMAKE_CXX_COMPILER" : "/home/buildbot/worker/temp/build/bin/clang++",
"TEST_SUITE_LIT:FILEPATH" : "/home/buildbot/worker/temp/build/bin/llvm-lit",
},
hint = None,
)

print(f"default factory: {f}\n")

assert factory_has_num_steps(f, 5)
assert factory_has_step(f, "clean-src-dir")
assert factory_has_step(f, "cmake-configure")
assert factory_has_step(f, "build-default")
assert not factory_has_step(f, "rsync-default")
assert factory_has_step(f, "test-check")

f = TestSuiteBuilder.getLlvmTestSuiteSteps(
cmake_definitions = {
"TEST_SUITE_REMOTE_HOST" : "buildbot@arm64-linux-02",
"TEST_SUITE_LIT_FLAGS" : "-v --threads=32 --time-tests",
},
compiler_dir = util.Interpolate("%(prop:builddir)s/build"),
hint = None,
)

print(f"default factory (compiler_dir): {f}\n")

assert factory_has_num_steps(f, 6)
assert factory_has_step(f, "clean-src-dir")
assert factory_has_step(f, "cmake-configure")
assert factory_has_step(f, "build-default")
assert factory_has_step(f, "rsync-default")
assert factory_has_step(f, "test-check")
65 changes: 1 addition & 64 deletions test/buildbot/builders/unified_cmakeex.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,12 @@
import sys

from buildbot.plugins import steps
import buildbot.process.properties

import zorg
from zorg.buildbot.builders import UnifiedTreeBuilder
from zorg.buildbot.process.factory import LLVMBuildFactory

#Note:
# - this function currently supports only %(kw:*)s formatting for the Interpolates.
# - this function does not support the substitutions for arguments (such as '%(kw:arg:-)s' & etc).
# - this function does not support the other types of the renderables except Interpolate
# (such as WithProperties and os on).
def partly_rendered(r):
if isinstance(r, buildbot.process.properties.Interpolate):
interpolations = {}
for k, v in r.kwargs.items():
interpolations[f"kw:{k}"] = v if v else ""
return r.fmtstring % interpolations
elif type(r) == str:
return r

return "unsupported_rendering"

def factory_has_num_steps(f, expected_num):
assert f
if len(f.steps) != expected_num:
print(f"error: factory_has_num_steps: {len(f.steps)}, expected {expected_num}")
return len(f.steps) == expected_num

def factory_has_step(f, name, hasarg=None, contains=None):
assert f
assert name

result = False

for s in f.steps:
v = partly_rendered(s.kwargs.get("name"))
if v == name:
result = True
# check that the step has that argument
arg_value = None
if hasarg:
if not hasarg in s.kwargs:
print(f"error: step '{v}': missing expected step argument '{hasarg}'")
return False

arg_value = s.kwargs.get(hasarg)

# Check for contained content if requested.
if arg_value and contains:
if type(contains) == type(arg_value) == dict:
result = contains.items() <= arg_value.items()
elif type(contains) == type(arg_value) == list:
result = contains <= arg_value
elif type(contains) == type(arg_value):
result = contains == arg_value
else:
print(f"error: step '{v}', argument '{hasarg}': unsupported type to compare, expected is '{type(contains)}', actual is '{type(arg_value)}'")
return False

if not result:
print(f"error: step '{v}', argument '{hasarg}': expected\n\t{contains}\nactual:\n\t{arg_value}")

return result

print(f"error: missing expected step '{name}'")

return False

DEFAULT_ENV = {'TERM': 'dumb', 'NINJA_STATUS': '%e [%u/%r/%f] '}
from zorg.buildbot.tests import factory_has_num_steps, factory_has_step, DEFAULT_ENV

# Use all defaults.
f = UnifiedTreeBuilder.getCmakeExBuildFactory()
Expand Down
70 changes: 70 additions & 0 deletions zorg/buildbot/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# -*- python -*-
# ex: set filetype=python:

import buildbot.process.properties

__all__ = []

DEFAULT_ENV = {'TERM': 'dumb', 'NINJA_STATUS': '%e [%u/%r/%f] '}

#Note:
# - this function currently supports only %(kw:*)s formatting for the Interpolates.
# - this function does not support the substitutions for arguments (such as '%(kw:arg:-)s' & etc).
# - this function does not support the other types of the renderables except Interpolate
# (such as WithProperties and os on).
def partly_rendered(r):
if isinstance(r, buildbot.process.properties.Interpolate):
interpolations = {}
for k, v in r.kwargs.items():
interpolations[f"kw:{k}"] = v if v else ""
return r.fmtstring % interpolations
elif type(r) == str:
return r

return "unsupported_rendering"

def factory_has_num_steps(f, expected_num):
assert f
if len(f.steps) != expected_num:
print(f"error: factory_has_num_steps: {len(f.steps)}, expected {expected_num}")
return len(f.steps) == expected_num

def factory_has_step(f, name, hasarg=None, contains=None):
assert f
assert name

result = False

for s in f.steps:
v = partly_rendered(s.kwargs.get("name"))
if v == name:
result = True
# check that the step has that argument
arg_value = None
if hasarg:
if not hasarg in s.kwargs:
print(f"error: step '{v}': missing expected step argument '{hasarg}'")
return False

arg_value = s.kwargs.get(hasarg)

# Check for contained content if requested.
if arg_value and contains:
if type(contains) == type(arg_value) == dict:
result = contains.items() <= arg_value.items()
elif type(contains) == type(arg_value) == list:
result = contains <= arg_value
elif type(contains) == type(arg_value):
result = contains == arg_value
else:
print(f"error: step '{v}', argument '{hasarg}': unsupported type to compare, expected is '{type(contains)}', actual is '{type(arg_value)}'")
return False

if not result:
print(f"error: step '{v}', argument '{hasarg}': expected\n\t{contains}\nactual:\n\t{arg_value}")

return result

print(f"error: missing expected step '{name}'")

return False