mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-02 16:08:30 +00:00
Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation
Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
This commit is contained in:
147
visualtest/include/SDL_visualtest_action_configparser.h
Normal file
147
visualtest/include/SDL_visualtest_action_configparser.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file SDL_visualtest_action_configparser.h
|
||||
*
|
||||
* Header file for the parser for action config files.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_visualtest_action_configparser_h
|
||||
#define _SDL_visualtest_action_configparser_h
|
||||
|
||||
/** The maximum length of one line in the actions file */
|
||||
#define MAX_ACTION_LINE_LENGTH 300
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Type of the action.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/*! Launch an application with some given arguments */
|
||||
SDL_ACTION_LAUNCH = 0,
|
||||
/*! Kill the SUT process */
|
||||
SDL_ACTION_KILL,
|
||||
/*! Quit (Gracefully exit) the SUT process */
|
||||
SDL_ACTION_QUIT,
|
||||
/*! Take a screenshot of the SUT window */
|
||||
SDL_ACTION_SCREENSHOT,
|
||||
/*! Verify a previously taken screenshot */
|
||||
SDL_ACTION_VERIFY
|
||||
} SDLVisualTest_ActionType;
|
||||
|
||||
/**
|
||||
* Struct that defines an action that will be performed on the SUT process at
|
||||
* a specific time.
|
||||
*/
|
||||
typedef struct SDLVisualTest_Action
|
||||
{
|
||||
/*! The type of action to be performed */
|
||||
SDLVisualTest_ActionType type;
|
||||
/*! The time, in milliseconds from the launch of the SUT, when the action
|
||||
will be performed */
|
||||
int time;
|
||||
/*! Any additional information needed to perform the action. */
|
||||
union
|
||||
{
|
||||
/*! The path and arguments to the process to be launched */
|
||||
struct
|
||||
{
|
||||
char* path;
|
||||
char* args;
|
||||
} process;
|
||||
} extra;
|
||||
} SDLVisualTest_Action;
|
||||
|
||||
/**
|
||||
* Struct for a node in the action queue.
|
||||
*/
|
||||
typedef struct SDLVisualTest_ActionNode
|
||||
{
|
||||
/*! The action in this node */
|
||||
SDLVisualTest_Action action;
|
||||
/*! Pointer to the next element in the queue */
|
||||
struct SDLVisualTest_ActionNode* next;
|
||||
} SDLVisualTest_ActionNode;
|
||||
|
||||
/**
|
||||
* Queue structure for actions loaded from the actions config file.
|
||||
*/
|
||||
typedef struct SDLVisualTest_ActionQueue
|
||||
{
|
||||
/*! Pointer to the front of the queue */
|
||||
SDLVisualTest_ActionNode* front;
|
||||
/*! Pointer to the rear of the queue */
|
||||
SDLVisualTest_ActionNode* rear;
|
||||
/*! Number of nodes in the queue */
|
||||
int size;
|
||||
} SDLVisualTest_ActionQueue;
|
||||
|
||||
/**
|
||||
* Add an action pointed to by \c action to the rear of the action queue pointed
|
||||
* to by \c queue.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDLVisualTest_EnqueueAction(SDLVisualTest_ActionQueue* queue,
|
||||
SDLVisualTest_Action action);
|
||||
|
||||
/**
|
||||
* Remove an action from the front of the action queue pointed to by \c queue.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDLVisualTest_DequeueAction(SDLVisualTest_ActionQueue* queue);
|
||||
|
||||
/**
|
||||
* Initialize the action queue pointed to by \c queue.
|
||||
*/
|
||||
void SDLVisualTest_InitActionQueue(SDLVisualTest_ActionQueue* queue);
|
||||
|
||||
/**
|
||||
* Get the action at the front of the action queue pointed to by \c queue.
|
||||
* The returned action pointer may become invalid after subsequent dequeues.
|
||||
*
|
||||
* \return pointer to the action on success, NULL on failure.
|
||||
*/
|
||||
SDLVisualTest_Action* SDLVisualTest_GetQueueFront(SDLVisualTest_ActionQueue* queue);
|
||||
|
||||
/**
|
||||
* Check if the queue pointed to by \c queue is empty or not.
|
||||
*
|
||||
* \return 1 if the queue is empty, 0 otherwise.
|
||||
*/
|
||||
int SDLVisualTest_IsActionQueueEmpty(SDLVisualTest_ActionQueue* queue);
|
||||
|
||||
/**
|
||||
* Dequeues all the elements in the queque pointed to by \c queue.
|
||||
*/
|
||||
void SDLVisualTest_EmptyActionQueue(SDLVisualTest_ActionQueue* queue);
|
||||
|
||||
/**
|
||||
* Inserts an action \c action into the queue pointed to by \c queue such that
|
||||
* the times of actions in the queue increase as we move from the front to the
|
||||
* rear.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDLVisualTest_InsertIntoActionQueue(SDLVisualTest_ActionQueue* queue,
|
||||
SDLVisualTest_Action action);
|
||||
|
||||
/**
|
||||
* Parses an action config file with path \c file and populates an action queue
|
||||
* pointed to by \c queue with actions.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDLVisualTest_ParseActionConfig(char* file, SDLVisualTest_ActionQueue* queue);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_action_configparser_h */
|
62
visualtest/include/SDL_visualtest_exhaustive_variator.h
Normal file
62
visualtest/include/SDL_visualtest_exhaustive_variator.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file SDL_visualtest_exhaustive_variator.h
|
||||
*
|
||||
* Header for the exhaustive variator.
|
||||
*/
|
||||
|
||||
#include "SDL_visualtest_harness_argparser.h"
|
||||
#include "SDL_visualtest_variator_common.h"
|
||||
|
||||
#ifndef _SDL_visualtest_exhaustive_variator_h
|
||||
#define _SDL_visualtest_exhaustive_variator_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Struct for the variator that exhaustively iterates through all variations of
|
||||
* command line arguments to the SUT.
|
||||
*/
|
||||
typedef struct SDLVisualTest_ExhaustiveVariator
|
||||
{
|
||||
/*! The current variation. */
|
||||
SDLVisualTest_Variation variation;
|
||||
/*! Configuration object for the SUT that the variator is running for. */
|
||||
SDLVisualTest_SUTConfig config;
|
||||
/*! Buffer to store the arguments string built from the variation */
|
||||
char buffer[MAX_SUT_ARGS_LEN];
|
||||
} SDLVisualTest_ExhaustiveVariator;
|
||||
|
||||
/**
|
||||
* Initializes the variator.
|
||||
*
|
||||
* \return 1 on success, 0 on failure
|
||||
*/
|
||||
int SDLVisualTest_InitExhaustiveVariator(SDLVisualTest_ExhaustiveVariator* variator,
|
||||
SDLVisualTest_SUTConfig* config);
|
||||
|
||||
/**
|
||||
* Gets the arguments string for the next variation using the variator and updates
|
||||
* the variator's current variation object to the next variation.
|
||||
*
|
||||
* \return The arguments string representing the next variation on success, and
|
||||
* NULL on failure or if we have iterated through all possible variations.
|
||||
* In the latter case subsequent calls will start the variations again from
|
||||
* the very beginning. The pointer returned should not be freed.
|
||||
*/
|
||||
char* SDLVisualTest_GetNextExhaustiveVariation(SDLVisualTest_ExhaustiveVariator* variator);
|
||||
|
||||
/**
|
||||
* Frees any resources associated with the variator.
|
||||
*/
|
||||
void SDLVisualTest_FreeExhaustiveVariator(SDLVisualTest_ExhaustiveVariator* variator);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_exhaustive_variator_h */
|
73
visualtest/include/SDL_visualtest_harness_argparser.h
Normal file
73
visualtest/include/SDL_visualtest_harness_argparser.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* \file SDL_visualtest_harness_argparser.h
|
||||
*
|
||||
* Provides functionality to parse command line arguments to the test harness.
|
||||
*/
|
||||
|
||||
#include <SDL.h>
|
||||
#include "SDL_visualtest_sut_configparser.h"
|
||||
#include "SDL_visualtest_variator_common.h"
|
||||
#include "SDL_visualtest_action_configparser.h"
|
||||
|
||||
#ifndef _SDL_visualtest_harness_argparser_h
|
||||
#define _SDL_visualtest_harness_argparser_h
|
||||
|
||||
/** Maximum length of a path string */
|
||||
#define MAX_PATH_LEN 300
|
||||
/** Maximum length of a string of SUT arguments */
|
||||
#define MAX_SUT_ARGS_LEN 600
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Stores the state of the test harness.
|
||||
*/
|
||||
typedef struct SDLVisualTest_HarnessState
|
||||
{
|
||||
/*! Path to the System Under Test (SUT) executable */
|
||||
char sutapp[MAX_PATH_LEN];
|
||||
/*! Command line arguments to be passed to the SUT */
|
||||
char sutargs[MAX_SUT_ARGS_LEN];
|
||||
/*! Time in milliseconds after which to kill the SUT */
|
||||
int timeout;
|
||||
/*! Configuration object for the SUT */
|
||||
SDLVisualTest_SUTConfig sut_config;
|
||||
/*! What type of variator to use to generate argument strings */
|
||||
SDLVisualTest_VariatorType variator_type;
|
||||
/*! The number of variations to generate */
|
||||
int num_variations;
|
||||
/*! If true, the test harness will just print the different variations
|
||||
without launching the SUT for each one */
|
||||
SDL_bool no_launch;
|
||||
/*! A queue with actions to be performed while the SUT is running */
|
||||
SDLVisualTest_ActionQueue action_queue;
|
||||
/*! Output directory to save the screenshots */
|
||||
char output_dir[MAX_PATH_LEN];
|
||||
/*! Path to directory with the verification images */
|
||||
char verify_dir[MAX_PATH_LEN];
|
||||
} SDLVisualTest_HarnessState;
|
||||
|
||||
/**
|
||||
* Parse command line paramters to the test harness and populate a state object.
|
||||
*
|
||||
* \param argv The array of command line parameters.
|
||||
* \param state Pointer to the state object to be populated.
|
||||
*
|
||||
* \return Non-zero on success, zero on failure.
|
||||
*/
|
||||
int SDLVisualTest_ParseHarnessArgs(char** argv, SDLVisualTest_HarnessState* state);
|
||||
|
||||
/**
|
||||
* Frees any resources associated with the state object pointed to by \c state.
|
||||
*/
|
||||
void SDLVisualTest_FreeHarnessState(SDLVisualTest_HarnessState* state);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_harness_argparser_h */
|
26
visualtest/include/SDL_visualtest_mischelper.h
Normal file
26
visualtest/include/SDL_visualtest_mischelper.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* \file mischelper.c
|
||||
*
|
||||
* Header with miscellaneous helper functions.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_visualtest_mischelper_h
|
||||
#define _SDL_visualtest_mischelper_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Stores a 32 digit hexadecimal string representing the MD5 hash of the
|
||||
* string \c str in \c hash.
|
||||
*/
|
||||
void SDLVisualTest_HashString(char* str, char hash[33]);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_mischelper_h */
|
44
visualtest/include/SDL_visualtest_parsehelper.h
Normal file
44
visualtest/include/SDL_visualtest_parsehelper.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file SDL_visualtest_parsehelper.h
|
||||
*
|
||||
* Header with some helper functions for parsing strings.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_visualtest_parsehelper_h
|
||||
#define _SDL_visualtest_parsehelper_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Takes an string of command line arguments and breaks them up into an array
|
||||
* based on whitespace.
|
||||
*
|
||||
* \param args The string of arguments.
|
||||
*
|
||||
* \return NULL on failure, an array of strings on success. The last element
|
||||
* of the array is NULL. The first element of the array is NULL and should
|
||||
* be set to the path of the executable by the caller.
|
||||
*/
|
||||
char** SDLVisualTest_ParseArgsToArgv(char* args);
|
||||
|
||||
/**
|
||||
* Takes a string and breaks it into tokens by splitting on whitespace.
|
||||
*
|
||||
* \param str The string to be split.
|
||||
* \param max_token_len Length of each element in the array to be returned.
|
||||
*
|
||||
* \return NULL on failure; an array of strings with the tokens on success. The
|
||||
* last element of the array is NULL.
|
||||
*/
|
||||
char** SDLVisualTest_Tokenize(char* str, int max_token_len);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_parsehelper_h */
|
111
visualtest/include/SDL_visualtest_process.h
Normal file
111
visualtest/include/SDL_visualtest_process.h
Normal file
@@ -0,0 +1,111 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file SDL_visualtest_process.h
|
||||
*
|
||||
* Provides cross-platfrom process launching and termination functionality.
|
||||
*/
|
||||
|
||||
#include <SDL_platform.h>
|
||||
|
||||
#if defined(__WIN32__)
|
||||
#include <Windows.h>
|
||||
#include <Shlwapi.h>
|
||||
#elif defined(__LINUX__)
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#error "Unsupported platform."
|
||||
#endif
|
||||
|
||||
#ifndef _SDL_visualtest_process_h
|
||||
#define _SDL_visualtest_process_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Struct to store a platform specific handle to a process.
|
||||
*/
|
||||
typedef struct SDL_ProcessInfo
|
||||
{
|
||||
//#if defined(_WIN32) || defined(__WIN32__)
|
||||
#if defined(__WIN32__)
|
||||
PROCESS_INFORMATION pi;
|
||||
//#elif defined(__linux__)
|
||||
#elif defined(__LINUX__)
|
||||
int pid;
|
||||
#endif
|
||||
} SDL_ProcessInfo;
|
||||
|
||||
/**
|
||||
* This structure stores the exit status (value returned by main()) and
|
||||
* whether the process exited sucessfully or not.
|
||||
*/
|
||||
typedef struct SDL_ProcessExitStatus
|
||||
{
|
||||
int exit_success; /*!< Zero if the process exited successfully */
|
||||
int exit_status; /*!< The exit status of the process. 8-bit value. */
|
||||
} SDL_ProcessExitStatus;
|
||||
|
||||
/**
|
||||
* Launches a process with the given commandline arguments.
|
||||
*
|
||||
* \param file The path to the executable to be launched.
|
||||
* \param args The command line arguments to be passed to the process.
|
||||
* \param pinfo Pointer to an SDL_ProcessInfo object to be populated with
|
||||
* platform specific information about the launched process.
|
||||
*
|
||||
* \return Non-zero on success, zero on failure.
|
||||
*/
|
||||
int SDL_LaunchProcess(char* file, char* args, SDL_ProcessInfo* pinfo);
|
||||
|
||||
/**
|
||||
* Checks if a process is running or not.
|
||||
*
|
||||
* \param pinfo Pointer to SDL_ProcessInfo object of the process that needs to be
|
||||
* checked.
|
||||
*
|
||||
* \return 1 if the process is still running; zero if it is not and -1 if the
|
||||
* status could not be retrieved.
|
||||
*/
|
||||
int SDL_IsProcessRunning(SDL_ProcessInfo* pinfo);
|
||||
|
||||
/**
|
||||
* Kills a currently running process.
|
||||
*
|
||||
* \param pinfo Pointer to a SDL_ProcessInfo object of the process to be terminated.
|
||||
* \param ps Pointer to a SDL_ProcessExitStatus object which will be populated
|
||||
* with the exit status.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDL_KillProcess(SDL_ProcessInfo* pinfo, SDL_ProcessExitStatus* ps);
|
||||
|
||||
/**
|
||||
* Cleanly exits the process represented by \c pinfo and stores the exit status
|
||||
* in the exit status object pointed to by \c ps.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDL_QuitProcess(SDL_ProcessInfo* pinfo, SDL_ProcessExitStatus* ps);
|
||||
|
||||
/**
|
||||
* Gets the exit status of a process. If the exit status is -1, the process is
|
||||
* still running.
|
||||
*
|
||||
* \param pinfo Pointer to a SDL_ProcessInfo object of the process to be checked.
|
||||
* \param ps Pointer to a SDL_ProcessExitStatus object which will be populated
|
||||
* with the exit status.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDL_GetProcessExitStatus(SDL_ProcessInfo* pinfo, SDL_ProcessExitStatus* ps);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_process_h */
|
||||
|
59
visualtest/include/SDL_visualtest_random_variator.h
Normal file
59
visualtest/include/SDL_visualtest_random_variator.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file SDL_visualtest_random_variator.h
|
||||
*
|
||||
* Header for the random variator.
|
||||
*/
|
||||
|
||||
#include "SDL_visualtest_harness_argparser.h"
|
||||
#include "SDL_visualtest_variator_common.h"
|
||||
|
||||
#ifndef _SDL_visualtest_random_variator_h
|
||||
#define _SDL_visualtest_random_variator_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Struct for the variator that randomly generates variations of command line
|
||||
* arguments to the SUT.
|
||||
*/
|
||||
typedef struct SDLVisualTest_RandomVariator
|
||||
{
|
||||
/*! The current variation. */
|
||||
SDLVisualTest_Variation variation;
|
||||
/*! Configuration object for the SUT that the variator is running for. */
|
||||
SDLVisualTest_SUTConfig config;
|
||||
/*! Buffer to store the arguments string built from the variation */
|
||||
char buffer[MAX_SUT_ARGS_LEN];
|
||||
} SDLVisualTest_RandomVariator;
|
||||
|
||||
/**
|
||||
* Initializes the variator.
|
||||
*
|
||||
* \return 1 on success, 0 on failure
|
||||
*/
|
||||
int SDLVisualTest_InitRandomVariator(SDLVisualTest_RandomVariator* variator,
|
||||
SDLVisualTest_SUTConfig* config, Uint64 seed);
|
||||
|
||||
/**
|
||||
* Generates a new random variation.
|
||||
*
|
||||
* \return The arguments string representing the random variation on success, and
|
||||
* NULL on failure. The pointer returned should not be freed.
|
||||
*/
|
||||
char* SDLVisualTest_GetNextRandomVariation(SDLVisualTest_RandomVariator* variator);
|
||||
|
||||
/**
|
||||
* Frees any resources associated with the variator.
|
||||
*/
|
||||
void SDLVisualTest_FreeRandomVariator(SDLVisualTest_RandomVariator* variator);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_random_variator_h */
|
85
visualtest/include/SDL_visualtest_rwhelper.h
Normal file
85
visualtest/include/SDL_visualtest_rwhelper.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file rwhelper.c
|
||||
*
|
||||
* Header file with some helper functions for working with SDL_RWops.
|
||||
*/
|
||||
|
||||
#include <SDL_rwops.h>
|
||||
|
||||
#ifndef _SDL_visualtest_rwhelper_h
|
||||
#define _SDL_visualtest_rwhelper_h
|
||||
|
||||
/** Length of the buffer in SDLVisualTest_RWHelperBuffer */
|
||||
#define RWOPS_BUFFER_LEN 256
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Struct that is used as a buffer by the RW helper functions. Should be initialized by calling
|
||||
* SDLVisualTest_RWHelperResetBuffer() before being used.
|
||||
*/
|
||||
typedef struct SDLVisualTest_RWHelperBuffer
|
||||
{
|
||||
/*! Character buffer that data is read into */
|
||||
char buffer[RWOPS_BUFFER_LEN];
|
||||
/*! buffer[buffer_pos] is the next character to be read from the buffer */
|
||||
int buffer_pos;
|
||||
/*! Number of character read into the buffer */
|
||||
int buffer_width;
|
||||
} SDLVisualTest_RWHelperBuffer;
|
||||
|
||||
/**
|
||||
* Resets the buffer pointed to by \c buffer used by some of the helper functions.
|
||||
* This function should be called when you're using one of the helper functions
|
||||
* with a new SDL_RWops object.
|
||||
*/
|
||||
void SDLVisualTest_RWHelperResetBuffer(SDLVisualTest_RWHelperBuffer* buffer);
|
||||
|
||||
/**
|
||||
* Reads a single character using the SDL_RWops object pointed to by \c rw.
|
||||
* This function reads data in blocks and stores them in the buffer pointed to by
|
||||
* \c buffer, so other SDL_RWops functions should not be used in conjunction
|
||||
* with this function.
|
||||
*
|
||||
* \return The character that was read.
|
||||
*/
|
||||
char SDLVisualTest_RWHelperReadChar(SDL_RWops* rw,
|
||||
SDLVisualTest_RWHelperBuffer* buffer);
|
||||
|
||||
/**
|
||||
* Reads characters using the SDL_RWops object pointed to by \c rw into the
|
||||
* character array pointed to by \c str (of size \c size) until either the
|
||||
* array is full or a new line is encountered. If \c comment_char is encountered,
|
||||
* all characters from that position till the end of the line are ignored. The new line
|
||||
* is not included as part of the buffer. Lines with only whitespace and comments
|
||||
* are ignored. This function reads data in blocks and stores them in the buffer
|
||||
* pointed to by \c buffer, so other SDL_RWops functions should not be used in
|
||||
* conjunction with this function.
|
||||
*
|
||||
* \return pointer to the string on success, NULL on failure or EOF.
|
||||
*/
|
||||
char* SDLVisualTest_RWHelperReadLine(SDL_RWops* rw, char* str, int size,
|
||||
SDLVisualTest_RWHelperBuffer* buffer,
|
||||
char comment_char);
|
||||
|
||||
/**
|
||||
* Counts the number of lines that are not all whitespace and comments using the
|
||||
* SDL_RWops object pointed to by \c rw. \c comment_char indicates the character
|
||||
* used for comments. Uses the buffer pointed to by \c buffer to read data in blocks.
|
||||
*
|
||||
* \return Number of lines on success, -1 on failure.
|
||||
*/
|
||||
int SDLVisualTest_RWHelperCountNonEmptyLines(SDL_RWops* rw,
|
||||
SDLVisualTest_RWHelperBuffer* buffer,
|
||||
char comment_char);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_rwhelper_h */
|
50
visualtest/include/SDL_visualtest_screenshot.h
Normal file
50
visualtest/include/SDL_visualtest_screenshot.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file SDL_visualtest_screenshot.h
|
||||
*
|
||||
* Header for the screenshot API.
|
||||
*/
|
||||
|
||||
#include "SDL_visualtest_process.h"
|
||||
|
||||
#ifndef _SDL_visualtest_screenshot_h
|
||||
#define _SDL_visualtest_screenshot_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Takes a screenshot of each window owned by the process \c pinfo and saves
|
||||
* it in a file \c prefix-i.png where \c prefix is the full path to the file
|
||||
* along with a prefix given to each screenshot.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDLVisualTest_ScreenshotProcess(SDL_ProcessInfo* pinfo, char* prefix);
|
||||
|
||||
/**
|
||||
* Takes a screenshot of the desktop and saves it into the file with path
|
||||
* \c filename.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDLVisualTest_ScreenshotDesktop(char* filename);
|
||||
|
||||
/**
|
||||
* Compare a screenshot taken previously with SUT arguments \c args that is
|
||||
* located in \c test_dir with a verification image that is located in
|
||||
* \c verify_dir.
|
||||
*
|
||||
* \return -1 on failure, 0 if the images were not equal, 1 if the images are equal
|
||||
* and 2 if the verification image is not present.
|
||||
*/
|
||||
int SDLVisualTest_VerifyScreenshots(char* args, char* test_dir, char* verify_dir);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_screenshot_h */
|
103
visualtest/include/SDL_visualtest_sut_configparser.h
Normal file
103
visualtest/include/SDL_visualtest_sut_configparser.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file SDL_visualtest_sut_configparser.h
|
||||
*
|
||||
* Header for the parser for SUT config files.
|
||||
*/
|
||||
|
||||
#ifndef _SDL_visualtest_sut_configparser_h
|
||||
#define _SDL_visualtest_sut_configparser_h
|
||||
|
||||
/** Maximum length of the name of an SUT option */
|
||||
#define MAX_SUTOPTION_NAME_LEN 100
|
||||
/** Maximum length of the name of a category of an SUT option */
|
||||
#define MAX_SUTOPTION_CATEGORY_LEN 40
|
||||
/** Maximum length of one enum value of an SUT option */
|
||||
#define MAX_SUTOPTION_ENUMVAL_LEN 40
|
||||
/** Maximum length of a line in the paramters file */
|
||||
#define MAX_SUTOPTION_LINE_LENGTH 256
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Describes the different kinds of options to the SUT.
|
||||
*/
|
||||
typedef enum {
|
||||
SDL_SUT_OPTIONTYPE_STRING = 0,
|
||||
SDL_SUT_OPTIONTYPE_INT,
|
||||
SDL_SUT_OPTIONTYPE_ENUM,
|
||||
SDL_SUT_OPTIONTYPE_BOOL
|
||||
} SDLVisualTest_SUTOptionType;
|
||||
|
||||
/**
|
||||
* Represents the range of values an integer option can take.
|
||||
*/
|
||||
typedef struct SDLVisualTest_SUTIntRange {
|
||||
/*! Minimum value of the integer option */
|
||||
int min;
|
||||
/*! Maximum value of the integer option */
|
||||
int max;
|
||||
} SDLVisualTest_SUTIntRange;
|
||||
|
||||
/**
|
||||
* Struct that defines an option to be passed to the SUT.
|
||||
*/
|
||||
typedef struct SDLVisualTest_SUTOption {
|
||||
/*! The name of the option. This is what you would pass in the command line
|
||||
along with two leading hyphens. */
|
||||
char name[MAX_SUTOPTION_NAME_LEN];
|
||||
/*! An array of categories that the option belongs to. The last element is
|
||||
NULL. */
|
||||
char** categories;
|
||||
/*! Type of the option - integer, boolean, etc. */
|
||||
SDLVisualTest_SUTOptionType type;
|
||||
/*! Whether the option is required or not */
|
||||
SDL_bool required;
|
||||
/*! extra data that is required for certain types */
|
||||
union {
|
||||
/*! This field is valid only for integer type options; it defines the
|
||||
valid range for such an option */
|
||||
SDLVisualTest_SUTIntRange range;
|
||||
/*! This field is valid only for enum type options; it holds the list of values
|
||||
that the option can take. The last element is NULL */
|
||||
char** enum_values;
|
||||
} data;
|
||||
} SDLVisualTest_SUTOption;
|
||||
|
||||
/**
|
||||
* Struct to hold all the options to an SUT application.
|
||||
*/
|
||||
typedef struct SDLVisualTest_SUTConfig
|
||||
{
|
||||
/*! Pointer to an array of options */
|
||||
SDLVisualTest_SUTOption* options;
|
||||
/*! Number of options in \c options */
|
||||
int num_options;
|
||||
} SDLVisualTest_SUTConfig;
|
||||
|
||||
/**
|
||||
* Parses a configuration file that describes the command line options an SUT
|
||||
* application will take and populates a SUT config object. All lines in the
|
||||
* config file must be smaller than
|
||||
*
|
||||
* \param file Path to the configuration file.
|
||||
* \param config Pointer to an object that represents an SUT configuration.
|
||||
*
|
||||
* \return zero on failure, non-zero on success
|
||||
*/
|
||||
int SDLVisualTest_ParseSUTConfig(char* file, SDLVisualTest_SUTConfig* config);
|
||||
|
||||
/**
|
||||
* Free any resources associated with the config object pointed to by \c config.
|
||||
*/
|
||||
void SDLVisualTest_FreeSUTConfig(SDLVisualTest_SUTConfig* config);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_sut_configparser_h */
|
120
visualtest/include/SDL_visualtest_variator_common.h
Normal file
120
visualtest/include/SDL_visualtest_variator_common.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file SDL_visualtest_variator_common.h
|
||||
*
|
||||
* Header for common functionality used by variators.
|
||||
*/
|
||||
|
||||
#include <SDL_types.h>
|
||||
#include "SDL_visualtest_sut_configparser.h"
|
||||
|
||||
#ifndef _SDL_visualtest_variator_common_h
|
||||
#define _SDL_visualtest_variator_common_h
|
||||
|
||||
/** The number of variations one integer option would generate */
|
||||
#define SDL_SUT_INTEGER_OPTION_TEST_STEPS 3
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** enum for indicating the type of variator being used */
|
||||
typedef enum SDLVisualTest_VariatorType
|
||||
{
|
||||
SDL_VARIATOR_NONE = 0,
|
||||
SDL_VARIATOR_EXHAUSTIVE,
|
||||
SDL_VARIATOR_RANDOM
|
||||
} SDLVisualTest_VariatorType;
|
||||
|
||||
/**
|
||||
* One possible value for a command line option to the SUT.
|
||||
*/
|
||||
typedef union SDLVisualTest_SUTOptionValue
|
||||
{
|
||||
/*! Value if the option is of type boolean */
|
||||
SDL_bool bool_value;
|
||||
/*! Value if the option is of type integer. If on is true then the option
|
||||
will be passed to the SUT, otherwise it will be ignored. */
|
||||
struct {
|
||||
int value;
|
||||
SDL_bool on;
|
||||
} integer;
|
||||
/*! Index of the string in the enum_values field of the corresponding
|
||||
SDLVisualTest_SUTOption object. If on is true the option will passed
|
||||
to the SUT, otherwise it will be ignored. */
|
||||
struct {
|
||||
int index;
|
||||
SDL_bool on;
|
||||
} enumerated;
|
||||
/*! Value if the option is of type string. If on is true the option will
|
||||
be passed to the SUT, otherwise it will be ignored. */
|
||||
struct {
|
||||
char* value;
|
||||
SDL_bool on;
|
||||
} string;
|
||||
} SDLVisualTest_SUTOptionValue;
|
||||
|
||||
/**
|
||||
* Represents a valid combination of parameters that can be passed to the SUT.
|
||||
* The ordering of the values here is the same as the ordering of the options in
|
||||
* the SDLVisualTest_SUTConfig object for this variation.
|
||||
*/
|
||||
typedef struct SDLVisualTest_Variation
|
||||
{
|
||||
/*! Pointer to array of option values */
|
||||
SDLVisualTest_SUTOptionValue* vars;
|
||||
/*! Number of option values in \c vars */
|
||||
int num_vars;
|
||||
} SDLVisualTest_Variation;
|
||||
|
||||
/**
|
||||
* "Increments" the value of the option by one and returns the carry. We wrap
|
||||
* around to the initial value on overflow which makes the carry one.
|
||||
* For example: "incrementing" an SDL_FALSE option makes it SDL_TRUE with no
|
||||
* carry, and "incrementing" an SDL_TRUE option makes it SDL_FALSE with carry
|
||||
* one. For integers, a random value in the valid range for the option is used.
|
||||
*
|
||||
* \param var Value of the option
|
||||
* \param opt Object with metadata about the option
|
||||
*
|
||||
* \return 1 if there is a carry for enum and bool type options, 0 otherwise.
|
||||
* 1 is always returned for integer and string type options. -1 is
|
||||
* returned on error.
|
||||
*/
|
||||
int SDLVisualTest_NextValue(SDLVisualTest_SUTOptionValue* var,
|
||||
SDLVisualTest_SUTOption* opt);
|
||||
|
||||
/**
|
||||
* Converts a variation object into a string of command line arguments.
|
||||
*
|
||||
* \param variation Variation object to be converted.
|
||||
* \param config Config object for the SUT.
|
||||
* \param buffer Pointer to the buffer the arguments string will be copied into.
|
||||
* \param size Size of the buffer.
|
||||
*
|
||||
* \return 1 on success, 0 on failure
|
||||
*/
|
||||
int SDLVisualTest_MakeStrFromVariation(SDLVisualTest_Variation* variation,
|
||||
SDLVisualTest_SUTConfig* config,
|
||||
char* buffer, int size);
|
||||
|
||||
/**
|
||||
* Initializes the variation using the following rules:
|
||||
* - Boolean options are initialized to SDL_FALSE.
|
||||
* - Integer options are initialized to the minimum valid value they can hold.
|
||||
* - Enum options are initialized to the first element in the list of values they
|
||||
* can take.
|
||||
* - String options are initialized to the name of the option.
|
||||
*
|
||||
* \return 1 on success, 0 on failure.
|
||||
*/
|
||||
int SDLVisualTest_InitVariation(SDLVisualTest_Variation* variation,
|
||||
SDLVisualTest_SUTConfig* config);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_variator_common_h */
|
64
visualtest/include/SDL_visualtest_variators.h
Normal file
64
visualtest/include/SDL_visualtest_variators.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* See COPYING.txt for the full license governing this code. */
|
||||
/**
|
||||
* \file SDL_visualtest_variators.h
|
||||
*
|
||||
* Header for all the variators that vary input parameters to a SUT application.
|
||||
*/
|
||||
|
||||
#include "SDL_visualtest_exhaustive_variator.h"
|
||||
#include "SDL_visualtest_random_variator.h"
|
||||
|
||||
#ifndef _SDL_visualtest_variators_h
|
||||
#define _SDL_visualtest_variators_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Struct that acts like a wrapper around the different types of variators
|
||||
* available.
|
||||
*/
|
||||
typedef struct SDLVisualTest_Variator
|
||||
{
|
||||
/*! Type of the variator */
|
||||
SDLVisualTest_VariatorType type;
|
||||
/*! union object that stores the variator */
|
||||
union
|
||||
{
|
||||
SDLVisualTest_ExhaustiveVariator exhaustive;
|
||||
SDLVisualTest_RandomVariator random;
|
||||
} data;
|
||||
} SDLVisualTest_Variator;
|
||||
|
||||
/**
|
||||
* Initializes the variator object pointed to by \c variator of type \c type
|
||||
* with information from the config object pointed to by \c config.
|
||||
*
|
||||
* \return 1 on success, 0 on failure
|
||||
*/
|
||||
int SDLVisualTest_InitVariator(SDLVisualTest_Variator* variator,
|
||||
SDLVisualTest_SUTConfig* config,
|
||||
SDLVisualTest_VariatorType type,
|
||||
Uint64 seed);
|
||||
|
||||
/**
|
||||
* Gets the next variation using the variator.
|
||||
*
|
||||
* \return The arguments string representing the variation on success, and
|
||||
* NULL on failure. The pointer returned should not be freed.
|
||||
*/
|
||||
char* SDLVisualTest_GetNextVariation(SDLVisualTest_Variator* variator);
|
||||
|
||||
/**
|
||||
* Frees any resources associated with the variator.
|
||||
*/
|
||||
void SDLVisualTest_FreeVariator(SDLVisualTest_Variator* variator);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_visualtest_variators_h */
|
Reference in New Issue
Block a user