summaryrefslogtreecommitdiff
path: root/lib/torture
diff options
context:
space:
mode:
authorJoseph Sutton <josephsutton@catalyst.net.nz>2023-04-12 09:41:29 +1200
committerAndreas Schneider <asn@cryptomilk.org>2023-04-12 13:52:32 +0000
commit44d03bf47930e81679feede7a7719feb7aa77c95 (patch)
treeef617c7de2a209a0d86383ee21d883832e442c1d /lib/torture
parent80c548437a7a199c3897246a71df2a2c5348b37a (diff)
downloadsamba-44d03bf47930e81679feede7a7719feb7aa77c95.tar.gz
lib/torture: Don't overwrite test outcomes
If a test fails an assertion, and later calls torture_skip() to skip part of the test, the TORTURE_SKIP result will overwrite the TORTURE_FAIL result, and the overall outcome will be successful. To avoid this, we now arrange possible outcomes in order of priority, and ensure we always keep the higher priority one. This reveals some failing tests. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'lib/torture')
-rw-r--r--lib/torture/torture.c22
-rw-r--r--lib/torture/torture.h10
2 files changed, 20 insertions, 12 deletions
diff --git a/lib/torture/torture.c b/lib/torture/torture.c
index b8fb28f669f..41226ef7504 100644
--- a/lib/torture/torture.c
+++ b/lib/torture/torture.c
@@ -212,18 +212,22 @@ void torture_warning(struct torture_context *context, const char *comment, ...)
void torture_result(struct torture_context *context,
enum torture_result result, const char *fmt, ...)
{
- va_list ap;
+ /* Of the two outcomes, keep that with the higher priority. */
+ if (result >= context->last_result) {
+ va_list ap;
- va_start(ap, fmt);
+ va_start(ap, fmt);
- if (context->last_reason) {
- torture_warning(context, "%s", context->last_reason);
- talloc_free(context->last_reason);
- }
+ if (context->last_reason) {
+ torture_warning(context, "%s", context->last_reason);
+ talloc_free(context->last_reason);
+ }
- context->last_result = result;
- context->last_reason = talloc_vasprintf(context, fmt, ap);
- va_end(ap);
+ context->last_result = result;
+ context->last_reason = talloc_vasprintf(context, fmt, ap);
+
+ va_end(ap);
+ }
}
/**
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index f6089684afd..6818084ea96 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -27,11 +27,15 @@ struct torture_suite;
struct torture_tcase;
struct torture_results;
+/*
+ * Arranged in precedence order. TORTURE_ERROR has the highest priority;
+ * TORTURE_OK the lowest.
+ */
enum torture_result {
TORTURE_OK=0,
- TORTURE_FAIL=1,
- TORTURE_ERROR=2,
- TORTURE_SKIP=3
+ TORTURE_SKIP=1,
+ TORTURE_FAIL=2,
+ TORTURE_ERROR=3
};
enum torture_progress_whence {