Changeset f9a4b2c in rtems-tools


Ignore:
Timestamp:
08/26/17 08:15:58 (6 years ago)
Author:
Cillian O'Donnell <cpodonnell8@…>
Branches:
5, master
Children:
cb0677b
Parents:
4600903
git-author:
Cillian O'Donnell <cpodonnell8@…> (08/26/17 08:15:58)
git-committer:
Chris Johns <chrisj@…> (08/29/17 08:06:24)
Message:

covoar: Remove config file and test critical options are valid.

Location:
tester/covoar
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tester/covoar/covoar.cc

    r4600903 rf9a4b2c  
    8181
    8282#define PrintableString(_s) \
    83        ((!(_s)) ? "NOT SET" : (_s))
    84 
    85 /*
    86  *  Configuration File Support
    87  */
    88 #include "ConfigFile.h"
    89 Configuration::FileReader *CoverageConfiguration;
    90 Configuration::Options_t Options[] = {
    91   { "explanations",         NULL },
    92   { "format",               NULL },
    93   { "symbolsFile",          NULL },
    94   { "outputDirectory",      NULL },
    95   { "executableExtension",  NULL },
    96   { "coverageExtension",    NULL },
    97   { "gcnosFile",            NULL },
    98   { "target",               NULL },
    99   { "verbose",              NULL },
    100   { "projectName",          NULL },
    101   { NULL,                   NULL }
    102 };
    103 
    104 bool isTrue(const char *value)
    105 {
    106   if ( !value )                  return false;
    107   if ( !strcmp(value, "true") )  return true;
    108   if ( !strcmp(value, "TRUE") )  return true;
    109   if ( !strcmp(value, "yes") )   return true;
    110   if ( !strcmp(value, "YES") )   return true;
    111   return false;
    112 }
    113 
    114 #define GET_BOOL(_opt, _val) \
    115   if (isTrue(CoverageConfiguration->getOption(_opt))) \
    116     _val = true;
    117 
    118 #define GET_STRING(_opt, _val) \
    119   do { \
    120     const char *_t; \
    121     _t = CoverageConfiguration->getOption(_opt); \
    122     if ( _t ) _val = _t; \
    123   } while(0)
    124 
    125 
    126 void check_configuration(void)
    127 {
    128   GET_BOOL( "verbose", Verbose );
    129 
    130   GET_STRING( "format",               format );
    131   GET_STRING( "target",               target );
    132   GET_STRING( "explanations",         explanations );
    133   GET_STRING( "symbolsFile",          symbolsFile );
    134   GET_STRING( "outputDirectory",      outputDirectory );
    135   GET_STRING( "executableExtension",  executableExtension );
    136   GET_STRING( "coverageExtension",    coverageFileExtension );
    137   GET_STRING( "gcnosFile",            gcnosFileName );
    138   GET_STRING( "projectName",          projectName );
    139 
    140   // Now calculate some values
    141   if ( coverageFileExtension )
    142     coverageExtensionLength = strlen( coverageFileExtension );
    143 
    144   if ( executableExtension )
    145     executableExtensionLength = strlen( executableExtension );
    146 
    147   if ( format )
    148     coverageFormat = Coverage::CoverageFormatToEnum( format );
    149 }
     83((!(_s)) ? "NOT SET" : (_s))
    15084
    15185static void
     
    198132  rld::process::tempfile                         err( ".err" );
    199133  bool                                           debug = false;
     134  std::string                                    option;
    200135
    201136  setup_signals();
    202137
    203   CoverageConfiguration = new Configuration::FileReader(Options);
    204 
    205138  //
    206139  // Process command line options.
     
    208141  progname = argv[0];
    209142
    210   while ((opt = getopt(argc, argv, "C:1:L:e:c:g:E:f:s:T:O:p:v:d")) != -1) {
     143  while ((opt = getopt(argc, argv, "1:L:e:c:g:E:f:s:T:O:p:v:d")) != -1) {
    211144    switch (opt) {
    212       case 'C': CoverageConfiguration->processFile( optarg ); break;
    213145      case '1': singleExecutable      = optarg; break;
    214146      case 'L': dynamicLibrary        = optarg; break;
     
    229161    }
    230162  }
    231 
    232   // Do not trust any arguments until after this point.
    233   check_configuration();
    234 
    235   // XXX We need to verify that all of the needed arguments are non-NULL.
     163  try
     164  {
     165   /*
     166        * Validate inputs.
     167        */
     168
     169   /*
     170        * Target name must be set.
     171        */
     172        if ( !target ) {
     173          option = "target -T";
     174          throw option;
     175        }
     176
     177   /*
     178        * Validate simulator format.
     179        */
     180        if ( !format ) {
     181          option = "format -f";
     182          throw option;
     183        }
     184
     185   /*
     186        * Has path to explanations.txt been specified.
     187        */
     188        if ( !explanations ) {
     189          option = "explanations -E";
     190          throw option;
     191        }
     192
     193   /*
     194        * Has coverage file extension been specified.
     195        */
     196        if ( !coverageFileExtension ) {
     197          option = "coverage extension -c";
     198          throw option;
     199        }
     200
     201   /*
     202        * Has executable extension been specified.
     203        */
     204        if ( !executableExtension ) {
     205          option = "executable extension -e";
     206          throw option;
     207        }
     208
     209   /*
     210        * Check for project name.
     211        */
     212        if ( !projectName ) {
     213          option = "project name -p";
     214          throw option;
     215        }
     216  }
     217  catch( std::string option )
     218  {
     219        std::cout << "error missing option: " + option << std::endl;
     220        usage();
     221        throw;
     222  }
    236223
    237224  // If a single executable was specified, process the remaining
     
    362349
    363350  //
    364   // Validate inputs.
    365   //
    366 
    367   // Target name must be set.
    368   if (!target) {
    369     fprintf( stderr, "ERROR: target not specified\n" );
    370     usage();
    371     exit(-1);
    372   }
    373 
    374   // Validate format.
    375   if (!format) {
    376     fprintf( stderr, "ERROR: coverage format report not specified\n" );
    377     usage();
    378     exit(-1);
    379   }
    380 
    381   // Validate that we have a symbols of interest file.
    382   if (!symbolsFile) {
    383     fprintf( stderr, "ERROR: symbols of interest file not specified\n" );
    384     usage();
    385     exit(-1);
    386   }
    387 
    388   //
    389351  // Create data to support analysis.
    390352  //
  • tester/covoar/wscript

    r4600903 rf9a4b2c  
    6969    bld.stlib(target = 'ccovoar',
    7070              source = ['app_common.cc',
    71                         'ConfigFile.cc',
    7271                        'CoverageFactory.cc',
    7372                        'CoverageMap.cc',
Note: See TracChangeset for help on using the changeset viewer.