1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2016 Red Hat
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include <gtest/gtest.h>
16 #include "osd/PGTransaction.h"
18 TEST(pgtransaction, simple)
22 ASSERT_TRUE(t.empty());
24 ASSERT_FALSE(t.empty());
26 t.safe_create_traverse(
27 [&](const pair<const hobject_t, PGTransaction::ObjectOperation> &p) {
28 ASSERT_EQ(p.first, h);
29 using T = PGTransaction::ObjectOperation::Init;
30 ASSERT_TRUE(boost::get<T::None>(&p.second.init_type));
36 TEST(pgtransaction, clone_safe_create_traverse)
41 ASSERT_TRUE(t.empty());
43 ASSERT_FALSE(t.empty());
46 t.safe_create_traverse(
47 [&](const pair<const hobject_t, PGTransaction::ObjectOperation> &p) {
48 using T = PGTransaction::ObjectOperation::Init;
50 ASSERT_EQ(p.first, h);
51 ASSERT_TRUE(boost::get<T::Clone>(&p.second.init_type));
53 boost::get<T::Clone>(&p.second.init_type)->source,
55 } else if (num == 1) {
56 ASSERT_EQ(p.first, h2);
57 ASSERT_TRUE(boost::get<T::None>(&p.second.init_type));
65 TEST(pgtransaction, clone_safe_create_traverse2)
72 ASSERT_TRUE(t.empty());
74 ASSERT_FALSE(t.empty());
79 t.safe_create_traverse(
80 [&](const pair<const hobject_t, PGTransaction::ObjectOperation> &p) {
81 using T = PGTransaction::ObjectOperation::Init;
83 ASSERT_EQ(p.first, h);
84 ASSERT_TRUE(boost::get<T::Clone>(&p.second.init_type));
86 boost::get<T::Clone>(&p.second.init_type)->source,
88 } else if (num == 1) {
89 ASSERT_EQ(p.first, h2);
90 ASSERT_TRUE(boost::get<T::Clone>(&p.second.init_type));
92 boost::get<T::Clone>(&p.second.init_type)->source,
94 } else if (num == 2) {
95 ASSERT_EQ(p.first, h3);
96 ASSERT_TRUE(boost::get<T::None>(&p.second.init_type));
104 TEST(pgtransaction, clone_safe_create_traverse3)
115 t.safe_create_traverse(
116 [&](const pair<const hobject_t, PGTransaction::ObjectOperation> &p) {
117 using T = PGTransaction::ObjectOperation::Init;
119 ASSERT_TRUE(p.second.is_delete());
120 } else if (p.first == h2) {
121 ASSERT_TRUE(boost::get<T::Clone>(&p.second.init_type));
123 boost::get<T::Clone>(&p.second.init_type)->source,