tapper-autoreport
is a "bash include file" you can add ("source") at
the end of your own bash script.
It then magically turns your bash script into an "Tapper test suite".
It also allows your bash script to be executed locally via the prove
command, a standard tool to run test scripts that produce TAP output
("Test Anything Protocol") -- without requiring an actual Tapper
framework.
Due to that and no other external dependecies it's a good starting point to write actual *function tests that are reusable.
It collects meta information from system, reports test results and can upload logs and other files over network to a Tapper server.
Run the scripts locally in a subdir where the tapper-autoreport
script is located.
- script:
#! /bin/bash
# your own stuff here ...
. /tapper-autoreport
Explanation:
- First it imports utility functions to be used by your script.
- Then you write your test.
- Then calls the actual reporting of test results, with all the Tapper details, like:
- TAP
- filename gets name
- run itself is already a success
- meta information
- report grouping heuristics
- self-report to Tapper
- upload files
- print out Tapper report URL
The tool prove
is a standard tool available in every Linux
distribution. Use it this way:
$ prove ./trivial-example-1.sh
./trivial-example-1.sh .. ok
All tests successful.
Files=1, Tests=5, 20 wallclock secs
Result: PASS
Explanation:
- "prove" is an existing standard tool
- it prints success statistics
- no report sending happens
- is meant for manual developing/testing
Cmd line and output:
$ ./trivial-example-1.sh
# http://tapper/tapper/reports/id/129218
# - upload ./trivial-example-1.sh ...
# - upload /boot/config-2.6.32-22-generic ...
# - upload /proc/cpuinfo ...
# - upload /proc/devices ...
# - upload /proc/version ...
Explanation:
- execute script
- report output to Tapper server
- upload files
- prints out Tapper report URL
- is meant for final reporting
You can influence the meta information when the automagic and defaults don't work perfectly:
#! /bin/bash
. ./tapper-autoreport nok /tmp/results.log $?
ok 0 "affe loewe tiger"
ok 0 "some other description"
ok 0 "yet another test description"
append_tapdata "timecpb: 12.345"
append_tapdata "timenocpb: 23.456"
SUITENAME="CPUID-ON"
SUITEVERSION="2.007"
OSNAME="Gentoo 10.1"
CHANGESET="98765"
HOSTNAME="J-F-Sebastian"
TICKETURL='https://mybugtracker/bugs/show_bug.cgi?id=901'
WIKIURL=https://mywiki/wiki/SomeTopic
PLANNINGID=foocompany.coolproduct.qa.coolfeature.test
TAPPER_REPORT_SERVER="tapper-devel"
NOSEND=1
uname -a | grep -q Linux # example for exit code
. ./tapper-autoreport nok /tmp/my-results.txt $?
Explanation:
- define additional test results, using fix success status of 0 (0 is TRUE in shell)
- define additional YAML data lines
- overwrite suite name
- overwrite suite version
- overwrite OS name
- overwrite changeset, usually kernel
- overwrite hostname
- specify relevant URL in used ticket system (like Bugzilla, RT, ...)
- specify relevant URL in used wiki
- specify relevant task planning id (like MS Project, TaskJuggler, ...)
- use different report server (e.g. "tapper-devel" for experiments)
- set NOSEND=1 to suppress sending to reports server completely
- param "nok" say "something was not ok"
- param of filename /tmp/my-results.txt means upload the file
- param of integer ($? is last exit code, 0 means ok, else not ok)
Import utility functions at the beginning of the script via
. ./tapper-autoreport --import-utils
Then you have several functions available.
Evaluates the first argument with Shell boolean semantics (0 is true) and appends a corresponding TAP line.
Evaluates the first argument with Shell inverse boolean semantics (0 is false) and appends a corresponding TAP line.
Appends a complete TAP line where you have taken care for the "ok"/"not ok" at the beginning.
Appends a key:value line at the tapdata YAML block. The key must start with letter and consist of only alphanum an underscore.
All require_*
functions check for something and gracefully exit
the script if the requirement is not fulfilled. Use this to
allow the script to run everywhere without polluting results with
false negatives.
Ensures vendor is AMD and cpu family from /proc/cpuinfo
is in a
minimum/maximum range. If you don't specify MIN it defaults to 0. If
you don't specify MAX it defaults to MIN.
Verifies that the string "foo" occurs in /proc/cpuinfo
flags section.
Verify that the program "foo" is available.
Use it to declare external programs you call, like "awk", "bc", "perl", etc.
Verify that L3 cache is available (checked in /sys/devices/system/cpu/cpu0/cache/index3).
Verify that a variant of netcat
(netcat, nc) is available.
Verify that the user executing the script is root (UID 0).
Verify that the current LK release is less than required 1st level version number.
Verify that the current LK release is less than required 2nd level version number.
Verify that the current LK release is less than required 3rd level version number.
These are really just utilities to help you but they don't influence the behaviour like the require_* functions do.
Returns 0 (shell TRUE) if L3 cache is available (checked in /sys/devices/system/cpu/cpu0/cache/index3).
Returns 0 (shell TRUE) if string "foo" occurs in /proc/cpuinfo
flags
section.
Return 0 (shell TRUE) if the program "foo" is available.
Prints vendor "AMD" or "Intel" from /proc/cpuinfo
.
Returns 0 (shell TRUE) if vendor is Intel.
Returns 0 (shell TRUE) if vendor is AMD.
Prints a random integer between 0 and MAX (default 32768).
Print cpu family from /proc/cpuinfo
.
Returns 0 (shell TRUE) if cpu family from /proc/cpuinfo is greater or equal to MINFAMILY. Defaults to 0.
Returns 0 (shell TRUE) if cpu family from /proc/cpuinfo is less or equal to MAXFAMILY. Defaults to 999.
Goes through all specified filenames and prints the first one that exists and is readable.
Returns 0 (shell TRUE) if WORD appears in "SPACE SEPARATED LIST OF WORDS". Remember the usual shell quoting rules.
Prints the 1st part of the kernel version number from uname -r.
Prints the 2nd part of the kernel version number from uname -r.
Prints the 3rd part of the kernel version number from uname -r.
You can
- use environment variables to provide more content
- provide commandline params that "Do What I Mean"
- define hooks (functions) to be called
TAP[*]
- Array of TAP linesTAPDATA[*]
- Array of YAML lines that contain data in TAPHEADERS[*]
- Array of Tapper headersOUTPUT[*]
- Array of additional output linesSUITENAME
- alternative suite name instead of $0SUITEVERSION
- alternative suite versionKEYWORDS
- space separated keywords to influence suite nameOSNAME
- alternative OS descriptionCHANGESET
- alternative changesetHOSTNAME
- alternative hostnameTAPPER_REPORT_SERVER
- alternative report serverTICKETURL
- relevant URL in used ticket system (Bugzilla)WIKIURL
- relevant URL in used wikiPLANNINGID
- relevant task planning id (MS Project, TaskJuggler)NOSEND
- if "1" no sending to Tapper happensNOUPLOAD
- if "1" no uploading of default files happens
--version
- print version number and exitnok
- declare something was not ok- [integer] - exit code of a program, 0 == ok, else not (Hint: use '$?' to refer to last program)
- [filename] - upload the file
- optional shell function to be executed at the end of autoreport's main()
- all stdout will be part of the report
They look like this: http://tapper/tapper/reports/id/129218
- report group
- testrun
- suite name
- suite version
- machine name
- reporter name (owner)
- uname
- OS name
- kernel version
- changeset
- kernel flags
- cpuinfo
- ram
- execution time
- bogomips
- itself
- /proc/cpuinfo
- /proc/devices
- /proc/version
- other files you give as params