-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jiri Jaburek <[email protected]>
- Loading branch information
Showing
7 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Some test suite use an intermediary layer between tests and the execution logic | ||
to re-use test code by parametrizing the tests. | ||
|
||
For example, a test can check ELF binary properties of any passed argument, | ||
reporting PASS/FAIL for that file. An intermediary "runconf" then specifies | ||
several executions of that same test, with different arguments. | ||
|
||
These "runconf" files can be a simple static language (like runtest files in the | ||
Linux Test Project), or they can be scripts that dynamically select/parametrize | ||
the tests based on environment. | ||
|
||
This example uses bash "runconf", defining a custom function called '+' that | ||
appends user-provided strings into a big array, which simply get passed to | ||
ptef-runner during a default argument-less run. | ||
When arguments are given on CLI, anything from runconf is ignored and the CLI | ||
arguments are used instead, preserving standard PTEF behavior. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash -x | ||
while [ $# -gt 0 ]; do | ||
if [ -f "/$1" -a ! -s "/$1" ]; then | ||
ptef-report PASS "$1" | ||
else | ||
ptef-report FAIL "$1" | ||
fi | ||
shift | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash -x | ||
while [ $# -gt 0 ]; do | ||
if [ -e "/$1" ]; then | ||
ptef-report PASS "$1" | ||
else | ||
ptef-report FAIL "$1" | ||
fi | ||
shift | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../utils/custom-runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# this is sourced by bash, so any bash logic is valid here | ||
|
||
+ exists/etc/passwd | ||
|
||
id=$(. /etc/os-release; echo "$ID") | ||
idlike=$(. /etc/os-release; echo "$ID_LIKE") | ||
|
||
if [ "$id" = "fedora" -o "$idlike" = "fedora" ]; then | ||
+ empty/etc/cron.deny | ||
+ empty/etc/motd | ||
fi | ||
|
||
if false; then | ||
+ this/is/never/added | ||
fi | ||
|
||
# vim: syntax=sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
utils/custom-runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
_alltests=() | ||
function + { | ||
_alltests+=("$@") | ||
} | ||
|
||
if [ -f runconf ]; then | ||
. runconf | ||
fi | ||
|
||
_base=$(basename "$0") | ||
|
||
if [ $# -eq 0 ]; then | ||
# no tests configured: behave according to spec, run everything | ||
if [ "${#_alltests[@]}" -eq 0 ]; then | ||
ptef-runner -a "$_base" | ||
else | ||
# since 'alltests' can contain more than ARG_MAX strings, | ||
# use xargs to split them into ARG_MAX-sized runs | ||
printf '%s\0' "${_alltests[@]}" | \ | ||
xargs -0 ptef-runner -a "$_base" | ||
fi | ||
else | ||
# running with user arguments, override alltests and just run what | ||
# the user instructed, per the spec | ||
ptef-runner -a "$_base" "$@" | ||
fi |