buildtest.buildsystem.base

BuilderBase class is an abstract class that defines common functions for any types of builders. Each type schema (script, compiler) is implemented as separate Builder.

ScriptBuilder class implements ‘type: script’ CompilerBuilder class implements ‘type: compiler’

Module Contents

Classes

BuilderBase(name, recipe, buildspec, testdir=None)

The BuilderBase is an abstract class that implements common functions for

CompilerBuilder(name, recipe, buildspec, testdir=None)

The BuilderBase is an abstract class that implements common functions for

CrayCompiler(name, recipe, buildspec, testdir=None)

The BuilderBase is an abstract class that implements common functions for

GNUCompiler(name, recipe, buildspec, testdir=None)

The BuilderBase is an abstract class that implements common functions for

IntelCompiler(name, recipe, buildspec, testdir=None)

The BuilderBase is an abstract class that implements common functions for

PGICompiler(name, recipe, buildspec, testdir=None)

The BuilderBase is an abstract class that implements common functions for

ScriptBuilder(name, recipe, buildspec, testdir=None)

The BuilderBase is an abstract class that implements common functions for

class buildtest.buildsystem.base.BuilderBase(name, recipe, buildspec, testdir=None)

The BuilderBase is an abstract class that implements common functions for any kind of builder.

__repr__(self)

Return repr(self).

__str__(self)

Return str(self).

_build_setup(self)

This method is the setup operation to get ready to build test which includes getting unique build id, setting up metadata object to store test details such as where test will be located and directory of test. This section cannot be reached without a valid, loaded recipe.

_generate_build_id(self)

Generate a build id based on the Buildspec name, and datetime.

_write_test(self)

This method is responsible for invoking generate_script that formulates content of testscript which is implemented in each subclass. Next we write content to file and apply 755 permission on script so it has executable permission.

build(self)

This method is responsible for invoking setup, creating test directory and writing test. This method is called from an instance object of this class that does builder.build().

generate_script(self)

Build the testscript content implemented in each subclass

get_bsub(self)
get_environment(self)

Retrieve a list of environment variables defined in buildspec and return them as list with the shell equivalent command

Returns

list of environment variable lines to add to test script.

Return type

list

get_sbatch(self)
get_test_extension(self)

Return the test extension, which depends on the shell used. Based on the value of shell key we return the shell extension.

shell: python –> py shell: bash –> sh (default)

Returns

returns test extension based on shell type

Return type

str

get_variables(self)

Retrieve a list of variables defined in buildspec and return them as list with the shell equivalent command.

Returns

list of variables variable lines to add to test script.

Return type

list

class buildtest.buildsystem.base.CompilerBuilder(name, recipe, buildspec, testdir=None)

Bases: buildtest.buildsystem.base.BuilderBase

The BuilderBase is an abstract class that implements common functions for any kind of builder.

cc
cflags
cppflags
cxx
cxxflags
executable
fc
fflags
lang_ext_table
ldflags
type = compiler
build_run_cmd(self)

This method builds the run command which refers to how to run the generated binary after compilation.

detect_lang(self, sourcefile)

This method will return the Programming Language based by looking up file extension of source file.

generate_compile_cmd(self)

This method generates the compilation line and returns the output as a list. The compilation line depends on the the language detected that is stored in variable self.lang.

generate_script(self)

This method will build the test content from a Buildspec that uses compiler schema. We need a ‘compiler’ and ‘source’ key which specifies the source files to compile. We resolve the source file path which can be an absolute value or relative path with respect to Buildspec. The file extension of sourcefile is used to detect the Programming Language which is used to lookup the compiler wrapper based on Language + Compiler. During compiler detection, we set class variables self.cc, self.cxx. self.fc, self.cflags, self.cxxflags, self.fflags, self.cppflags. self.ldflags. Finally we generate the compile command and add each instruction to lines which contains content of test. Upon completion, we return a list that contains content of the test.

get_cc(self)
get_cflags(self)
get_cppfilags(self)
get_cxx(self)
get_cxxflags(self)
get_fc(self)
get_fflags(self)
get_ldflags(self)
get_modules(self, modules)

Return a list of modules as a list

get_path(self)

This method returns the full path for GNU Compilers: gcc, g++, gfortran

resolve_source(self, source)

This method resolves full path to source file, it checks for absolute path first before checking relative path that is relative to Buildspec recipe.

set_cc(self, cc)
set_cflags(self, cflags)
set_cppflags(self, cppflags)
set_cxx(self, cxx)
set_cxxflags(self, cxxflags)
set_executable_name(self, name=None)

This method set the executable name. One may specify a custom name to executable via name argument. Otherwise the executable is using the filename of self.sourcefile and adding .exe extension at end.

set_fc(self, fc)
set_fflags(self, fflags)
set_ldflags(self, ldflags)
setup(self)
class buildtest.buildsystem.base.CrayCompiler(name, recipe, buildspec, testdir=None)

Bases: buildtest.buildsystem.base.CompilerBuilder

The BuilderBase is an abstract class that implements common functions for any kind of builder.

cc = cc
cxx = CC
fc = ftn
class buildtest.buildsystem.base.GNUCompiler(name, recipe, buildspec, testdir=None)

Bases: buildtest.buildsystem.base.CompilerBuilder

The BuilderBase is an abstract class that implements common functions for any kind of builder.

cc = gcc
cxx = g++
fc = gfortran
class buildtest.buildsystem.base.IntelCompiler(name, recipe, buildspec, testdir=None)

Bases: buildtest.buildsystem.base.CompilerBuilder

The BuilderBase is an abstract class that implements common functions for any kind of builder.

cc = icc
cxx = icpc
fc = ifort
class buildtest.buildsystem.base.PGICompiler(name, recipe, buildspec, testdir=None)

Bases: buildtest.buildsystem.base.CompilerBuilder

The BuilderBase is an abstract class that implements common functions for any kind of builder.

cc = pgcc
cxx = pgc++
fc = pgfortran
class buildtest.buildsystem.base.ScriptBuilder(name, recipe, buildspec, testdir=None)

Bases: buildtest.buildsystem.base.BuilderBase

The BuilderBase is an abstract class that implements common functions for any kind of builder.

type = script
generate_script(self)

This method builds the testscript content based on the builder type. For ScriptBuilder we need to add the shebang, environment variables and the run section. Environment variables are declared first followed by run section

Returns

return content of test script

Return type

list