} END_TEST START_TEST(c_dp_set_n_too_high_3) { dp_context_t* ctx = dp_create(); ck_assert(dp_set_epsilon(ctx, 2872) == 1); dp_destroy(ctx); } END_TEST
int VOLSER_AFSVolPartitionInfo(struct rx_call *call, const char *name, struct diskPartition *partition) { int num; struct dp_part *dp; int ret = 0; mlog_log(MDEBVOLDB, "VOLSER_AFSVolPartitionInfo"); num = partition_name2num (name); if (num == -1) { ret = VOLSERILLEGAL_PARTITION; goto out; } ret = dp_create (num, &dp); if (ret) goto out; memset(partition, 0, sizeof(*partition)); strlcpy(partition->name, dp->part, 32); partition->free = 1000; dp_free(dp); out: VOLSER_EXIT; return ret; }
} END_TEST START_TEST(c_dp_set_n_too_low_2) { dp_context_t* ctx = dp_create(); ck_assert(dp_set_epsilon(ctx, -100000) == -1); dp_destroy(ctx); } END_TEST
static int volser_fetch_vh (int32_t partition, int32_t volid, struct dp_part **dp, volume_handle **vh) { int ret; ret = dp_create (partition, dp); if (ret) { fprintf (stderr, "volser_fetch_vh: dp_create: %d\n", ret); return VOLSERILLEGAL_PARTITION; } ret = vld_open_volume_by_num (*dp, volid, vh); if (ret) { fprintf (stderr, "volser_fetch_vh: vld_open_volume_by_num: %d\n", ret); dp_free (*dp); if (ret == ENOENT) return VNOVOL; return ret; } ret = vld_info_uptodatep (*vh); if (ret) { printf ("volser_fetch_vh: vld_info_uptodatep: %d\n", ret); vld_free (*vh); dp_free (*dp); return VOLSERFAILEDOP; /* XXX */ } return 0; }
int VOLSER_AFSVolListVolumes(struct rx_call *call, const int32_t partID, const int32_t flags, volEntries *resultEntries) { int ret = 0; List *vollist; Listitem *item; volume_handle *vh; struct dp_part *dp; int numvol; int i; mlog_log(MDEBVOLDB, "VOLSER_AFSVolListVolumes"); ret = dp_create (partID, &dp); if (ret) goto out; ret = vld_list_volumes(dp, &vollist); if (ret) goto free_part; numvol = 0; item = listhead(vollist); while (item) { numvol++; item = listnext(vollist, item); } resultEntries->len = numvol; resultEntries->val = calloc(sizeof(struct volintInfo) * resultEntries->len, 1); i = 0; while (!listemptyp(vollist)) { vh = (volume_handle *) listdelhead(vollist); assert(vh); ret = vld_info_uptodatep (vh); assert(ret == 0); copy_volumeinfo(&resultEntries->val[i], vh, partID); vld_free (vh); i++; } free(vollist); free_part: dp_free (dp); out: VOLSER_EXIT; return ret; }
} END_TEST START_TEST(c_dp_set_n_epsilon_3) { dp_context_t* ctx = dp_create(); dp_set_n(ctx, 9); dp_set_epsilon(ctx, 0.8); ck_assert(9 == ctx->n); ck_assert(0.8 == ctx->epsilon); ck_assert(GEOM_EQ(1.5518455739153598, ctx->step)); dp_destroy(ctx); } END_TEST
} END_TEST START_TEST(c_dp_set_n_epsilon_2) { dp_context_t* ctx = dp_create(); dp_set_n(ctx, 1279); dp_set_epsilon(ctx, 0.2); ck_assert(1279 == ctx->n); ck_assert(0.2 == ctx->epsilon); ck_assert(GEOM_EQ(305.8415144851744, ctx->step)); dp_destroy(ctx); } END_TEST
} END_TEST START_TEST(c_dp_set_n_epsilon_1) { dp_context_t* ctx = dp_create(); dp_set_n(ctx, 32); dp_set_epsilon(ctx, 0.5); ck_assert(32 == ctx->n); ck_assert(0.5 == ctx->epsilon); ck_assert(GEOM_EQ(5.656854249492381, ctx->step)); dp_destroy(ctx); } END_TEST
int VOLSER_AFSVolCreateVolume(struct rx_call *call, const int32_t partition, const char *name, const int32_t type, const int32_t parent, int32_t *volid, int32_t *trans) { int ret = 0; int32_t backstoretype = VLD_SVOL; struct dp_part *dp; mlog_log(MDEBVOLDB, "VOLSER_AFSVolCreateVolume" " part %d name %s type %d parent %d volid %u", partition, name, type, parent, *volid); if (!sec_is_superuser(call)) { ret = VOLSERBAD_ACCESS; goto out; } /* XXX parent should be used */ ret = vld_create_trans (partition, *volid, trans); if (ret) goto out; ret = vld_trans_set_iflags (*trans, ITCreate); if (ret) goto out; ret = dp_create (partition, &dp); if (ret) { vld_end_trans (*trans, NULL); goto out; } ret = vld_create_volume (dp, *volid, name, backstoretype, type, 0); if (ret) { vld_end_trans (*trans, NULL); goto out; } out: VOLSER_EXIT; return ret; }
int VOLSER_AFSVolDeleteVolume(struct rx_call *call, const int32_t transid) { int ret = 0; int32_t backstoretype = VLD_SVOL; struct trans *trans; struct dp_part *dp; mlog_log(MDEBVOLDB, "VOLSER_AFSVolDeleteVolume"); if (!sec_is_superuser(call)) { ret = VOLSERBAD_ACCESS; goto out; } ret = vld_verify_trans(transid); if (ret) goto out; ret = vld_get_trans(transid, &trans); if (ret) goto out; ret = dp_create (trans->partition, &dp); if (ret) { vld_put_trans (trans); goto out; } ret = vld_delete_volume (dp, trans->volid, backstoretype, 0); vld_put_trans(trans); out: VOLSER_EXIT; return ret; }
int vld_init (void) { struct dp_part *dp; int ret, partnum, i; db_lru = listnew(); if (db_lru == NULL) errx (1, "vld_init: db_lru == NULL"); for (i = 0; i < 100 /* XXX */ ; i++) listaddhead (db_lru, NULL); vol_list = listnew(); if (vol_list == NULL) errx (1, "vld_init: vol_list == NULL"); volume_htab = hashtabnew(volume_htab_sz, volume_cmp, volume_hash); if (volume_htab == NULL) errx (1, "vld_init: volume_htab == NULL"); for (partnum = 0; partnum < 'z'-'a'; partnum++) { ret = dp_create (partnum , &dp); if (ret) { warnx ("vld_init: dp_create(%d) returned %d", partnum, ret); continue; } ret = dp_findvol (dp, register_vols_cb, dp); if (ret) warnx ("vld_init: dp_findvol returned: %d", ret); dp_free (dp); } return 0; }
} END_TEST START_TEST(c_dp_add_many_large_templates) { dp_context_t* ctx = dp_create(); // add several templates for a rectangle. const int num = 4; const char* fnames[] = { "data/rect1.stroke.srz", "data/rect2.stroke.srz", "data/rect3.stroke.srz", "data/rect4.stroke.srz" }; for (int i = 0; i < num; i++) { if (_add_to_template(ctx, fnames[i], "rectangle")) { dp_destroy(ctx); ck_abort_msg("Could not load stroke."); } } debug("Destroying context: %p\n", ctx); dp_destroy(ctx); } END_TEST