s4/test: Replace hand-made field count to test
authorKamen Mazdrashki <kamenim@samba.org>
Sat, 22 May 2010 02:03:16 +0000 (05:03 +0300)
committerKamen Mazdrashki <kamenim@samba.org>
Wed, 26 May 2010 11:36:12 +0000 (14:36 +0300)
This patch replaces hand-make count of fields to be tested
with defines for FIRST-LAST value for corresponding fields
to test with.

As a side-effect, 'acct_flags' is now included in tests.

source4/torture/libnet/libnet_user.c
source4/torture/libnet/userman.c
source4/torture/libnet/usertest.h

index 140282bd2bbdc6fdc4648dea3cc83a33932b4d24..03e460fcf59b863c9fec07eb57cea400286bbbd4 100644 (file)
@@ -356,10 +356,10 @@ static void set_test_changes(struct torture_context *tctx,
 
        torture_comment(tctx, "Fields to change: [");
 
-       for (i = 0; i < num_changes && i < FIELDS_NUM; i++) {
+       for (i = 0; i < num_changes && i <= USER_FIELD_LAST; i++) {
                const char *fldname;
 
-               testfld = (req_change == none) ? (random() % FIELDS_NUM) : req_change;
+               testfld = (req_change == none) ? (random() % USER_FIELD_LAST) + 1 : req_change;
 
                /* get one in case we hit time field this time */
                gettimeofday(&now, NULL);
@@ -524,7 +524,7 @@ bool torture_modifyuser(struct torture_context *torture)
 
        torture_comment(torture, "Testing change of all fields - each single one in turn\n");
 
-       for (fld = 1; fld < FIELDS_NUM - 1; fld++) {
+       for (fld = USER_FIELD_FIRST; fld <= USER_FIELD_LAST; fld++) {
                ZERO_STRUCT(req);
                req.in.domain_name = lp_workgroup(torture->lp_ctx);
                req.in.user_name = name;
index c1d67fb8b6c37a4a940f9d2bb3de52f8cb04fbd3..c67f133356cf41b7462ed4e231d46ca31ff7a1fd 100644 (file)
@@ -110,10 +110,10 @@ static bool test_usermod(struct torture_context *tctx, struct dcerpc_pipe *p,
 
        torture_comment(tctx, "fields to change: [");
 
-       for (i = 0; i < num_changes && i < FIELDS_NUM - 1; i++) {
+       for (i = 0; i < num_changes && i <= USER_FIELD_LAST; i++) {
                const char *fldname;
 
-               testfld = (random() % (FIELDS_NUM - 1)) + 1;
+               testfld = (random() % USER_FIELD_LAST) + 1;
 
                gettimeofday(&now, NULL);
 
@@ -444,7 +444,7 @@ bool torture_usermod(struct torture_context *torture)
                goto done;
        }
 
-       for (i = 1; i < FIELDS_NUM; i++) {
+       for (i = USER_FIELD_FIRST; i <= USER_FIELD_LAST; i++) {
                struct libnet_rpc_usermod m;
 
                if (!test_usermod(torture, p, mem_ctx, &h, i, &m, &name)) {
index 19d56415b3c11f2eba7571613dbd0087b83b4c75..aecec538dd6e7439ef1731a28494222218c9b39f 100644 (file)
        }
 
 
-#define FIELDS_NUM 11
-enum test_fields { none = 0, account_name, full_name, description, home_directory, home_drive,
+#define USER_FIELD_FIRST       account_name
+#define USER_FIELD_LAST        acct_flags
+
+enum test_fields { none = 0,
+                  account_name, full_name, description, home_directory, home_drive,
                   comment, logon_script, profile_path, acct_expiry, acct_flags };