Rizin
unix-like reverse engineering framework and cli tools
test_filter_flags.c File Reference

Tests Filter Flags coders. More...

#include "tests.h"

Go to the source code of this file.

Functions

static bool encode (uint32_t known_size)
 
static bool decode_ret (uint32_t known_size, lzma_ret expected_ret)
 
static bool decode (uint32_t known_size)
 
int main (void)
 

Variables

static uint8_t buffer [4096]
 
static lzma_filter known_flags
 
static lzma_filter decoded_flags
 
static lzma_stream strm = LZMA_STREAM_INIT
 

Detailed Description

Tests Filter Flags coders.

Definition in file test_filter_flags.c.

Function Documentation

◆ decode()

static bool decode ( uint32_t  known_size)
static

Definition at line 62 of file test_filter_flags.c.

63 {
64  if (decode_ret(known_size, LZMA_OK))
65  return true;
66 
68  return true;
69 
70  return false;
71 }
lzma_vli id
Filter ID.
Definition: filter.h:54
static bool decode_ret(uint32_t known_size, lzma_ret expected_ret)
static lzma_filter decoded_flags
static lzma_filter known_flags
@ LZMA_OK
Operation completed successfully.
Definition: base.h:58

References decode_ret(), decoded_flags, lzma_filter::id, known_flags, and LZMA_OK.

◆ decode_ret()

static bool decode_ret ( uint32_t  known_size,
lzma_ret  expected_ret 
)
static

Definition at line 47 of file test_filter_flags.c.

48 {
50 
51  size_t pos = 0;
52  if (lzma_filter_flags_decode(&decoded_flags, NULL,
53  buffer, &pos, known_size) != expected_ret
54  || pos != known_size)
55  return true;
56 
57  return false;
58 }
#define NULL
Definition: cris-opc.c:27
Definition: buffer.h:15
int pos
Definition: main.c:11
#define memcrap(buf, size)
Definition: tests.h:22

References decoded_flags, memcrap, NULL, and pos.

Referenced by decode().

◆ encode()

static bool encode ( uint32_t  known_size)
static

Definition at line 23 of file test_filter_flags.c.

24 {
25  memcrap(buffer, sizeof(buffer));
26 
27  uint32_t tmp;
28  if (lzma_filter_flags_size(&tmp, &known_flags) != LZMA_OK)
29  return true;
30 
31  if (tmp != known_size)
32  return true;
33 
34  size_t out_pos = 0;
35  if (lzma_filter_flags_encode(&known_flags,
36  buffer, &out_pos, known_size) != LZMA_OK)
37  return true;
38 
39  if (out_pos != known_size)
40  return true;
41 
42  return false;
43 }
const lzma_allocator const uint8_t size_t uint8_t size_t * out_pos
Definition: block.h:528
unsigned int uint32_t
Definition: sftypes.h:29

References known_flags, LZMA_OK, memcrap, out_pos, and autogen_x86imm::tmp.

◆ main()

int main ( void  )

Definition at line 243 of file test_filter_flags.c.

244 {
245 #if defined(HAVE_ENCODER_X86) && defined(HAVE_DECODER_X86)
246  test_bcj();
247 #endif
248 #if defined(HAVE_ENCODER_DELTA) && defined(HAVE_DECODER_DELTA)
249  test_delta();
250 #endif
251 // #ifdef HAVE_FILTER_LZMA
252 // test_lzma();
253 // #endif
254 
255  lzma_end(&strm);
256 
257  return 0;
258 }
static lzma_stream strm

References strm.

Variable Documentation

◆ buffer

uint8_t buffer[4096]
static

Definition at line 16 of file test_filter_flags.c.

◆ decoded_flags

lzma_filter decoded_flags
static

Definition at line 18 of file test_filter_flags.c.

Referenced by decode(), and decode_ret().

◆ known_flags

lzma_filter known_flags
static

Definition at line 17 of file test_filter_flags.c.

Referenced by decode(), and encode().

◆ strm

Definition at line 19 of file test_filter_flags.c.

Referenced by main().