LTP GCOV extension - code coverage report
Current view: directory - src/tmc - tmc_ipc.c
Test: min.info
Date: 2009-06-18 Instrumented lines: 56
Code covered: 69.6 % Executed lines: 39

       1                 : /*
       2                 :  * This file is part of MIN Test Framework. Copyright © 2008 Nokia Corporation
       3                 :  * and/or its subsidiary(-ies).
       4                 :  * Contact: Konrad Marek Zapalowicz
       5                 :  * Contact e-mail: DG.MIN-Support@nokia.com
       6                 :  * 
       7                 :  * This program is free software: you can redistribute it and/or modify it 
       8                 :  * under the terms of the GNU General Public License as published by the Free 
       9                 :  * Software Foundation, version 2 of the License. 
      10                 :  * 
      11                 :  * This program is distributed in the hope that it will be useful, but WITHOUT 
      12                 :  * ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or 
      13                 :  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General  Public License for
      14                 :  * more details. You should have received a copy of the GNU General Public 
      15                 :  * License along with this program. If not,  see 
      16                 :  * <http://www.gnu.org/licenses/>.
      17                 :  */
      18                 : 
      19                 : 
      20                 : /**
      21                 :  *  @file       tmc_msgipc.c
      22                 :  *  @version    0.1
      23                 :  *  @brief      This file contains implementation of the TMC IPC part.
      24                 :  */
      25                 : 
      26                 : /* ------------------------------------------------------------------------- */
      27                 : /* INCLUDE FILES */
      28                 : #include <tmc_ipc.h>
      29                 : 
      30                 : /* ------------------------------------------------------------------------- */
      31                 : /* EXTERNAL DATA STRUCTURES */
      32                 : /* None */
      33                 : 
      34                 : /* ------------------------------------------------------------------------- */
      35                 : /* EXTERNAL GLOBAL VARIABLES */
      36                 : /* None */
      37                 : 
      38                 : /* ------------------------------------------------------------------------- */
      39                 : /* EXTERNAL FUNCTION PROTOTYPES */
      40                 : /* None */
      41                 : 
      42                 : /* ------------------------------------------------------------------------- */
      43                 : /* GLOBAL VARIABLES */
      44                 : /* None */
      45                 : 
      46                 : /* ------------------------------------------------------------------------- */
      47                 : /* CONSTANTS */
      48                 : /* None */
      49                 : 
      50                 : /* ------------------------------------------------------------------------- */
      51                 : /* MACROS */
      52                 : /* None */
      53                 : 
      54                 : /* ------------------------------------------------------------------------- */
      55                 : /* LOCAL GLOBAL VARIABLES */
      56                 : /* None */
      57                 : 
      58                 : /* ------------------------------------------------------------------------- */
      59                 : /* LOCAL CONSTANTS AND MACROS */
      60                 : /* None */
      61                 : 
      62                 : /* ------------------------------------------------------------------------- */
      63                 : /* MODULE DATA STRUCTURES */
      64                 : /* None */
      65                 : 
      66                 : /* ------------------------------------------------------------------------- */
      67                 : /* LOCAL FUNCTION PROTOTYPES */
      68                 : /* None */
      69                 : 
      70                 : /* ------------------------------------------------------------------------- */
      71                 : /* FORWARD DECLARATIONS */
      72                 : /* None */
      73                 : 
      74                 : /* ==================== LOCAL FUNCTIONS ==================================== */
      75                 : /* None */
      76                 : 
      77                 : /* ======================== FUNCTIONS ====================================== */
      78                 : /* ------------------------------------------------------------------------- */
      79                 : /** Initializes TMC's inter process communication part
      80                 :  *  @param tmcipi adress of the TMC's inter process communication entity.
      81                 :  *  @param receiver PID of the process to which messages will be adressed to.
      82                 :  *
      83                 :  *  Fills TMCIPCInterface structure with default data.
      84                 :  */
      85                 : void ip_init (TMCIPCInterface * tmcipi, int receiver)
      86             194 : {
      87             194 :         if (tmcipi == INITPTR) {
      88               0 :                 MIN_ERROR ("TMCIPInterface is not initialized.");
      89               0 :                 return;
      90                 :         }
      91                 : 
      92             194 :         tmcipi->mqid_ = mq_open_queue ((int)'a');
      93             194 :         tmcipi->sender_ = getpid ();
      94             194 :         tmcipi->receiver_ = receiver;
      95                 : 
      96             194 :         tmcipi->in_.receiver_ = 0;
      97             194 :         tmcipi->in_.sender_ = 0;
      98             194 :         tmcipi->in_.type_ = 0;
      99             194 :         tmcipi->in_.param_ = 0;
     100             194 :         STRCPY (tmcipi->in_.desc_, "\0", MaxDescSize);
     101             194 :         STRCPY (tmcipi->in_.message_, "\0", MaxMsgSize);
     102                 : }
     103                 : 
     104                 : /* ------------------------------------------------------------------------- */
     105                 : /** Returns status of the initialization process.
     106                 :  *  @param tmcipi adress of the TMC's inter process communication entity.
     107                 :  *  @return 0 when init was successfull, -1 otherwise.
     108                 :  */
     109                 : int ip_status (const TMCIPCInterface * tmcipi)
     110             100 : {
     111             100 :         if (tmcipi->mqid_ == -1) {
     112               0 :                 MIN_ERROR ("TMCIPInterface is not initialized correctly.");
     113               0 :                 return -1;
     114                 :         }
     115                 :         else {
     116             100 :                 MIN_DEBUG ("TMCIPInterface is initialized correctly.");
     117             100 :                 return 0;
     118                 :         }
     119                 : }
     120                 : 
     121                 : /* ------------------------------------------------------------------------- */
     122                 : /** Sends MSG_OK message.
     123                 :  *  @param tmcipi adress of the TMC's inter process communication entity.
     124                 :  */
     125                 : void ip_send_ok (const TMCIPCInterface * tmcipi)
     126             100 : {
     127             100 :         if (tmcipi == INITPTR)
     128               0 :                 return;
     129                 : 
     130             100 :         mq_send_message2 (tmcipi->mqid_, tmcipi->receiver_, MSG_OK, 0,
     131                 :                           "MSG_OK");
     132                 : }
     133                 : 
     134                 : /* ------------------------------------------------------------------------- */
     135                 : /** Sends MSG_KO message.
     136                 :  *  @param tmcipi adress of the TMC's inter process communication entity.
     137                 :  *  @param errnum enumerated error value.
     138                 :  *  @param desc textual description of the error.
     139                 :  */
     140                 : void ip_send_ko (const TMCIPCInterface * tmcipi, int errnum, const char *desc)
     141               0 : {
     142               0 :         if (tmcipi == INITPTR) {
     143               0 :                 MIN_ERROR ("TMCIPInterface is not initialized");
     144               0 :                 return;
     145                 :         }
     146                 : 
     147               0 :         mq_send_message2 (tmcipi->mqid_, tmcipi->receiver_, MSG_KO, errnum,
     148                 :                           desc);
     149                 : }
     150                 : 
     151                 : /* ------------------------------------------------------------------------- */
     152                 : /** Sends MSG_TCD message.
     153                 :  *  @param tmcipi adress of the TMC's inter process communication entity.
     154                 :  *  @param file configuration file that was used to retrieve test cases.
     155                 :  *  @param it DLList iterator pointing on the beginning of the test cases list.
     156                 :  */
     157                 : void ip_send_tcd (const TMCIPCInterface * tmcipi, const char *file,
     158                 :                   DLListIterator it)
     159              95 : {
     160                 :         MsgBuffer       out;
     161              95 :         TestCaseInfo   *tci = INITPTR;
     162              95 :         if (tmcipi == INITPTR) {
     163               0 :                 MIN_ERROR ("TMCIPInterface is not initialized.");
     164               0 :                 return;
     165                 :         }
     166                 : 
     167              95 :         MIN_DEBUG ("%s:%s(%p,%s,%p)",__FILE__,__FUNCTION__,tmcipi,file,it);
     168                 : 
     169              95 :         out.receiver_ = tmcipi->receiver_;
     170              95 :         out.sender_ = tmcipi->sender_;
     171              95 :         out.type_ = MSG_TCD;
     172                 : 
     173             544 :         while (it != DLListNULLIterator) {
     174                 : 
     175             354 :                 tci = (TestCaseInfo *) dl_list_data (it);
     176             354 :                 if (tci != INITPTR) {
     177             354 :                         out.param_ = tci->id_;
     178             354 :                         STRCPY (out.desc_, file, MaxFileName);
     179             354 :                         STRCPY (out.message_, tci->name_, MaxTestCaseName);
     180             354 :                         mq_send_message (tmcipi->mqid_, &out);
     181                 :                 } else {
     182               0 :                         MIN_WARN ("Test Case not found on list.");
     183                 :                 }
     184             354 :                 it = dl_list_next (it);
     185                 :         }
     186                 : }
     187                 : 
     188                 : /* ------------------------------------------------------------------------- */
     189                 : /** Sends MSG_RET message.
     190                 :  *  @param tmcipi adress of the TMC's inter process communication entity.
     191                 :  *  @param result test case result, @see TPResult.
     192                 :  *  @param desc textual description of the test result
     193                 :  */
     194                 : void ip_send_ret (const TMCIPCInterface * tmcipi, int result,
     195                 :                   const char *desc)
     196             159 : {
     197             159 :         if (tmcipi == INITPTR) {
     198               0 :                 MIN_ERROR ("TMCIPInterface is not initialized");
     199               0 :                 return;
     200                 :         }
     201                 : 
     202             159 :         mq_send_message2 (tmcipi->mqid_, tmcipi->receiver_, MSG_RET, result,
     203                 :                           desc);
     204                 : 
     205                 : }
     206                 : 
     207                 : /* ------------------------------------------------------------------------- */
     208                 : /** Sends end mark for MSG_TCD transmission.
     209                 :  *  @param tmcipi adress of the TMC's inter process communication entity.
     210                 :  */
     211                 : void ip_send_eotcd (const TMCIPCInterface * tmcipi)
     212             100 : {
     213             100 :         if (tmcipi == INITPTR) {
     214               0 :                 MIN_ERROR ("TMCIPInterface is not initialized");
     215               0 :                 return;
     216                 :         }
     217                 : 
     218             100 :         mq_send_message2 (tmcipi->mqid_, tmcipi->receiver_, MSG_TCD, 0, "\0");
     219                 : }
     220                 : 
     221                 : 
     222                 : 
     223                 : /* ------------------------------------------------------------------------- */
     224                 : /* ================= OTHER EXPORTED FUNCTIONS ============================== */
     225                 : /* None */
     226                 : 
     227                 : /* ------------------------------------------------------------------------- */
     228                 : /* ================= TESTS FOR LOCAL FUNCTIONS ============================= */
     229                 : /* None */
     230                 : 
     231                 : /* ------------------------------------------------------------------------- */
     232                 : /* End of file */

Generated by: LTP GCOV extension version 1.6