~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to lib/torture/subunit.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
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
 
        }
37
 
}
38
 
 
39
 
static void subunit_test_start(struct torture_context *ctx, 
 
36
                return talloc_asprintf(ctx, "%s.%s", tcase->name, test->name);
 
37
        }
 
38
}
 
39
 
 
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
{
75
99
        fprintf(stderr, "%s", comment);
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
{
81
105
        fprintf(stderr, "WARNING!: %s\n", comment);
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
};