LCOV - code coverage report
Current view: top level - app/fddev - dev1.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 58 0.0 %
Date: 2024-11-13 11:58:15 Functions: 0 5 0.0 %

          Line data    Source code
       1             : #define _GNU_SOURCE
       2             : #include "fddev.h"
       3             : 
       4             : #include "../fdctl/configure/configure.h"
       5             : #include "../fdctl/run/run.h"
       6             : 
       7             : #include <stdio.h>
       8             : #include <unistd.h>
       9             : #include <sched.h>
      10             : #include <sys/wait.h>
      11             : 
      12             : extern char fd_log_private_path[ 1024 ]; /* empty string on start */
      13             : 
      14           0 : #define FD_LOG_ERR_NOEXIT(a) do { long _fd_log_msg_now = fd_log_wallclock(); fd_log_private_1( 4, _fd_log_msg_now, __FILE__, __LINE__, __func__, fd_log_private_0 a ); } while(0)
      15             : 
      16             : extern int * fd_log_private_shared_lock;
      17             : 
      18             : static void
      19           0 : parent_signal( int sig ) {
      20             :   /* Same hack as in run.c, see comments there. */
      21           0 :   int lock = 0;
      22           0 :   fd_log_private_shared_lock = &lock;
      23             : 
      24           0 :   if( -1!=fd_log_private_logfile_fd() ) FD_LOG_ERR_NOEXIT(( "Received signal %s\nLog at \"%s\"", fd_io_strsignal( sig ), fd_log_private_path ));
      25           0 :   else                                  FD_LOG_ERR_NOEXIT(( "Received signal %s",                fd_io_strsignal( sig ) ));
      26             : 
      27           0 :   if( FD_LIKELY( sig==SIGINT ) ) exit_group( 128+SIGINT );
      28           0 :   else                           exit_group( 0          );
      29           0 : }
      30             : 
      31             : static void
      32           0 : install_parent_signals( void ) {
      33           0 :   struct sigaction sa = {
      34           0 :     .sa_handler = parent_signal,
      35           0 :     .sa_flags   = 0,
      36           0 :   };
      37           0 :   if( FD_UNLIKELY( sigaction( SIGTERM, &sa, NULL ) ) )
      38           0 :     FD_LOG_ERR(( "sigaction(SIGTERM) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      39           0 :   if( FD_UNLIKELY( sigaction( SIGINT, &sa, NULL ) ) )
      40           0 :     FD_LOG_ERR(( "sigaction(SIGINT) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      41           0 : }
      42             : 
      43             : void
      44             : dev1_cmd_args( int *    pargc,
      45             :                char *** pargv,
      46           0 :                args_t * args) {
      47           0 :   char * usage = "usage: dev1 <tile>";
      48           0 :   if( FD_UNLIKELY( *pargc < 1 ) ) FD_LOG_ERR(( "%s", usage ));
      49             : 
      50           0 :   strncpy( args->dev1.tile_name, *pargv[ 0 ], sizeof( args->dev1.tile_name ) - 1 );
      51             : 
      52           0 :   (*pargc)--;
      53           0 :   (*pargv)++;
      54             : 
      55           0 :   args->dev1.no_configure = fd_env_strip_cmdline_contains( pargc, pargv, "--no-configure" );
      56           0 : }
      57             : 
      58             : void
      59             : dev1_cmd_perm( args_t *         args,
      60             :                fd_caps_ctx_t *  caps,
      61           0 :                config_t * const config ) {
      62           0 :   dev_cmd_perm( args, caps, config );
      63           0 : }
      64             : 
      65             : void
      66             : dev1_cmd_fn( args_t *         args,
      67           0 :              config_t * const config ) {
      68           0 :   (void)args;
      69             : 
      70           0 :   if( FD_LIKELY( !args->dev1.no_configure ) ) {
      71           0 :     args_t configure_args = {
      72           0 :       .configure.command = CONFIGURE_CMD_INIT,
      73           0 :     };
      74           0 :     for( ulong i=0; i<CONFIGURE_STAGE_COUNT; i++ )
      75           0 :       configure_args.configure.stages[ i ] = STAGES[ i ];
      76           0 :     configure_cmd_fn( &configure_args, config );
      77           0 :   }
      78             : 
      79           0 :   update_config_for_dev( config );
      80           0 :   run_firedancer_init( config, 1 );
      81             : 
      82           0 :   install_parent_signals();
      83             : 
      84           0 :   if( FD_UNLIKELY( close( 0 ) ) ) FD_LOG_ERR(( "close(0) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      85           0 :   if( FD_UNLIKELY( close( 1 ) ) ) FD_LOG_ERR(( "close(1) failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      86           0 :   if( FD_UNLIKELY( close( config->log.lock_fd ) ) ) FD_LOG_ERR(( "close() failed (%i-%s)", errno, fd_io_strerror( errno ) ));
      87             : 
      88           0 :   int result = 0;
      89           0 :   if( !strcmp( args->dev1.tile_name, "agave" ) ) {
      90           0 :     result = agave_main( config );
      91           0 :   } else {
      92           0 :     ulong tile_id = fd_topo_find_tile( &config->topo, args->dev1.tile_name, 0UL );
      93           0 :     if( FD_UNLIKELY( tile_id==ULONG_MAX ) ) FD_LOG_ERR(( "tile %s not found in topology", args->dev1.tile_name ));
      94             : 
      95           0 :     fd_topo_tile_t * tile = &config->topo.tiles[ tile_id ];
      96           0 :     fd_topo_run_tile_t run_tile = fdctl_tile_run( tile );
      97           0 :     fd_topo_run_tile( &config->topo, tile, config->development.sandbox, 1, config->uid, config->gid, -1, NULL, NULL, &run_tile );
      98           0 :   }
      99             : 
     100             :   /* main functions should exit_group and never return, but just in case */
     101           0 :   exit_group( result );
     102           0 : }

Generated by: LCOV version 1.14