Build Integration: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
(New page: This article describes how to add tests to your target build. It assumes that your have completed the steps described in the article Runtime Integration. -adding build tools -impleme...)
 
No edit summary
Line 1: Line 1:
This article describes how to add tests to your target build. It assumes that your have completed the steps described in the article [[Runtime Integration]].


This article describes how to add tests to your target build. It assumes that your have completed the steps described in the article [[Runtime Integration]].


-adding build tools
-implementing a strategy for adding test unit sources


==Adding STRIDE Build Tools to Your Target Build==
== Adding STRIDE Build Tools to Your Target Build ==
If you haven't already done so, download and install the appropriate [[Package_Installation#Build_Tools]] package on your target build machine. The [[Build Tools|STRIDE Build Tools]] must be run as part of your build process to generate additional artifacts needed to build and run your tests.
 
=== Build Artifacts ===
The STRIDE Build Tools take one or more .h files as input, and produce
* <u>A STRIDE database (.sidb) file</u> that contains metadata describing the tests declared in the input header files
** This file is used as an intermediate file in the build process, and is used by the host [[Stride Runner]]
* <u>Generated .h and .c (or .cpp) source files</u>
** These files implement harnessing which allows the tests to be run remotely
 
=== Build Order ===
[[image:STRIDE Build Process1.jpg|thumb||STRIDE Build Process Overview]]
The Build Tools-generated source code--referred to as an [[Intercept Module]]--is compiled and linked along with the rest of your target sources, therefore the Build Tools must be run (and the IM source compiled) before your target link takes place. Often the simplest approach is to add the STRIDE Build Tools so that they run as the first step in your build process.
 
=== Build Tool Inputs ===
The collection of .h files that comprise the input to the Build Tools (specifically, the [[S2scompile|s2scompile]] tool) will change as new test assets are created. It's important that the process of adding new test files to the target build is simple and straightforward. Therefore, a technique that supports this changing input is recommended.
 
The SDK Makefile uses such a technique: a directory is designated to contain all files to be input to the s2scompile tool.


===Compiler Settings===
===Compiler Settings===
The s2scompile tool requires settings that customize compiler settings for your target environment.
Complete information can be found in [[S2scompile]], but the most important options are as follows:
;--c / --c++
: Controls whether IM code is generated as c or c++
;--compatibility
: Controls which language extensions are used in the generated IM code
;--targ_*
: Sets datatype characteristics (size, alignment, etc.). Some examples are shown in [[Sample Stride Target Settings]]
== Build Tools Integration ==
The Makefile included with the SDK can serve as an example of build tools make integration. Another stripped-down Makefile is shown below.
'''Sample GNU makefile illustrating use of STRIDE Build Tools:'''
<source lang="bash">
# Makefile for Stride Build
.PHONY: clean all _build _instrument
.PRECIOUS: Makefile
#  input to build tools will be all .h files in SCL_DIRS
SCL_DIRS = $(HOME)/stride/SCL_headers
SCL_SRCS_H = $(foreach dir, $(SCL_DIRS), $(wildcard $(dir)/*.h))
# Set this to the directory that contains the
# STRIDE 'Runtime' files
RUNTIME_PATH = $(HOME)/SDK/Runtime
BUILD_ROOT = .
INT_PATH = $(BUILD_ROOT)/Meta
OUT_PATH = $(BUILD_ROOT)
IM_PATH  = $(BUILD_ROOT)/IM
S2SC = s2scompile
S2SB = s2sbind
S2SI = s2sinstrument
INC_PATHS = \
    -I "$(RUNTIME_PATH)" \
    --sys_include "/usr/include" \
DEFINES =
CFLAGS = $(INC_PATHS) $(DEFINES) --c
COMPILER_OPTIONS_FILE = $(HOME)/SDK/Linux/settings/stride.s2sinstrument
METAS = $(foreach src, $(SCL_SRCS_H:.h=.h.meta), $(INT_PATH)/$(notdir $(src)))
SIDB = stride.sidb
vpath %.h $(foreach dir, $(SCL_DIRS), $(dir))
all: _build _instrument
clean:
    $(RM) $(METAS) $(OUT_PATH)/$(SIDB)
_build: $(OUT_PATH)/$(SIDB)
#rule to run s2sbind
$(OUT_PATH)/$(SIDB): $(METAS)
    @if [ ! -e $(OUT_PATH) ] ; then mkdir $(OUT_PATH) ; fi
    $(S2SB) --output=$@ $(METAS)
# rule to run s2scompile
$(INT_PATH)/%.meta: %
    @if [ ! -e $(INT_PATH) ] ; then mkdir $(INT_PATH) ; fi
    $(S2SC) --options_file="$(COMPILER_OPTIONS_FILE)" $(CFLAGS) --output="$@" "$<"
# rule to run s2sinstrument
_instrument:
    @if [ ! -e $(IM_PATH) ] ; then mkdir $(IM_PATH) ; fi
    $(S2SI) --options_file="$(BUILD_ROOT)/stride.s2sinstrument" --im_name=stride --code_output="$(IM_PATH)" --header_output="$(IM_PATH)" "$(OUT_PATH)/$(SIDB)"
</source>
The sample here shows only the Build Tools phase of the build. In addition to what's shown here, you need to also:
* Include the IM source file strideIM.c in your target compile and link
* Include any source files that implement test units in your target compile and link.
== Launching the IM Thread in the Target Application ==


[[Sample Stride Target Settings]]


==Building the Target with STRIDE Diagnostics==
==Building the Target with STRIDE Diagnostics==
srDiag.h
srDiag.c


==Running STRIDE Diagnostics==
==Running STRIDE Diagnostics==

Revision as of 16:53, 9 June 2009

This article describes how to add tests to your target build. It assumes that your have completed the steps described in the article Runtime Integration.


Adding STRIDE Build Tools to Your Target Build

If you haven't already done so, download and install the appropriate Package_Installation#Build_Tools package on your target build machine. The STRIDE Build Tools must be run as part of your build process to generate additional artifacts needed to build and run your tests.

Build Artifacts

The STRIDE Build Tools take one or more .h files as input, and produce

  • A STRIDE database (.sidb) file that contains metadata describing the tests declared in the input header files
    • This file is used as an intermediate file in the build process, and is used by the host Stride Runner
  • Generated .h and .c (or .cpp) source files
    • These files implement harnessing which allows the tests to be run remotely

Build Order

STRIDE Build Process Overview

The Build Tools-generated source code--referred to as an Intercept Module--is compiled and linked along with the rest of your target sources, therefore the Build Tools must be run (and the IM source compiled) before your target link takes place. Often the simplest approach is to add the STRIDE Build Tools so that they run as the first step in your build process.

Build Tool Inputs

The collection of .h files that comprise the input to the Build Tools (specifically, the s2scompile tool) will change as new test assets are created. It's important that the process of adding new test files to the target build is simple and straightforward. Therefore, a technique that supports this changing input is recommended.

The SDK Makefile uses such a technique: a directory is designated to contain all files to be input to the s2scompile tool.

Compiler Settings

The s2scompile tool requires settings that customize compiler settings for your target environment.

Complete information can be found in S2scompile, but the most important options are as follows:

--c / --c++
Controls whether IM code is generated as c or c++
--compatibility
Controls which language extensions are used in the generated IM code
--targ_*
Sets datatype characteristics (size, alignment, etc.). Some examples are shown in Sample Stride Target Settings

Build Tools Integration

The Makefile included with the SDK can serve as an example of build tools make integration. Another stripped-down Makefile is shown below.

Sample GNU makefile illustrating use of STRIDE Build Tools:

# Makefile for Stride Build
.PHONY: clean all _build _instrument
.PRECIOUS: Makefile

#  input to build tools will be all .h files in SCL_DIRS
SCL_DIRS = $(HOME)/stride/SCL_headers
SCL_SRCS_H = $(foreach dir, $(SCL_DIRS), $(wildcard $(dir)/*.h))

# Set this to the directory that contains the
# STRIDE 'Runtime' files
RUNTIME_PATH = $(HOME)/SDK/Runtime

BUILD_ROOT = .

INT_PATH = $(BUILD_ROOT)/Meta
OUT_PATH = $(BUILD_ROOT)
IM_PATH  = $(BUILD_ROOT)/IM

S2SC = s2scompile
S2SB = s2sbind
S2SI = s2sinstrument

INC_PATHS = \
    -I "$(RUNTIME_PATH)" \
    --sys_include "/usr/include" \

DEFINES = 

CFLAGS = $(INC_PATHS) $(DEFINES) --c

COMPILER_OPTIONS_FILE = $(HOME)/SDK/Linux/settings/stride.s2sinstrument

METAS = $(foreach src, $(SCL_SRCS_H:.h=.h.meta), $(INT_PATH)/$(notdir $(src)))

SIDB = stride.sidb

vpath %.h $(foreach dir, $(SCL_DIRS), $(dir))

all: _build _instrument

clean:
    $(RM) $(METAS) $(OUT_PATH)/$(SIDB)

_build: $(OUT_PATH)/$(SIDB)

#rule to run s2sbind
$(OUT_PATH)/$(SIDB): $(METAS)
    @if [ ! -e $(OUT_PATH) ] ; then mkdir $(OUT_PATH) ; fi
    $(S2SB) --output=$@ $(METAS)

# rule to run s2scompile
$(INT_PATH)/%.meta: %
    @if [ ! -e $(INT_PATH) ] ; then mkdir $(INT_PATH) ; fi
    $(S2SC) --options_file="$(COMPILER_OPTIONS_FILE)" $(CFLAGS) --output="$@" "$<"

# rule to run s2sinstrument
_instrument:
    @if [ ! -e $(IM_PATH) ] ; then mkdir $(IM_PATH) ; fi
    $(S2SI) --options_file="$(BUILD_ROOT)/stride.s2sinstrument" --im_name=stride --code_output="$(IM_PATH)" --header_output="$(IM_PATH)" "$(OUT_PATH)/$(SIDB)"

The sample here shows only the Build Tools phase of the build. In addition to what's shown here, you need to also:

  • Include the IM source file strideIM.c in your target compile and link
  • Include any source files that implement test units in your target compile and link.

Launching the IM Thread in the Target Application

Building the Target with STRIDE Diagnostics

srDiag.h srDiag.c

Running STRIDE Diagnostics

Interpreting Diagnostic Results

- add TestIntro sample to build

- run tests -publish

-- good technique is to set up like the sdk makefile; all test sources and headers are put in a specific directory.

-- build tools Build Tools