r16174: Couple of fixes to the UI code - make 'torture_ok()' optional, be more verbos...
authorJelmer Vernooij <jelmer@samba.org>
Mon, 12 Jun 2006 23:03:02 +0000 (23:03 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:09:05 +0000 (14:09 -0500)
source/torture/smbtorture.c
source/torture/ui.c
source/torture/ui.h

index 97b6ab2c65d89989be51f7bd4ca302bf93ab6ac4..c2c76d25c3f2631fa2dcd08cecfd7b2220574c85 100644 (file)
@@ -240,7 +240,22 @@ static void simple_test_start (struct torture_test *test)
 
 static void simple_test_result (struct torture_test *test, enum torture_result res, const char *reason)
 {
-       printf("\t %d: %s\n",res, reason?reason:"");
+       switch (res) {
+       case TORTURE_OK:
+               if (reason)
+                       printf("OK: %s\n", reason);
+               break;
+       case TORTURE_FAIL:
+               printf("ERROR: %s - %s\n", test->name, reason);
+               break;
+       case TORTURE_TODO:
+               printf("TODO: %s - %s\n", test->name, reason);
+               break;
+       case TORTURE_SKIP:
+               printf("SKIP: %s - %s\n", test->name, reason);
+               break;
+
+       }
 }
 
 static void simple_comment (struct torture_test *test, const char *comment)
index 9c25991d20fdf89bf31d899a8ced3e1cd01601f9..62f8bacb65ce589e5b9ab199bed329a3722560e8 100644 (file)
 #include "includes.h"
 #include "torture/ui.h"
 
+static int test_destructor(void *_test)
+{
+       struct torture_test *test = _test;
+
+       if (test->result == TORTURE_OK)
+               torture_ok(test);
+
+       return 0;       
+}
+
+
 struct torture_test *torture_test(struct torture_context *ctx, const char *name, const char *description)
 {
        struct torture_test *test = talloc(ctx, struct torture_test);
@@ -32,6 +43,8 @@ struct torture_test *torture_test(struct torture_context *ctx, const char *name,
 
        ctx->ui_ops->test_start(test);
 
+       talloc_set_destructor(test, test_destructor);
+
        return test;
 }
 
@@ -44,8 +57,10 @@ struct torture_test *torture_subtest(struct torture_test *parent, const char *na
        test->context = parent->context;
 
        test->context->ui_ops->test_start(test);
+
+       talloc_set_destructor(test, test_destructor);
        
-       return NULL;
+       return test;
 }
 
 void torture_comment(struct torture_test *test, const char *comment, ...) _PRINTF_ATTRIBUTE(2,3)
@@ -60,6 +75,7 @@ void torture_comment(struct torture_test *test, const char *comment, ...) _PRINT
        talloc_free(tmp);
 }
 
+
 void torture_ok(struct torture_test *test)
 {
        test->context->ui_ops->test_result(test, TORTURE_OK, NULL);
index 8bc309d717ffe58aedf259b4542e14d604f0c6e3..9c19d99f1c4affbf99855d25bc38570f2e939e26 100644 (file)
@@ -43,6 +43,8 @@ struct torture_test
 
        void *ui_data;
 
+       enum torture_result result;
+
        struct torture_context *context;
 };