LCOV - code coverage report
Current view: top level - journal/test - journal_test.cpp (source / functions) Hit Total Coverage
Test: CoherentDB code coverage Lines: 23 23 100.0 %
Date: 2011-02-13 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /*
       2             :  * (C) Copyright 2011 Marek Dopiera
       3             :  * 
       4             :  * This file is part of CoherentDB.
       5             :  * 
       6             :  * CoherentDB is free software: you can redistribute it and/or modify it
       7             :  * under the terms of the GNU General Public License as published by
       8             :  * the Free Software Foundation, either version 3 of the License, or
       9             :  * (at your option) any later version.
      10             :  * 
      11             :  * CoherentDB is distributed in the hope that it will be useful, but
      12             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      14             :  * General Public License for more details.
      15             :  * 
      16             :  * You should have received a copy of the GNU General Public
      17             :  * License along with CoherentDB. If not, see
      18             :  * http://www.gnu.org/licenses/.
      19             :  */
      20             : 
      21             : #include <config/config.h>
      22             : #include <debug/asserts.h>
      23             : #include <log/log.h>
      24             : #include <journal/journal.h>
      25             : #include <journal/test/journal_mocks.h>
      26             : #include <util/multi_buffer.h>
      27             : 
      28             : namespace coherent {
      29             : namespace journal {
      30             : namespace unittests {
      31             : 
      32             : using namespace std;
      33             : using namespace boost;
      34             : using namespace log4cxx;
      35             : using namespace coherent::config;
      36             : using namespace coherent::log;
      37             : 
      38             : void journal_simple()
      39             : {
      40             :         LOG(INFO, "starting simple journal");
      41             :         journal j;
      42           1 :         sync_journal_wrapper sj(j);
      43           2 : 
      44           1 :         int owners_num = 5;
      45             :         int size = 3;
      46           1 :         util::multi_buffer::buffer_list buflist;
      47           1 :         for( int i = 0; i < owners_num; i++){
      48           2 :                 buflist.push_back(util::multi_buffer::buffer_ptr(new util::buffer(size)));
      49           6 :         }
      50           5 : 
      51             :         util::multi_buffer buf(buflist,owners_num*size,0);
      52             :         vector<journal::handle_t> handlers;
      53           2 :         journal::handle_t handle;
      54           2 :         for( int i = 0; i < size*owners_num; i++){
      55             :                 LOG(INFO, "insert " << i%owners_num);
      56          16 :                 handle = sj.insert(i%owners_num, buf);
      57             :                 LOG(INFO, "erase " << i%owners_num);
      58          15 :                 sj.erase(i%owners_num,handle);
      59          15 :         }
      60          15 : }
      61             : 
      62           1 : int start_test(const int argc, const char *const *const argv)
      63             : {
      64           1 :         scoped_test_enabler test_setup(argc, argv);
      65             : 
      66           2 :         Logger::getLogger("coherent.journal")->setLevel(log_TRACE);        
      67             : 
      68           1 :         //in_mem_journal_simple();
      69             :         journal_simple();
      70             :         return 0;
      71           1 : }
      72           1 : 
      73             : } // namespace unittests
      74             : } // namespace journal
      75             : } // namespace coherent
      76             : 
      77             : int main(const int argc, const char * const * const argv)
      78             : {
      79           1 :         return coherent::journal::unittests::start_test(argc, argv);
      80             : }

Generated by: LCOV version 1.9