]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/osd/TestECBackend.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / test / osd / TestECBackend.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2013 Inktank Storage, Inc.
7 *
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.
12 *
13 */
14
15 #include <iostream>
16 #include <sstream>
17 #include <errno.h>
18 #include <signal.h>
19 #include "osd/ECBackend.h"
20 #include "gtest/gtest.h"
21
22 using namespace std;
23
24 TEST(ECUtil, stripe_info_t)
25 {
26 const uint64_t swidth = 4096;
27 const uint64_t ssize = 4;
28
29 ECUtil::stripe_info_t s(ssize, swidth);
30 ASSERT_EQ(s.get_stripe_width(), swidth);
31
32 ASSERT_EQ(s.logical_to_next_chunk_offset(0), 0u);
33 ASSERT_EQ(s.logical_to_next_chunk_offset(1), s.get_chunk_size());
34 ASSERT_EQ(s.logical_to_next_chunk_offset(swidth - 1),
35 s.get_chunk_size());
36
37 ASSERT_EQ(s.logical_to_prev_chunk_offset(0), 0u);
38 ASSERT_EQ(s.logical_to_prev_chunk_offset(swidth), s.get_chunk_size());
39 ASSERT_EQ(s.logical_to_prev_chunk_offset((swidth * 2) - 1),
40 s.get_chunk_size());
41
42 ASSERT_EQ(s.logical_to_next_stripe_offset(0), 0u);
43 ASSERT_EQ(s.logical_to_next_stripe_offset(swidth - 1),
44 s.get_stripe_width());
45
46 ASSERT_EQ(s.logical_to_prev_stripe_offset(swidth), s.get_stripe_width());
47 ASSERT_EQ(s.logical_to_prev_stripe_offset(swidth), s.get_stripe_width());
48 ASSERT_EQ(s.logical_to_prev_stripe_offset((swidth * 2) - 1),
49 s.get_stripe_width());
50
51 ASSERT_EQ(s.aligned_logical_offset_to_chunk_offset(2*swidth),
52 2*s.get_chunk_size());
53 ASSERT_EQ(s.aligned_chunk_offset_to_logical_offset(2*s.get_chunk_size()),
54 2*s.get_stripe_width());
55
56 ASSERT_EQ(s.aligned_offset_len_to_chunk(make_pair(swidth, 10*swidth)),
57 make_pair(s.get_chunk_size(), 10*s.get_chunk_size()));
58
59 ASSERT_EQ(s.offset_len_to_stripe_bounds(make_pair(swidth-10, (uint64_t)20)),
60 make_pair((uint64_t)0, 2*swidth));
61 }
62