capstone/suite/cstest/include/test_run.h

50 lines
1.6 KiB
C
Raw Normal View History

2024-08-31 21:33:38 +08:00
// Copyright © 2024 Rot127 <unisono@quyllur.org>
// SPDX-License-Identifier: BSD-3
#ifndef TESTRUN_H
#define TESTRUN_H
#include "test_case.h"
#include <stdint.h>
typedef enum {
TEST_RUN_SUCCESS = 0, ///< All test cases succeeded.
TEST_RUN_FAILURE = 1, ///< At least one test case failed.
TEST_RUN_ERROR = 2, ///< Test run had errors.
} TestRunResult;
typedef struct {
uint32_t valid_test_files; ///< Total number of test files.
uint32_t invalid_files; ///< Number of invalid files.
uint32_t tc_total; ///< Total number of test cases.
uint32_t successful; ///< Number of successful test cases.
uint32_t failed; ///< Number of failed test cases.
uint32_t errors; ///< Number errors (parsing errors etc).
uint32_t skipped; ///< Number skipped test cases.
2024-09-14 16:57:54 +08:00
uint32_t decoded_insns; ///< Number of total decoded instructions.
2024-08-31 21:33:38 +08:00
} TestRunStats;
typedef struct {
uint32_t case_cnt;
TestCase *cases;
} TestRun;
/* CYAML configuration. */
static const cyaml_config_t cyaml_config = {
.log_fn = cyaml_log, /* Use the default logging function. */
.mem_fn = cyaml_mem, /* Use the default memory allocator. */
.log_level = CYAML_LOG_WARNING, /* Logging errors and warnings only. */
};
typedef struct {
size_t arch_bits; ///< Bits of the architecture.
TestCase *tcase; ///< The test case to check.
csh handle; ///< The Capstone instance for this test. Setup and teared down by the cmocka handlers.
2024-09-14 16:57:54 +08:00
uint32_t decoded_insns; ///< Counts the number of decoded instructions of this test case.
2024-08-31 21:33:38 +08:00
} UnitTestState;
TestRunResult cstest_run_tests(char **test_file_paths, uint32_t path_count,
TestRunStats *stats);
#endif // TESTRUN_H