visualtest/include/SDL_visualtest_harness_argparser.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 28 Aug 2017 00:22:23 -0700
changeset 11382 2c50e79b19e0
parent 7924 fcb86d323770
permissions -rw-r--r--
Renaming of guard header names to quiet -Wreserved-id-macro
     1 /**
     2  *  \file SDL_visualtest_harness_argparser.h
     3  *
     4  *  Provides functionality to parse command line arguments to the test harness.
     5  */
     6 
     7 #include <SDL.h>
     8 #include "SDL_visualtest_sut_configparser.h"
     9 #include "SDL_visualtest_variator_common.h"
    10 #include "SDL_visualtest_action_configparser.h"
    11 
    12 #ifndef SDL_visualtest_harness_argparser_h_
    13 #define SDL_visualtest_harness_argparser_h_
    14 
    15 /** Maximum length of a path string */
    16 #define MAX_PATH_LEN 300
    17 /** Maximum length of a string of SUT arguments */
    18 #define MAX_SUT_ARGS_LEN 600
    19 
    20 /* Set up for C function definitions, even when using C++ */
    21 #ifdef __cplusplus
    22 extern "C" {
    23 #endif
    24 
    25 /**
    26  * Stores the state of the test harness.
    27  */
    28 typedef struct SDLVisualTest_HarnessState
    29 {
    30     /*! Path to the System Under Test (SUT) executable */
    31     char sutapp[MAX_PATH_LEN];
    32     /*! Command line arguments to be passed to the SUT */
    33     char sutargs[MAX_SUT_ARGS_LEN];
    34     /*! Time in milliseconds after which to kill the SUT */
    35     int timeout;
    36     /*! Configuration object for the SUT */
    37     SDLVisualTest_SUTConfig sut_config;
    38     /*! What type of variator to use to generate argument strings */
    39     SDLVisualTest_VariatorType variator_type;
    40     /*! The number of variations to generate */
    41     int num_variations;
    42     /*! If true, the test harness will just print the different variations
    43         without launching the SUT for each one */
    44     SDL_bool no_launch;
    45     /*! A queue with actions to be performed while the SUT is running */
    46     SDLVisualTest_ActionQueue action_queue;
    47     /*! Output directory to save the screenshots */
    48     char output_dir[MAX_PATH_LEN];
    49     /*! Path to directory with the verification images */
    50     char verify_dir[MAX_PATH_LEN];
    51 } SDLVisualTest_HarnessState;
    52 
    53 /**
    54  * Parse command line paramters to the test harness and populate a state object.
    55  *
    56  * \param argv  The array of command line parameters.
    57  * \param state Pointer to the state object to be populated.
    58  *
    59  * \return Non-zero on success, zero on failure.
    60  */
    61 int SDLVisualTest_ParseHarnessArgs(char** argv, SDLVisualTest_HarnessState* state);
    62 
    63 /**
    64  * Frees any resources associated with the state object pointed to by \c state.
    65  */
    66 void SDLVisualTest_FreeHarnessState(SDLVisualTest_HarnessState* state);
    67 
    68 /* Ends C function definitions when using C++ */
    69 #ifdef __cplusplus
    70 }
    71 #endif
    72 
    73 #endif /* SDL_visualtest_harness_argparser_h_ */
    74 
    75 /* vi: set ts=4 sw=4 expandtab: */