LCOV - code coverage report
Current view: directory - src/trusted/gdb_rsp - target_test.cc (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 22 18 81.8 %
Date: 2012-02-16 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright 2010 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can
       4                 :  * be found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : #include <assert.h>
       8                 : #include <stdio.h>
       9                 : #include <stdlib.h>
      10                 : #include <string.h>
      11                 : 
      12                 : #include <string>
      13                 : #include <sstream>
      14                 : #include <vector>
      15                 : 
      16                 : #include "native_client/src/trusted/gdb_rsp/abi.h"
      17                 : #include "native_client/src/trusted/gdb_rsp/session_mock.h"
      18                 : #include "native_client/src/trusted/gdb_rsp/target.h"
      19                 : #include "native_client/src/trusted/gdb_rsp/test.h"
      20                 : 
      21                 : using gdb_rsp::Abi;
      22                 : using gdb_rsp::SessionMock;
      23                 : using gdb_rsp::Target;
      24                 : 
      25               1 : int TestTarget() {
      26               1 :   int errs = 0;
      27                 : 
      28               1 :   SessionMock *ses = gdb_rsp::GetGoldenSessionMock(true, false);
      29               1 :   const gdb_rsp::Abi* abi = gdb_rsp::Abi::Get();
      30                 : 
      31               1 :   Target *target = new Target(NULL);
      32               1 :   if (!target->Init()) {
      33               0 :     printf("Failed to INIT target.\n");
      34               0 :     return 1;
      35                 :   }
      36                 : 
      37                 :   // Create a pseudo thread with registers set to their index
      38               1 :   port::IThread *thread = port::IThread::Acquire(0x1234, true);
      39              17 :   for (uint32_t a = 0; a < abi->GetRegisterCount(); a++) {
      40              16 :     const Abi::RegDef* def = abi->GetRegisterDef(a);
      41              16 :     uint64_t val = static_cast<uint64_t>(a);
      42              16 :     thread->SetRegister(a, &val, def->bytes_);
      43                 :   }
      44               1 :   target->TrackThread(thread);
      45                 : 
      46                 :   // Pretend we just got a signal on that thread
      47               1 :   target->Signal(thread->GetId(), 5, false);
      48                 : 
      49                 :   // Run the session to completion.
      50               1 :   target->Run(ses);
      51                 : 
      52               1 :   if (ses->PeekAction() != SessionMock::DISCONNECT) {
      53               0 :     printf("We did not consume all the actions.\n");
      54               0 :     errs++;
      55                 :   }
      56                 : 
      57               1 :   delete target;
      58               1 :   delete ses;
      59               1 :   return errs;
      60                 : }
      61                 : 

Generated by: LCOV version 1.7