13 if (
src[0] ==
'\r' &&
src[1] ==
'\n') {
24 #define crlf2lf(x) (x)
28 const char *envvars[],
const char *envvals[],
size_t env_size,
ut64 timeout_ms,
void *user) {
48 static char *convert_win_cmds(
const char *cmds) {
49 char *
r =
malloc(strlen(cmds) + 1);
55 if (*cmds ==
'!' || (*cmds ==
'\"' && cmds[1] ==
'!')) {
59 for (;
c = *cmds,
c; cmds++) {
69 }
else if (
c ==
'$') {
75 for (;
c = *cmds,
c &&
c !=
'}'; cmds++) {
97 char *lend = strchr(cmds,
'\n');
100 llen = lend - cmds + 1;
121 void *extra_arg, *file_arg;
122 rz_list_foreach (extra_args, it, extra_arg) {
127 char *wcmds = convert_win_cmds(cmds);
132 rz_list_foreach (
files, it, file_arg) {
136 const char *envvars[] = {
142 const char *envvals[] = {
149 size_t env_size = load_plugins ? 1 : 2;
151 size_t env_size = load_plugins ? 0 : 1;
167 rz_list_foreach_safe (extra_args, it, tmpit, token) {
172 rz_list_foreach_safe (
files, it, tmpit, token) {
177 if (rz_list_empty(
files)) {
185 ut64 timeout_ms =
test->timeout.set ?
test->timeout.value * 1000 :
config->timeout_ms;
208 const char *expect_out =
test->expect.value;
209 const char *regexp_out =
test->regexp_out.value;
213 const char *expect_err =
test->expect_err.value;
214 const char *regexp_err =
test->regexp_err.value;
224 const char *
args[] = {
"." };
225 const char *invalid_json =
"this is not json lol";
234 const char *valid_json =
"{\"this is\":\"valid json\",\"lol\":true}";
243 return invalid_detected && valid_detected;
258 const char *
args[] = {
"." };
309 out->as_timeout =
true;
316 size_t hexlen = strlen(
hex);
343 out->disas_timeout =
true;
351 out->disasm = disasm;
368 out->il_timeout =
true;
375 out->il_report = il_err;
394 if (!
out->bytes || !
test->bytes ||
out->bytes_size !=
test->bytes_size ||
out->as_timeout) {
397 if (memcmp(
out->bytes,
test->bytes,
test->bytes_size) != 0) {
402 if (!
out->disasm || !
test->disasm ||
out->as_timeout) {
405 if (strcmp(
out->disasm,
test->disasm) != 0) {
411 if (!
out->il ||
out->il_failed || (
out->il_report && *
out->il_report) ||
out->il_timeout) {
415 if (strcmp(
out->il,
test->il) != 0) {
434 const char *
cmd =
"aaa";
452 switch (
test->type) {
454 if (
test->cmd_test->name.value) {
457 return strdup(
"<unnamed>");
469 switch (
test->type) {
471 return test->cmd_test->broken.value;
475 return test->json_test->broken;
488 bool success =
false;
490 switch (
test->type) {
536 #if !RZ_ASSERT_STDOUT
537 #error RZ_ASSERT_STDOUT undefined or 0
540 if (!success &&
test->type ==
RZ_TEST_TYPE_CMD && strstr(
test->path,
"/dbg") && (!
out->out || (!strstr((
char *)
out->out,
"WARNING:") && !strstr((
char *)
out->out,
"ERROR:") && !strstr((
char *)
out->out,
"FATAL:"))) && (!
out->err || (!strstr((
char *)
out->err,
"Sanitizer") && !strstr((
char *)
out->err,
"runtime error:")))) {
RZ_API bool rz_test_check_asm_test(RzAsmTestOutput *out, RzAsmTest *test)
RZ_API RzTestResultInfo * rz_test_run_test(RzTestRunConfig *config, RzTest *test)
RZ_API RzSubprocessOutput * rz_test_run_cmd_test(RzTestRunConfig *config, RzCmdTest *test, RzTestCmdRunner runner, void *user)
RZ_API bool rz_test_broken(RzTest *test)
RZ_API bool rz_test_check_jq_available(void)
RZ_API RzSubprocessOutput * rz_test_run_json_test(RzTestRunConfig *config, RzJsonTest *test, RzTestCmdRunner runner, void *user)
RZ_API RzAsmTestOutput * rz_test_run_asm_test(RzTestRunConfig *config, RzAsmTest *test)
RZ_API bool rz_test_check_json_test(RzSubprocessOutput *out, RzJsonTest *test)
static RzSubprocessOutput * subprocess_runner(const char *file, const char *args[], size_t args_size, const char *envvars[], const char *envvals[], size_t env_size, ut64 timeout_ms, void *user)
RZ_API bool rz_test_cmp_cmd_output(const char *output, const char *expect, const char *regexp)
RZ_API RzSubprocessOutput * rz_test_run_fuzz_test(RzTestRunConfig *config, RzFuzzTest *test, RzTestCmdRunner runner, void *user)
RZ_API bool rz_test_check_cmd_test(RzSubprocessOutput *out, RzCmdTest *test)
RZ_API void rz_test_test_result_info_free(RzTestResultInfo *result)
RZ_API void rz_test_asm_test_output_free(RzAsmTestOutput *out)
RZ_API bool rz_test_check_fuzz_test(RzSubprocessOutput *out)
static RzSubprocessOutput * run_rz_test(RzTestRunConfig *config, ut64 timeout_ms, const char *cmds, RzList *files, RzList *extra_args, bool load_plugins, RzTestCmdRunner runner, void *user)
RZ_API char * rz_test_test_name(RzTest *test)
int bits(struct state *s, int need)
const lzma_allocator const uint8_t size_t uint8_t * out
void rip(char *fname, off_t offset, unsigned int length)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type special files
RZ_API void Ht_() free(HtName_(Ht) *ht)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_NONNULL RzListIter *iter)
Removes an entry in the list by using the RzListIter pointer.
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API RZ_OWN char * rz_list_to_str(RZ_NONNULL RzList *list, char ch)
Casts a RzList containg strings into a concatenated string.
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
#define expect(expr, value)
static uint64_t start_time
static const char hex[16]
RZ_API int rz_hex_str2bin(const char *in, ut8 *out)
Convert an input string in into the binary form in out.
RZ_API char * rz_hex_bin2strdup(const ut8 *in, int len)
RZ_API RzList * rz_regex_get_match_list(const char *pattern, const char *flags, const char *text)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API int rz_snprintf(char *string, int len, const char *fmt,...) RZ_PRINTF_CHECK(3
RZ_API RzList * rz_str_split_duplist(const char *str, const char *c, bool trim)
Split the string str according to the substring c and returns a RzList with the result.
RZ_API char * rz_str_replace(char *str, const char *key, const char *val, int g)
RZ_API void rz_str_trim(RZ_NONNULL RZ_INOUT char *str)
Removes whitespace characters (space, tab, newline etc.) from the beginning and end of a string.
RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string ends with a specifc sequence of characters (case sensitive)
RZ_API RzSubprocessOutput * rz_subprocess_drain(RzSubprocess *proc)
RZ_API RzSubprocessWaitReason rz_subprocess_wait(RzSubprocess *proc, ut64 timeout_ms)
RZ_API void rz_subprocess_free(RzSubprocess *proc)
RZ_API ut8 * rz_subprocess_out(RzSubprocess *proc, int *length)
enum rz_process_wait_reason_t RzSubprocessWaitReason
RZ_API RzSubprocess * rz_subprocess_start(const char *file, const char *args[], size_t args_size, const char *envvars[], const char *envvals[], size_t env_size)
RZ_API void rz_subprocess_output_free(RzSubprocessOutput *out)
RZ_API ut8 * rz_subprocess_err(RzSubprocess *proc, int *length)
RZ_API ssize_t rz_subprocess_stdin_write(RzSubprocess *proc, const ut8 *buf, size_t buf_size)
RZ_API int rz_subprocess_ret(RzSubprocess *proc)
RZ_API void rz_subprocess_kill(RzSubprocess *proc)
RzSubprocessOutput *(* RzTestCmdRunner)(const char *file, const char *args[], size_t args_size, const char *envvars[], const char *envvals[], size_t env_size, ut64 timeout_ms, void *user)
@ RZ_ASM_TEST_MODE_BIG_ENDIAN
@ RZ_ASM_TEST_MODE_BROKEN
@ RZ_ASM_TEST_MODE_ASSEMBLE
@ RZ_ASM_TEST_MODE_DISASSEMBLE
RZ_API ut64 rz_time_now_mono(void)
Returns the current time in microseconds, using the monotonic clock.
RZ_API void * rz_pvector_pop(RzPVector *vec)
RZ_API void rz_pvector_init(RzPVector *vec, RzPVectorFree free)
static size_t rz_pvector_len(const RzPVector *vec)
static void ** rz_pvector_push(RzPVector *vec, void *x)
RZ_API void rz_pvector_clear(RzPVector *vec)
RzAsmTestOutput * asm_out
RzSubprocessOutput * proc_out
ut64(WINAPI *w32_GetEnabledXStateFeatures)()