|
cmEngine
0.1.1
A library for interpreting CMake code.
|
Used to write tests, create test environments and mock objects. More...
Macros | |
| #define | CM_EXPECT(test_driver, expr) cmExpect(test_driver, __FILE__, __LINE__, #expr, (expr)) |
| #define | CM_EXPECT_STRING_EQ(test_driver, a, b) cmExpectStringEq(test_driver, __FILE__, __LINE__, a, #a, b, #b) |
Typedefs | |
| typedef void(* | cmDiagnosticChecker) (struct cmTestDriver *test_driver, const struct cmDiagnostic *diagnostic) |
| typedef void(* | cmMessageChecker) (struct cmTestDriver *test_driver, const struct cmMessage *message) |
Enumerations | |
| enum | cmTestDriverVerbosity { CM_HIGH_VERBOSITY, CM_LOW_VERBOSITY } |
| enum | cmLogType { CM_STATUS_LOG, CM_START_LOG, CM_DONE_LOG, CM_FAIL_LOG, CM_INFO_LOG } |
Functions | |
| void * | cmMalloc (size_t size) |
| void * | cmRealloc (void *addr, size_t size) |
| void | cmFree (void *addr) |
| struct cmTestDriver * | cmNewTestDriver (void) |
| void | cmReleaseTestDriver (struct cmTestDriver *test_driver) |
| void | cmSetTestDriverVerbosity (struct cmTestDriver *test_driver, enum cmTestDriverVerbosity verbosity) |
| void | cmLog (struct cmTestDriver *test_driver, enum cmLogType log_type, const char *fmt,...) cmLog_ATTRIBUTES |
| int | cmGetTestDriverResult (const struct cmTestDriver *test_driver) |
| void | cmExpect (struct cmTestDriver *test_driver, const char *filename, unsigned int line, const char *expr_string, int expr_result) |
| void | cmExpectStringEq (struct cmTestDriver *test_driver, const char *filename, unsigned int line, const char *a, const char *a_source, const char *b, const char *b_source) |
| struct cmTestEnvironment * | cmNewTestEnvironment (struct cmTestDriver *test_driver, const char *filename, unsigned int line, const char *name) |
| void | cmReleaseTestEnvironment (struct cmTestEnvironment *test_environment) |
| struct cmHost * | cmGetTestEnvironmentHost (struct cmTestEnvironment *test_environment) |
| void | cmAddTestFile (struct cmTestEnvironment *test_environment, const char *filename, const char *content) |
| void | cmDefineTestVariable (struct cmTestEnvironment *test_environment, const char *name, const char *value) |
| void | cmSetMaxAllocations (struct cmTestEnvironment *test_environment, size_t count) |
| void | cmIgnoreOOMDiagnostics (struct cmTestEnvironment *test_environment) |
| void | cmAddBinaryTestFile (struct cmTestEnvironment *test_environment, const char *filename, const char *content, size_t content_size) |
| int | cmParseTestOptionString (struct cmTestEnvironment *test_environment, const char *option_string) CM_WARN_UNUSED_RESULT |
| void | cmExpectDiagnostic (struct cmTestEnvironment *test_environment, cmDiagnosticChecker diagnostic_checker) |
| void | cmExpectMessage (struct cmTestEnvironment *test_environment, cmMessageChecker message_checker) |
| int | cmOpenTestScript (struct cmTestEnvironment *test_environment, const char *filename) |
| int | cmRunTestEnvironment (struct cmTestEnvironment *test_environment) |
Used to write tests, create test environments and mock objects.
| #define CM_EXPECT | ( | test_driver, | |
| expr | |||
| ) | cmExpect(test_driver, __FILE__, __LINE__, #expr, (expr)) |
Simplifies calls to cmExpect
| #define CM_EXPECT_STRING_EQ | ( | test_driver, | |
| a, | |||
| b | |||
| ) | cmExpectStringEq(test_driver, __FILE__, __LINE__, a, #a, b, #b) |
Simplifies calls to cmExpectStringEq.
| typedef void(* cmDiagnosticChecker) (struct cmTestDriver *test_driver, const struct cmDiagnostic *diagnostic) |
This is the type definition for a function that checks diagnostics.
| typedef void(* cmMessageChecker) (struct cmTestDriver *test_driver, const struct cmMessage *message) |
This is the type definition for a function that checks messages.
| enum cmLogType |
Enumerates the several types of log messages.
| void cmAddBinaryTestFile | ( | struct cmTestEnvironment * | test_environment, |
| const char * | filename, | ||
| const char * | content, | ||
| size_t | content_size | ||
| ) |
Adds a binary file to the test environment.
| test_environment | The test environment to add the file to. |
| filename | The name to give the file. |
| content | The content of the file. |
| content_size | The number of bytes in this file. |
| void cmAddTestFile | ( | struct cmTestEnvironment * | test_environment, |
| const char * | filename, | ||
| const char * | content | ||
| ) |
Adds a file to the test environment.
| test_environment | The test environment to add the file to. |
| filename | The name to give the file. |
| content | The content of the file. This string must be null terminated. |
| void cmDefineTestVariable | ( | struct cmTestEnvironment * | test_environment, |
| const char * | name, | ||
| const char * | value | ||
| ) |
Defines a test variable.
| test_environment | The test environment to define the variable in. |
| name | The name to give the variable. |
| value | The value to give the variable. |
| void cmExpect | ( | struct cmTestDriver * | test_driver, |
| const char * | filename, | ||
| unsigned int | line, | ||
| const char * | expr_string, | ||
| int | expr_result | ||
| ) |
Makes an expectation. An expectation is similar to an assertion but the program is not aborted if the expectation fails.
| test_driver | The test driver to make the expectation with. |
| filename | The filename that the expectation was made at. |
| line | The line that the expectation was made at. |
| expr_string | A string expression of the expectation. |
| expr_result | The result of the expression. |
| void cmExpectDiagnostic | ( | struct cmTestEnvironment * | test_environment, |
| cmDiagnosticChecker | diagnostic_checker | ||
| ) |
Notifies the test environment that it should expect a diagnostic.
| test_environment | The test environment to receive the diagnostic. |
| diagnostic_checker | The function used to inspect the diagnostic. If this parameter is null, then the diagnostic is received but not inspected. |
| void cmExpectMessage | ( | struct cmTestEnvironment * | test_environment, |
| cmMessageChecker | message_checker | ||
| ) |
Notifies the test environment that is should expect a message.
| test_environment | The environment to expect a message in. |
| message_checker | The message checker to inspect the message with. This parameter may be a null pointer, in which case the message contents are not checked. |
| void cmExpectStringEq | ( | struct cmTestDriver * | test_driver, |
| const char * | filename, | ||
| unsigned int | line, | ||
| const char * | a, | ||
| const char * | a_source, | ||
| const char * | b, | ||
| const char * | b_source | ||
| ) |
Checks for equality of two strings.
| test_driver | The test driver to log the possible failure to. |
| filename | The filename from FILE |
| line | The line from LINE |
| a | The primary string. |
| a_source | The source code that evaluates to a |
| b | The secondary string. |
| b_source | The source code that evaluates to b |
| void cmFree | ( | void * | addr | ) |
Releases a block of memory.
| addr | The address of the memory to release. |
| int cmGetTestDriverResult | ( | const struct cmTestDriver * | test_driver | ) |
Gets the result of the test driver.
| test_driver | The test driver to get the result of. |
| struct cmHost* cmGetTestEnvironmentHost | ( | struct cmTestEnvironment * | test_environment | ) |
Accesses the host interface for the test environment.
| test_environment | The test environment to get the host interface to. |
| void cmIgnoreOOMDiagnostics | ( | struct cmTestEnvironment * | test_environment | ) |
Ignores out of memory conditions. This is useful for testing the graceful exit of malloc failures.
| test_environment | The test environment to ignore OOM conditions. |
| void cmLog | ( | struct cmTestDriver * | test_driver, |
| enum cmLogType | log_type, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
Makes a log entry from a test.
| test_driver | The test driver to make the log with. |
| log_type | The type of log message. |
| fmt | The format specification string. |
| void* cmMalloc | ( | size_t | size | ) |
Allocates memory of a specified size. If memory allocation fails, the program is aborted.
| size | The number of bytes to allocate. |
| struct cmTestDriver* cmNewTestDriver | ( | void | ) |
Creates a new test driver.
| struct cmTestEnvironment* cmNewTestEnvironment | ( | struct cmTestDriver * | test_driver, |
| const char * | filename, | ||
| unsigned int | line, | ||
| const char * | name | ||
| ) |
Creates a new test environment.
| test_driver | A pointer to the test driver. |
| name | The name to give the test. |
| filename | The filename that the environment is declared in. |
| line | The lien within the file that the environment is declared in. |
| int cmOpenTestScript | ( | struct cmTestEnvironment * | test_environment, |
| const char * | filename | ||
| ) |
Opens up a test script to be executed.
| test_environment | The test environment to open the script in. |
| filename | The name of the file to open. This should have been created already with cmAddTestFile |
| int cmParseTestOptionString | ( | struct cmTestEnvironment * | test_environment, |
| const char * | option_string | ||
| ) |
Parses test options.
| test_environment | The test environment to parse the options in. |
| option_string | The option string to parse. |
| void* cmRealloc | ( | void * | addr, |
| size_t | size | ||
| ) |
Reallocates a block of memory. If the allocation fails, the program is aborted.
| addr | The memory block to resize. This parameter may be a null pointer, in which case a new memory block is allocated. |
| size | The number of bytes to resize the block to. |
| void cmReleaseTestDriver | ( | struct cmTestDriver * | test_driver | ) |
Releases memory allocated by a test driver.
| test_driver | The test driver to release memory for. |
| void cmReleaseTestEnvironment | ( | struct cmTestEnvironment * | test_environment | ) |
Releases the memory allocated by a test environment.
| test_environment | The test environment to release the memory for. |
| int cmRunTestEnvironment | ( | struct cmTestEnvironment * | test_environment | ) |
Runs the test environment.
| test_environment | The test environment to run. |
| void cmSetMaxAllocations | ( | struct cmTestEnvironment * | test_environment, |
| size_t | count | ||
| ) |
Sets the maximum number of memory allocations.
| test_environment | The test environment to set the max allocation count of. |
| count | The max number of allocations to give this test environment. |
| void cmSetTestDriverVerbosity | ( | struct cmTestDriver * | test_driver, |
| enum cmTestDriverVerbosity | verbosity | ||
| ) |
Assigns the verbosity of the test drive.r
| test_driver | The test driver to assign the verbosity for. |
| verbosity | The verbosity to set. |
1.8.12