Changeset 745 for trunk/server/lib/torture/subunit.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/lib/torture/subunit.c
r414 r745 20 20 #include "includes.h" 21 21 #include "lib/torture/torture.h" 22 #include <subunit/child.h> 22 23 23 static void subunit_suite_start(struct torture_context *ctx,24 static void torture_subunit_suite_start(struct torture_context *ctx, 24 25 struct torture_suite *suite) 25 26 { 26 27 } 27 28 28 static void subunit_print_testname(struct torture_context *ctx,29 static char *torture_subunit_test_name(struct torture_context *ctx, 29 30 struct torture_tcase *tcase, 30 31 struct torture_test *test) 31 32 { 32 33 if (!strcmp(tcase->name, test->name)) { 33 printf("%s", test->name);34 return talloc_strdup(ctx, test->name); 34 35 } else { 35 printf("%s.%s", tcase->name, test->name);36 return talloc_asprintf(ctx, "%s.%s", tcase->name, test->name); 36 37 } 37 38 } 38 39 39 static void subunit_test_start(struct torture_context *ctx, 40 static void torture_subunit_report_time(struct torture_context *tctx) 41 { 42 struct timespec tp; 43 struct tm *tmp; 44 char timestr[200]; 45 if (clock_gettime(CLOCK_REALTIME, &tp) != 0) { 46 perror("clock_gettime"); 47 return; 48 } 49 50 tmp = localtime(&tp.tv_sec); 51 if (!tmp) { 52 perror("localtime"); 53 return; 54 } 55 56 if (strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", tmp) <= 0) { 57 perror("strftime"); 58 return; 59 } 60 61 printf("time: %s.%06ld\n", timestr, tp.tv_nsec / 1000); 62 } 63 64 static void torture_subunit_test_start(struct torture_context *context, 40 65 struct torture_tcase *tcase, 41 66 struct torture_test *test) 42 67 { 43 printf("test: "); 44 subunit_print_testname(ctx, tcase, test); 45 printf("\n"); 68 char *fullname = torture_subunit_test_name(context, context->active_tcase, context->active_test); 69 subunit_test_start(fullname); 70 torture_subunit_report_time(context); 71 talloc_free(fullname); 46 72 } 47 73 48 static void subunit_test_result(struct torture_context *context,74 static void torture_subunit_test_result(struct torture_context *context, 49 75 enum torture_result res, const char *reason) 50 76 { 77 char *fullname = torture_subunit_test_name(context, context->active_tcase, context->active_test); 78 torture_subunit_report_time(context); 51 79 switch (res) { 52 80 case TORTURE_OK: 53 printf("success: ");81 subunit_test_pass(fullname); 54 82 break; 55 83 case TORTURE_FAIL: 56 printf("failure: ");84 subunit_test_fail(fullname, reason); 57 85 break; 58 86 case TORTURE_ERROR: 59 printf("error: ");87 subunit_test_error(fullname, reason); 60 88 break; 61 89 case TORTURE_SKIP: 62 printf("skip: ");90 subunit_test_skip(fullname, reason); 63 91 break; 64 92 } 65 subunit_print_testname(context, context->active_tcase, context->active_test); 66 67 if (reason) 68 printf(" [\n%s\n]", reason); 69 printf("\n"); 93 talloc_free(fullname); 70 94 } 71 95 72 static void subunit_comment(struct torture_context *test,96 static void torture_subunit_comment(struct torture_context *test, 73 97 const char *comment) 74 98 { … … 76 100 } 77 101 78 static void subunit_warning(struct torture_context *test,102 static void torture_subunit_warning(struct torture_context *test, 79 103 const char *comment) 80 104 { … … 82 106 } 83 107 108 static void torture_subunit_progress(struct torture_context *tctx, int offset, enum torture_progress_whence whence) 109 { 110 switch (whence) { 111 case TORTURE_PROGRESS_SET: 112 printf("progress: %d\n", offset); 113 break; 114 case TORTURE_PROGRESS_CUR: 115 printf("progress: %+-d\n", offset); 116 break; 117 case TORTURE_PROGRESS_POP: 118 printf("progress: pop\n"); 119 break; 120 case TORTURE_PROGRESS_PUSH: 121 printf("progress: push\n"); 122 break; 123 default: 124 fprintf(stderr, "Invalid call to progress()\n"); 125 break; 126 } 127 } 128 84 129 const struct torture_ui_ops torture_subunit_ui_ops = { 85 .comment = subunit_comment, 86 .warning = subunit_warning, 87 .test_start = subunit_test_start, 88 .test_result = subunit_test_result, 89 .suite_start = subunit_suite_start 130 .comment = torture_subunit_comment, 131 .warning = torture_subunit_warning, 132 .test_start = torture_subunit_test_start, 133 .test_result = torture_subunit_test_result, 134 .suite_start = torture_subunit_suite_start, 135 .progress = torture_subunit_progress, 136 .report_time = torture_subunit_report_time, 90 137 };
Note:
See TracChangeset
for help on using the changeset viewer.