/Users/deen/code/yugabyte-db/src/yb/encryption/encryption_test_util.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) YugaByte, Inc. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
4 | | // in compliance with the License. You may obtain a copy of the License at |
5 | | // |
6 | | // http://www.apache.org/licenses/LICENSE-2.0 |
7 | | // |
8 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
9 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
10 | | // or implied. See the License for the specific language governing permissions and limitations |
11 | | // under the License. |
12 | | // |
13 | | |
14 | | #ifndef YB_ENCRYPTION_ENCRYPTION_TEST_UTIL_H |
15 | | #define YB_ENCRYPTION_ENCRYPTION_TEST_UTIL_H |
16 | | |
17 | | #include "yb/encryption/encryption_util.h" |
18 | | |
19 | | #include "yb/util/slice.h" |
20 | | #include "yb/util/test_util.h" |
21 | | |
22 | | namespace yb { |
23 | | namespace encryption { |
24 | | |
25 | | void DoTest(const std::function<void(size_t, size_t)>& file_op, size_t size); |
26 | | |
27 | | template <typename Writable> |
28 | 2 | void TestWrites(Writable* file, const Slice& data) { |
29 | 22 | DoTest([&](size_t begin, size_t end) { |
30 | 22 | ASSERT_OK(file->Append(Slice(data.data() + begin, end - begin))); |
31 | 22 | }, data.size()); _ZZN2yb10encryption10TestWritesINS_12WritableFileEEEvPT_RKNS_5SliceEENKUlmmE_clEmm Line | Count | Source | 29 | 22 | DoTest([&](size_t begin, size_t end) { | 30 | 22 | ASSERT_OK(file->Append(Slice(data.data() + begin, end - begin))); | 31 | 22 | }, data.size()); |
Unexecuted instantiation: _ZZN2yb10encryption10TestWritesIN7rocksdb12WritableFileEEEvPT_RKNS_5SliceEENKUlmmE_clEmm |
32 | 2 | } _ZN2yb10encryption10TestWritesINS_12WritableFileEEEvPT_RKNS_5SliceE Line | Count | Source | 28 | 2 | void TestWrites(Writable* file, const Slice& data) { | 29 | 2 | DoTest([&](size_t begin, size_t end) { | 30 | 2 | ASSERT_OK(file->Append(Slice(data.data() + begin, end - begin))); | 31 | 2 | }, data.size()); | 32 | 2 | } |
Unexecuted instantiation: _ZN2yb10encryption10TestWritesIN7rocksdb12WritableFileEEEvPT_RKNS_5SliceE |
33 | | |
34 | | template <typename BufType, typename Readable> |
35 | 2 | void TestRandomAccessReads(Readable* file, const Slice& data) { |
36 | 2 | auto buf = static_cast<BufType*>(EncryptionBuffer::Get()->GetBuffer(data.size())); |
37 | 22 | DoTest([&](size_t begin, size_t end) { |
38 | 22 | Slice result; |
39 | 22 | ASSERT_OK(file->Read(begin, end - begin, &result, buf)); |
40 | 22 | ASSERT_EQ(result.ToDebugHexString(), |
41 | 22 | Slice(data.data() + begin, end - begin).ToDebugHexString()); |
42 | 22 | }, data.size()); |
43 | 2 | } |
44 | | |
45 | | template <typename BufType, typename Readable> |
46 | 0 | void TestSequentialReads(Readable* file, const Slice& data) { |
47 | 0 | DoTest([&](size_t begin, size_t end) { |
48 | 0 | auto buf = static_cast<BufType*>(EncryptionBuffer::Get()->GetBuffer(data.size())); |
49 | 0 | Slice result; |
50 | 0 | ASSERT_OK(file->Read(end - begin, &result, buf)); |
51 | 0 | ASSERT_EQ(result.ToDebugHexString(), |
52 | 0 | Slice(data.data() + begin, end - begin).ToDebugHexString()); |
53 | 0 | }, data.size()); |
54 | 0 | } |
55 | | |
56 | | } // namespace encryption |
57 | | } // namespace yb |
58 | | |
59 | | #endif // YB_ENCRYPTION_ENCRYPTION_TEST_UTIL_H |