aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/mt_assert.318
-rw-r--r--man/mtest_overview.73
-rwxr-xr-xmtest.sh20
3 files changed, 41 insertions, 0 deletions
diff --git a/man/mt_assert.3 b/man/mt_assert.3
index 3b06a9b..ab22e9e 100644
--- a/man/mt_assert.3
+++ b/man/mt_assert.3
@@ -17,6 +17,8 @@ c/c++
shell
.PP
.BI "mt_fail <" expression ">"
+.br
+.BI "mt_dfail <" command "> [" argumnet "] ..."
.SH DESCRIPTION
.PP
Macro
@@ -38,6 +40,22 @@ works just as
but function is not forced to exit and can continue execution.
This is good when test allocates some memory and we need to clean up before
returning.
+.PP
+For shell scripting,
+.BR mt_fail (3)
+passed
+.I expression
+to eval.
+.I expression
+must be single argument, so it should be closed in "" to preserve spaces.
+If
+.I expression
+is easy and does not required
+.B eval
+to process, one can use
+.BR mt_dfail (3)
+which passes all arguments directly to if statement
+.B """if ! ${@}"""
.SH EXAMPLE
.PP
Proper example can be found in
diff --git a/man/mtest_overview.7 b/man/mtest_overview.7
index 6f4172b..f69f153 100644
--- a/man/mtest_overview.7
+++ b/man/mtest_overview.7
@@ -41,6 +41,8 @@ For shell
.br
.BI "mt_fail <" expression ">"
.br
+.BI "mt_dfail <" command "> [" argumnet "] ..."
+.br
.BR "mt_return"
.PP
Test output is compatible with
@@ -104,6 +106,7 @@ Example of using mt in posix shell
a=1
a=$((a + 1))
mt_fail "[ $a -eq 2 ]"
+ mt_dfail [ $a -eq 3 ]
}
mt_run test_one
diff --git a/mtest.sh b/mtest.sh
index 61af340..fc4a934 100755
--- a/mtest.sh
+++ b/mtest.sh
@@ -158,6 +158,26 @@ mt_fail()
## ==========================================================================
+# same as mt_fail() but does not use eval and arguments are directly
+# passed to if
+#
+# $@ - code to run
+## ==========================================================================
+
+
+mt_dfail()
+{
+ mt_total_checks=$(( mt_total_checks + 1 ))
+ if ! $@
+ then
+ echo "# assert $mt_current_test, '$1'"
+ mt_test_status=1
+ mt_checks_failed=$(( mt_checks_failed + 1 ))
+ fi
+}
+
+
+## ==========================================================================
# prints test plant in format 1..<number_of_test_run>. If all tests have
# passed, macro will exit script with code 0, else it returns number of
# failed tests. If number of failed tests exceeds 254, then 254 will be