2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Kyungwook Tak <k.tak@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
19 * @author Maciej Karpiuk (m.karpiuk2@samsung.com)
25 #include <test_common.h>
26 #include <ckm/ckm-type.h>
27 #include <protocols.h>
33 DBFixture(const char *db_fname);
35 constexpr static const char *m_default_name = "name";
36 constexpr static const char *m_default_owner = "label";
38 // ::::::::::::::::::::::::: helper methods :::::::::::::::::::::::::
39 static void generate_name(unsigned int id, CKM::Name &output);
40 static void generate_owner(unsigned int id, CKM::ClientId &output);
41 static CKM::DB::Row create_default_row(CKM::DataType type =
42 CKM::DataType::BINARY_DATA);
43 static CKM::DB::Row create_default_row(const CKM::Name &name,
44 const CKM::ClientId &owner,
45 CKM::DataType type = CKM::DataType::BINARY_DATA);
46 static void compare_row(const CKM::DB::Row &lhs, const CKM::DB::Row &rhs);
48 // ::::::::::::::::::::::::: time measurement :::::::::::::::::::::::::
49 void performance_start(const char *operation_name);
50 void performance_stop(long num_operations_performed);
52 // ::::::::::::::::::::::::: DB :::::::::::::::::::::::::
53 void generate_perf_DB(unsigned int num_name, unsigned int names_per_owner);
54 long add_full_access_rights(unsigned int num_name,
55 unsigned int num_names_per_owner);
56 void check_DB_integrity(const CKM::DB::Row &rowPattern);
58 void insert_row(const CKM::Name &name, const CKM::ClientId &owner);
59 void delete_row(const CKM::Name &name, const CKM::ClientId &owner);
60 void add_permission(const CKM::Name &name, const CKM::ClientId &owner,
61 const CKM::ClientId &accessor);
62 void read_row_expect_success(const CKM::Name &name,
63 const CKM::ClientId &owner);
69 double performance_get_time_elapsed_ms();
71 constexpr static const char *m_crypto_db_fname = "/tmp/testme.db";
72 std::string m_operation;
73 std::chrono::high_resolution_clock::time_point m_start_time, m_end_time;