Lhogho
0.0.028
|
Go to the source code of this file.
Data Structures | |
struct | test_case_info_tag |
Macros | |
#define | __INTERNAL_H_8DED3586_3931_4BD5_A578_3B8B6082391C_INCLUDED |
Typedefs | |
typedef RESULT(* | parse_config_attribute_function )(const TCHAR *parameter_name, const TCHAR *parameter_optipons, test_case_info *test_case_params) |
Variables | |
int | g_first |
Basic definitions | |
These macros are used to define basic constants in the code. | |
#define | LOGO_NAME "lhogho" |
#define | TARGET_FILE_EXTENSION "lgo" |
#define | SHELL_FILE_EXTENSION "sh" |
#define | EXPECTED_RESULTS_EXT "expected" |
#define | REAL_RESULTS_EXT "real" |
#define | ERROR_RESULTS_EXT "stderr" |
#define | LTEMP_EXT "ltemp" |
#define | MAX_LINE_LENGTH 2048 |
#define | MAX_NAME_LEN 1024 |
#define | EXPECTED_MEMORY TEXT("{MEM#0:0}") |
#define | MEMORY_CHECK_OPTION "-Zm" |
#define | PARAM_SET_SYMBOL TEXT('=') |
#define | SPACE_ESC_SYMBOL TEXT('\"') |
#define | COMMENT_SYMBOL TEXT(';') |
Config file data types | |
These struct contains data from parameters written into test case file. | |
typedef struct test_case_info_tag | test_case_info |
String functions prototypes | |
int | m_strcmp (const TCHAR *str1, const TCHAR *str2) |
compares two strings More... | |
TCHAR * | m_strcpy (TCHAR *dest, const TCHAR *src) |
copy string More... | |
BOOL | m_isspace (TCHAR chr) |
test if char is space More... | |
RESULT | m_strdup (TCHAR **dest_ptr, const TCHAR *src) |
duplicate string. Allocate memory for destination More... | |
RESULT | m_strndup (TCHAR **dest_ptr, const TCHAR *src, size_t num_chars) |
duplicate string, but no more than num_chars symbols More... | |
size_t | m_strlen (const TCHAR *str) |
calculates string length More... | |
TCHAR * | m_fgets (FILE *file, TCHAR *buffer, size_t buffer_size, size_t *out_size_ptr) |
Read a line from file. More... | |
void | m_fputs (FILE *file, const TCHAR *buffer) |
prints a line to file More... | |
void | m_fputs_ascii (FILE *file, const char *buffer) |
prints a line to file, convert it to UNICODE if needed More... | |
void | m_fputc (FILE *file, TCHAR tchar) |
prints a symbol to file More... | |
Internal tester helper functions prototypes | |
RESULT | parse_line (FILE *input_file, TCHAR **parameter_name, TCHAR **parameter_optipons) |
Parse a comment line in the test case file. More... | |
RESULT | extract_args (FILE *input_file, test_case_info *test_info) |
Extracts all argument pairs from test case file. More... | |
RESULT | extract_expected_results (FILE *input_file, const char *file_name) |
Extract value for expected results from test case file. More... | |
RESULT | execute_test (const char *file_name, test_case_info test_info) |
Execute a test case. More... | |
RESULT | compile_test (const char *file_name, test_case_info test_info) |
Compile test case file to executable. More... | |
RESULT | check_results (const char *file_name, test_case_info test_info, UINT32 exec_result) |
Check results from test case execution. More... | |
RESULT | import_results (const char *file_name, test_case_info test_info) |
Import results from test execution into test case file. More... | |
void | clean_up (const char *file_name) |
Clean up any temporary data from test execution. More... | |
void | print_file (const char *file_name, FILE *output) |
prints a file to the end of another one More... | |
RESULT | file_compare (const char *test_file_name, test_case_info test_info) |
Compare result file with one expected. More... | |
RESULT | exec_shell (const char *file_name) |
Execute a shell script with name same as test file name. More... | |
#define __INTERNAL_H_8DED3586_3931_4BD5_A578_3B8B6082391C_INCLUDED |
Definition at line 23 of file internal.h.
#define LOGO_NAME "lhogho" |
Definition at line 31 of file internal.h.
#define TARGET_FILE_EXTENSION "lgo" |
Definition at line 32 of file internal.h.
#define SHELL_FILE_EXTENSION "sh" |
Definition at line 33 of file internal.h.
#define EXPECTED_RESULTS_EXT "expected" |
Definition at line 34 of file internal.h.
#define REAL_RESULTS_EXT "real" |
Definition at line 35 of file internal.h.
#define ERROR_RESULTS_EXT "stderr" |
Definition at line 36 of file internal.h.
#define LTEMP_EXT "ltemp" |
Definition at line 37 of file internal.h.
#define MAX_LINE_LENGTH 2048 |
Definition at line 38 of file internal.h.
#define MAX_NAME_LEN 1024 |
Definition at line 39 of file internal.h.
#define EXPECTED_MEMORY TEXT("{MEM#0:0}") |
Definition at line 41 of file internal.h.
#define MEMORY_CHECK_OPTION "-Zm" |
Definition at line 42 of file internal.h.
#define PARAM_SET_SYMBOL TEXT('=') |
Definition at line 44 of file internal.h.
#define SPACE_ESC_SYMBOL TEXT('\"') |
Definition at line 45 of file internal.h.
#define COMMENT_SYMBOL TEXT(';') |
Definition at line 46 of file internal.h.
typedef struct test_case_info_tag test_case_info |
typedef RESULT(* parse_config_attribute_function)(const TCHAR *parameter_name, const TCHAR *parameter_optipons, test_case_info *test_case_params) |
Definition at line 65 of file internal.h.
str1 | first string |
str2 | second string |
Comare two strings. Return negative value if first is less than second positive value if first is great than second and zero if strings are equal
Definition at line 54 of file string_functions.c.
dest | destination string |
src | source string |
Copy string value to given pointer. User must supply enought memory
Definition at line 75 of file string_functions.c.
dest_ptr | pointer to destination string |
src | source string |
Duplicate string. Allocate memory for destination. If memory problems occured return error.
Definition at line 137 of file string_functions.c.
dest_ptr | pointer to destination string |
src | source string |
num_chars | number of characters to copy. |
Copy string value to given pointer, byt no more than num_chars
symbols. Allocates memory for destination. Not copy the 0 byte if source is longer than wanted length
Definition at line 114 of file string_functions.c.
size_t m_strlen | ( | const TCHAR * | str) |
str | the string |
Calculates string length in symbols. Works with char and w_char
Definition at line 34 of file string_functions.c.
file | file to read from |
buffer | buffer to read in |
buffer_size | size of space in the buffer |
out_size_ptr | size of line readed |
Read characters from given open file until new line symbol is reached or input buffer is full. Returns the count of really readed symbols in parameter and pointer to the buffer. If error occured during read process returns NULL
Definition at line 159 of file string_functions.c.
file | file to write in |
buffer | string to write |
Writes a line to the file. Buffer must be a valid nul-terminated string
Definition at line 216 of file string_functions.c.
void m_fputs_ascii | ( | FILE * | file, |
const char * | buffer | ||
) |
file | file to write in |
buffer | string to write |
Writes a line to the file. If program works in unicode mode the string is converted from ASCII to unicode.
Definition at line 232 of file string_functions.c.
file | file to write in |
tchar | symbol to write |
Writes a symbol to file.
Definition at line 258 of file string_functions.c.
input_file | file to read from |
parameter_name | name of the parameter readed |
parameter_optipons | pointer to data assigned to the parameter |
Read a comment line from test case file. If line describes valid parameter-value pair assignes name of parameter to parameter_name
and option value to parameter_optipons
Allocates memory for them. If line is empty return SUCCESS_EMPTY
value If other error occurs return some error value.
Definition at line 51 of file tester_internal.c.
RESULT extract_args | ( | FILE * | input_file, |
test_case_info * | test_info | ||
) |
input_file | file to read from |
test_info | struct in which data from parameters will be writen |
Reads comment lines from the source file until empty is found For each extracts data and call all registered parsers. Each of them is responsible to process parameter or return ERR_INVALID_ARG
if doesn't recognise the param name
Definition at line 142 of file tester_internal.c.
RESULT extract_expected_results | ( | FILE * | input_file, |
const char * | file_name | ||
) |
input_file | Test case file |
file_name | name of the file |
Read lines with expected results from test case file until empty found. Write them after corresponding processment to the file with name similar to file_name
but with specified suffix.
Definition at line 223 of file tester_internal.c.
RESULT execute_test | ( | const char * | file_name, |
test_case_info | test_info | ||
) |
file_name | Test case file name |
test_info | Options for execution |
RESULT
valuePrepare shell comand line calling tested application and execute it. Depending on testing mode could perform different actions. Collect stdout output and return execution success code as SUCCESS result
Definition at line 267 of file tester_internal.c.
RESULT compile_test | ( | const char * | file_name, |
test_case_info | test_info | ||
) |
file_name | Test case file name |
test_info | Options for execution |
Calls external compiler to compile test file.
Definition at line 356 of file tester_internal.c.
RESULT check_results | ( | const char * | file_name, |
test_case_info | test_info, | ||
UINT32 | exec_result | ||
) |
file_name | name of tested file |
test_info | options for execution |
exec_result | return value from execution |
Checks results from test execution and compare them with expected.
Definition at line 426 of file tester_internal.c.
RESULT import_results | ( | const char * | file_name, |
test_case_info | test_info | ||
) |
file_name | name of tested file |
test_info | options for execution |
Import results from test execution into test case file.
Definition at line 501 of file tester_internal.c.
void clean_up | ( | const char * | file_name) |
file_name | name of tested file |
Remove any temporary files produced from test execution process
Definition at line 572 of file tester_internal.c.
void print_file | ( | const char * | file_name, |
FILE * | output_file | ||
) |
file_name | name of file to be printed |
output_file | file where data will be appended |
Appends contet of input file into end of destination file
Definition at line 599 of file tester_internal.c.
RESULT file_compare | ( | const char * | test_file_name, |
test_case_info | test_info | ||
) |
test_file_name | name of tested file |
test_info | parameters for test execution |
Compare file containing produced from tester data with file containing expected data Returns success value if lines are "equual" and error if tey are not
Definition at line 682 of file tester_internal.c.
RESULT exec_shell | ( | const char * | file_name) |
file_name | name of tested file |
Try to execute shell script with name same as input file if any. If no script exist return SUCCESS_FILE else return SUCESS_FULL on successfull execution of ERR_GENERIC on error.
Definition at line 803 of file tester_internal.c.
int g_first |
Definition at line 34 of file tester_internal.c.