LCOV - code coverage report
Current view: top level - testing - testing_api_cmd_signal.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 16 0.0 %
Date: 2025-06-05 21:03:14 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   (C) 2018 Taler Systems SA
       4             : 
       5             :   TALER is free software; you can redistribute it and/or modify
       6             :   it under the terms of the GNU General Public License as
       7             :   published by the Free Software Foundation; either version 3, or
       8             :   (at your option) any later version.
       9             : 
      10             :   TALER is distributed in the hope that it will be useful, but
      11             :   WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             :   GNU General Public License for more details.
      14             : 
      15             :   You should have received a copy of the GNU General Public
      16             :   License along with TALER; see the file COPYING.  If not, see
      17             :   <http://www.gnu.org/licenses/>
      18             : */
      19             : /**
      20             :  * @file testing/testing_api_cmd_signal.c
      21             :  * @brief command(s) to send signals to processes.
      22             :  * @author Marcello Stanisci
      23             :  */
      24             : #include "platform.h"
      25             : #include "taler_json_lib.h"
      26             : #include <gnunet/gnunet_curl_lib.h>
      27             : #include "taler_testing_lib.h"
      28             : 
      29             : 
      30             : /**
      31             :  * State for a "signal" CMD.
      32             :  */
      33             : struct SignalState
      34             : {
      35             :   /**
      36             :    * The process to send the signal to.
      37             :    */
      38             :   struct GNUNET_OS_Process *process;
      39             : 
      40             :   /**
      41             :    * The signal to send to the process.
      42             :    */
      43             :   int signal;
      44             : };
      45             : 
      46             : /**
      47             :  * Run the command.
      48             :  *
      49             :  * @param cls closure.
      50             :  * @param cmd the command to execute.
      51             :  * @param is the interpreter state.
      52             :  */
      53             : static void
      54           0 : signal_run (void *cls,
      55             :             const struct TALER_TESTING_Command *cmd,
      56             :             struct TALER_TESTING_Interpreter *is)
      57             : {
      58           0 :   struct SignalState *ss = cls;
      59             : 
      60           0 :   GNUNET_break (0 == GNUNET_OS_process_kill
      61             :                   (ss->process, ss->signal));
      62           0 :   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
      63             :               "Signaling '%d'..\n",
      64             :               ss->signal);
      65           0 :   TALER_TESTING_interpreter_next (is);
      66           0 : }
      67             : 
      68             : 
      69             : /**
      70             :  * Cleanup the state from a "signal" CMD.
      71             :  *
      72             :  * @param cls closure.
      73             :  * @param cmd the command which is being cleaned up.
      74             :  */
      75             : static void
      76           0 : signal_cleanup (void *cls,
      77             :                 const struct TALER_TESTING_Command *cmd)
      78             : {
      79           0 :   struct SignalState *ss = cls;
      80             : 
      81           0 :   GNUNET_free (ss);
      82           0 : }
      83             : 
      84             : 
      85             : /**
      86             :  * Create a "signal" CMD.
      87             :  *
      88             :  * @param label command label.
      89             :  * @param process handle to the process to signal.
      90             :  * @param signal signal to send.
      91             :  *
      92             :  * @return the command.
      93             :  */
      94             : struct TALER_TESTING_Command
      95           0 : TALER_TESTING_cmd_signal (const char *label,
      96             :                           struct GNUNET_OS_Process *process,
      97             :                           int signal)
      98             : {
      99             :   struct SignalState *ss;
     100             : 
     101           0 :   ss = GNUNET_new (struct SignalState);
     102           0 :   ss->process = process;
     103           0 :   ss->signal = signal;
     104             : 
     105             :   {
     106           0 :     struct TALER_TESTING_Command cmd = {
     107             :       .cls = ss,
     108             :       .label = label,
     109             :       .run = &signal_run,
     110             :       .cleanup = &signal_cleanup
     111             :     };
     112             : 
     113           0 :     return cmd;
     114             :   }
     115             : }

Generated by: LCOV version 1.16