(Created page with "== Introduction == Blts-common package (0.4.0) provides common functions used in BLTS test assets gathered in one library. It includes common functionality like: ;*logging ;*tim…") |
|||
| Line 16: | Line 16: | ||
=== Building packages === | === Building packages === | ||
| - | + | {{:Quality/TestSuite/Building_BLTS_Packages}} | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
The building environment requires the following RPM packages installed: | The building environment requires the following RPM packages installed: | ||
Contents |
Blts-common package (0.4.0) provides common functions used in BLTS test assets gathered in one library. It includes common functionality like:
Current common library CLI implementation requires starting tests as root.
The source package includes the pack.sh script, which is used for building RPM and Debian packages and source tar packages. To build an RPM package with the script, execute this command in the top level source directory of asset:
./pack.sh -r
To get help about the packaging script, execute
./pack.sh -h
The asset can also be built manually by executing:
./autogen.sh ./configure make
The building environment requires the following RPM packages installed:
All BLTS test packages have dependency to the blts-common package so it is mandatory and must be installed first. The library package can be installed in the device by executing the command:
rpm -ivh libbltscommon1_{version}.rpm
Results XML writer part of the common library requires that the test environment must have following package installed:
The common library command-line frontend offers following general arguments for all BLTS test drivers:
| General Switch | Function |
|---|---|
| -l | Used log file |
| -e | Execute single or multiple selected tests, for example -e 1,4,5. |
| -en | Execute test by name, for example -en "My test X" |
| -s | Show list of all tests |
| -C | Used configuration file |
| -? | Help message |
| -xml, -axml | Create result XML. -axml appends results to an existing XML file. |
| -auto | Silent logging for test automation. Only the results are printed to stdout. |
| -v | Verbose logging (default) |
| -vv | Even more verbose logging |
The development package can be installed by executing the command:
rpm -ivh libbltscommon-devel_{version}.rpm
blts-common library can be used with own test modules by doing modifications to configure.ac file:
# Checks for libraries. AC_CHECK_LIB([bltscommon], [log_open],,[AC_MSG_ERROR([cannot find libbltscommon])]) # Library configs BLTS_COMMON_CFLAGS=`pkg-config --cflags bltscommon` BLTS_COMMON_LIBS=`pkg-config --libs bltscommon` AC_SUBST(BLTS_COMMON_CFLAGS) AC_SUBST(BLTS_COMMON_LIBS)
or simply by adding this line:
PKG_CHECK_MODULES([BLTSCOMMON],[bltscommon])
Using the dependency checker
#include <blts_dep_check.h> depcheck(rulesfile,loglevel);
The parameter rulesfile here is a name of a file containing rules to be checked and the parameter loglevel can be value between 0-2.
In rules file there must be only one rule per line and the format for a defined rule format is <strictness> <type> <name>
Example of rules file (used for checking ALSA components):
required kmod snd_pcm optional bin aplay required lib libasound.so optional file /usr/share/alsa-base/alsa.default
Using logging functions
#include <blts_log.h> int blts_log_open(const char *filename, unsigned int flags); //open given log file int blts_log_close(); //close current log file void blts_log_set_level(int level); //setter for logging level int blts_log_get_level(); //getter for logging level void blts_log_print_level(int level, const char *format, ...); //print to current log file int blts_log_start_syslog_capture(); //start syslog capture (in child process) int blts_log_end_syslog_capture(); //stop syslog capture
The common library supports four different logging levels:
Messages logged with a level other than trace are printed to the log file by default and to stdout when using -v argument. To get trace level messages visible, -vv argument must be used.
The following macros can be used to log messages with a different levels:
There is also two trace level macros to use for tracking function usage:
The syslog_capture functions can be used to log system messages when executing test cases if necessary. The syslog path is hard coded "/var/log/tests/kmsg.log"
CLI frontend example
The blts-common package comes with an example that can used as an starting point when developing own test drivers. The example source codes files are located in subfolder src/blts-cli-example. The CLI frontend example shows also how to use configuration files and parameter variations in your own test drivers. See README.ParameterVariation documentation for the further instructions.
Both Debian and RPM packaging is provided.
The blts-common package consists of libbltscommon1 runtime library and libbltscommon-devel development library. There is also some example files that show how to use blts-common library.
| blts-common | blts-common library |
| Version | Date | Handled By | Status | Comments |
|---|---|---|---|---|
| 0.1 | 17-Dec-2010 | Aki Nyman | Draft | Page created (refers to blts-common package 0.4.0) |