Skip to content

Commit

Permalink
tests: add case for PROPTAG_ARRAY::transform
Browse files Browse the repository at this point in the history
References: DESK-2209
  • Loading branch information
jengelh committed Oct 12, 2024
1 parent 41cd1a7 commit 291edd7
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion tests/exrpctest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This file is part of Gromox.
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <gromox/exmdb_client.hpp>
#include <gromox/exmdb_rpc.hpp>
#include <gromox/paths.h>
Expand All @@ -15,6 +16,42 @@ namespace exmdb_client = exmdb_client_remote;

static alloc_context g_alloc_mgr;

static int t_2209(const char *dir)
{
static constexpr uint64_t v_zero = 0;
static constexpr BINARY v_binzero = {0, {.pc = deconst("")}};
const TAGGED_PROPVAL pvd[] = {
{PR_COMMENT, deconst("acomment")},
};
TAGGED_PROPVAL qvd[std::size(pvd)+4]{};
const TPROPVAL_ARRAY pvals = {std::size(pvd), deconst(pvd)};
TPROPVAL_ARRAY qvals = {0, deconst(qvd)};
std::vector<uint16_t> original_indices;
PROBLEM_ARRAY problems{};

for (size_t i = 0; i < pvals.count; ++i) {
const auto &pv = pvals.ppropval[i];
if (pv.proptag == PR_ACCESS) {
problems.emplace_back(i, pv.proptag, ecAccessDenied);
} else {
qvals.ppropval[qvals.count++] = pv;
original_indices.push_back(i);
}
}
qvals.emplace_back(PidTagChangeNumber, &v_zero);
qvals.emplace_back(PR_CHANGE_KEY, &v_binzero);
qvals.emplace_back(PR_PREDECESSOR_CHANGE_LIST, &v_binzero);
qvals.emplace_back(PROP_TAG(PT_I8, 0), &v_zero);

if (!exmdb_client::set_folder_properties(dir, CP_UTF8,
rop_util_make_eid_ex(1, PRIVATE_FID_ROOT), &qvals, &problems)) {
mlog(LV_ERR, "set_folder_properties failed unexpectedly");
return EXIT_FAILURE;
}
problems.transform(original_indices);
return EXIT_SUCCESS;
}

int main(int argc, char **argv)
{
exmdb_rpc_alloc = [](size_t z) { return g_alloc_mgr.alloc(z); };
Expand Down Expand Up @@ -43,5 +80,6 @@ int main(int argc, char **argv)
TPROPVAL_ARRAY props{};
if (!exmdb_client::get_store_properties(g_storedir, CP_UTF8, &ptags, &props))
mlog(LV_ERR, "get_store_properties failed unexpectedly");
return 0;

return t_2209(g_storedir);
}

0 comments on commit 291edd7

Please sign in to comment.