Ignore:
Timestamp:
Apr 9, 2010, 3:51:41 PM (15 years ago)
Author:
Silvan Scherrer
Message:

Samba 3.5.x: trunk update to 3.5.2

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/torture/torture.c

    r414 r429  
    70327032}
    70337033
     7034static bool dbtrans_inc(struct db_context *db)
     7035{
     7036        struct db_record *rec;
     7037        uint32_t *val;
     7038        bool ret = false;
     7039        NTSTATUS status;
     7040
     7041        rec = db->fetch_locked(db, db, string_term_tdb_data("transtest"));
     7042        if (rec == NULL) {
     7043                printf(__location__ "fetch_lock failed\n");
     7044                return false;
     7045        }
     7046
     7047        if (rec->value.dsize != sizeof(uint32_t)) {
     7048                printf(__location__ "value.dsize = %d\n",
     7049                       (int)rec->value.dsize);
     7050                goto fail;
     7051        }
     7052
     7053        val = (uint32_t *)rec->value.dptr;
     7054        *val += 1;
     7055
     7056        status = rec->store(rec, make_tdb_data((uint8_t *)val,
     7057                                               sizeof(uint32_t)),
     7058                            0);
     7059        if (!NT_STATUS_IS_OK(status)) {
     7060                printf(__location__ "store failed: %s\n",
     7061                       nt_errstr(status));
     7062                goto fail;
     7063        }
     7064
     7065        ret = true;
     7066fail:
     7067        TALLOC_FREE(rec);
     7068        return ret;
     7069}
     7070
     7071static bool run_local_dbtrans(int dummy)
     7072{
     7073        struct db_context *db;
     7074        struct db_record *rec;
     7075        NTSTATUS status;
     7076        uint32_t initial;
     7077        int res;
     7078
     7079        db = db_open(talloc_tos(), "transtest.tdb", 0, TDB_DEFAULT,
     7080                     O_RDWR|O_CREAT, 0600);
     7081        if (db == NULL) {
     7082                printf("Could not open transtest.db\n");
     7083                return false;
     7084        }
     7085
     7086        res = db->transaction_start(db);
     7087        if (res == -1) {
     7088                printf(__location__ "transaction_start failed\n");
     7089                return false;
     7090        }
     7091
     7092        rec = db->fetch_locked(db, db, string_term_tdb_data("transtest"));
     7093        if (rec == NULL) {
     7094                printf(__location__ "fetch_lock failed\n");
     7095                return false;
     7096        }
     7097
     7098        if (rec->value.dptr == NULL) {
     7099                initial = 0;
     7100                status = rec->store(
     7101                        rec, make_tdb_data((uint8_t *)&initial,
     7102                                           sizeof(initial)),
     7103                        0);
     7104                if (!NT_STATUS_IS_OK(status)) {
     7105                        printf(__location__ "store returned %s\n",
     7106                               nt_errstr(status));
     7107                        return false;
     7108                }
     7109        }
     7110
     7111        TALLOC_FREE(rec);
     7112
     7113        res = db->transaction_commit(db);
     7114        if (res == -1) {
     7115                printf(__location__ "transaction_commit failed\n");
     7116                return false;
     7117        }
     7118
     7119        while (true) {
     7120                uint32_t val, val2;
     7121                int i;
     7122
     7123                res = db->transaction_start(db);
     7124                if (res == -1) {
     7125                        printf(__location__ "transaction_start failed\n");
     7126                        break;
     7127                }
     7128
     7129                if (!dbwrap_fetch_uint32(db, "transtest", &val)) {
     7130                        printf(__location__ "dbwrap_fetch_uint32 failed\n");
     7131                        break;
     7132                }
     7133
     7134                for (i=0; i<10; i++) {
     7135                        if (!dbtrans_inc(db)) {
     7136                                return false;
     7137                        }
     7138                }
     7139
     7140                if (!dbwrap_fetch_uint32(db, "transtest", &val2)) {
     7141                        printf(__location__ "dbwrap_fetch_uint32 failed\n");
     7142                        break;
     7143                }
     7144
     7145                if (val2 != val + 10) {
     7146                        printf(__location__ "val=%d, val2=%d\n",
     7147                               (int)val, (int)val2);
     7148                        break;
     7149                }
     7150
     7151                printf("val2=%d\r", val2);
     7152
     7153                res = db->transaction_commit(db);
     7154                if (res == -1) {
     7155                        printf(__location__ "transaction_commit failed\n");
     7156                        break;
     7157                }
     7158        }
     7159
     7160        TALLOC_FREE(db);
     7161        return true;
     7162}
    70347163
    70357164static double create_procs(bool (*fn)(int), bool *result)
     
    72067335        { "LOCAL-STREAM-NAME", run_local_stream_name, 0},
    72077336        { "LOCAL-WBCLIENT", run_local_wbclient, 0},
     7337        { "LOCAL-DBTRANS", run_local_dbtrans, 0},
    72087338        {NULL, NULL, 0}};
    72097339
     
    73187448
    73197449        load_case_tables();
     7450
     7451        setup_logging("smbtorture", true);
    73207452
    73217453        if (is_default_dyn_CONFIGFILE()) {
Note: See TracChangeset for help on using the changeset viewer.