Rizin
unix-like reverse engineering framework and cli tools
test-lz4-list.TestVerbose Class Reference
Inheritance diagram for test-lz4-list.TestVerbose:

Public Member Functions

def setUpClass (self)
 
def test_filename (self)
 
def test_frame_number (self)
 
def test_frame_type (self)
 
def test_block (self)
 
def test_checksum (self)
 
def test_compressed (self)
 
def test_uncompressed (self)
 
def test_ratio (self)
 

Public Attributes

 vinfo_list
 
 cvinfo
 

Detailed Description

Definition at line 108 of file test-lz4-list.py.

Member Function Documentation

◆ setUpClass()

def test-lz4-list.TestVerbose.setUpClass (   self)

Definition at line 110 of file test-lz4-list.py.

110  def setUpClass(self):
111  # Even do we're listing 2 files to test multiline working as expected.
112  # we're only really interested in testing the output of the concat-all file.
113  self.vinfo_list = []
114  start = end = 0
115  output = execute("{} --list -m -v {}/test_list_concat-all.lz4 {}/test_list_*M-lz4f-2f--content-size.lz4".format(LZ4, TEMP, TEMP), print_output=True)
116  for i, line in enumerate(output):
117  if line.startswith("test_list"):
118  if start != 0 and end != 0:
119  self.vinfo_list.append(VerboseFileInfo(output[start:end]))
120  start = i
121  if not line:
122  end = i
123  self.vinfo_list.append(VerboseFileInfo(output[start:end]))
124  # Populate file_frame_map as a reference of the expected info
125  concat_file_list = glob.glob("/tmp/test_list_[!concat]*.lz4")
126  # One of the files has 2 frames so duplicate it in this list to map each frame 1 to a single file
127  for i, filename in enumerate(concat_file_list):
128  if "2f--content-size" in filename:
129  concat_file_list.insert(i, filename)
130  break
131  self.cvinfo = self.vinfo_list[0]
132  self.cvinfo.file_frame_map = concat_file_list
133  self.cvinfo.compressed_size = os.path.getsize("{}/test_list_concat-all.lz4".format(TEMP))
134 
#define append(x, y)
Definition: cmd_print.c:1740
def execute(command, print_command=True, print_output=False, print_error=True, param_shell=True)

◆ test_block()

def test-lz4-list.TestVerbose.test_block (   self)

Definition at line 153 of file test-lz4-list.py.

153  def test_block(self):
154  for i, frame_info in enumerate(self.cvinfo.frame_list):
155  if "--BD" in self.cvinfo.file_frame_map[i]:
156  self.assertRegex(self.cvinfo.frame_list[i]["block"], "^B[0-9]+D$", self.cvinfo.frame_list[i]["line"])
157  elif "--BI" in self.cvinfo.file_frame_map[i]:
158  self.assertEqual(self.cvinfo.frame_list[i]["block"], "^B[0-9]+I$", self.cvinfo.frame_list[i]["line"])
159 

References test-lz4-list.TestVerbose.cvinfo.

◆ test_checksum()

def test-lz4-list.TestVerbose.test_checksum (   self)

Definition at line 160 of file test-lz4-list.py.

160  def test_checksum(self):
161  for i, frame_info in enumerate(self.cvinfo.frame_list):
162  if "-lz4f-" in self.cvinfo.file_frame_map[i] and "--no-frame-crc" not in self.cvinfo.file_frame_map[i]:
163  self.assertEqual(self.cvinfo.frame_list[i]["checksum"], "XXH32", self.cvinfo.frame_list[i]["line"])
164 

References test-lz4-list.TestVerbose.cvinfo.

◆ test_compressed()

def test-lz4-list.TestVerbose.test_compressed (   self)

Definition at line 165 of file test-lz4-list.py.

165  def test_compressed(self):
166  total = 0
167  for i, frame_info in enumerate(self.cvinfo.frame_list):
168  if "-2f-" not in self.cvinfo.file_frame_map[i]:
169  expected_size = os.path.getsize(self.cvinfo.file_frame_map[i])
170  self.assertEqual(self.cvinfo.frame_list[i]["compressed"], str(expected_size), self.cvinfo.frame_list[i]["line"])
171  total += int(self.cvinfo.frame_list[i]["compressed"])
172  self.assertEqual(total, self.cvinfo.compressed_size, "Expected total sum ({}) to match {} filesize".format(total, self.cvinfo.filename))
173 
static int
Definition: sfsocketcall.h:114

References test-lz4-list.TestVerbose.cvinfo, int, and cmd_descs_generate.str.

◆ test_filename()

def test-lz4-list.TestVerbose.test_filename (   self)

Definition at line 135 of file test-lz4-list.py.

135  def test_filename(self):
136  for i, vinfo in enumerate(self.vinfo_list):
137  self.assertRegex(vinfo.filename, "^test_list_.*({}/{})".format(i + 1, len(self.vinfo_list)))
138 
size_t len
Definition: 6502dis.c:15

References len, and test-lz4-list.TestVerbose.vinfo_list.

◆ test_frame_number()

def test-lz4-list.TestVerbose.test_frame_number (   self)

Definition at line 139 of file test-lz4-list.py.

139  def test_frame_number(self):
140  for vinfo in self.vinfo_list:
141  for i, frame_info in enumerate(vinfo.frame_list):
142  self.assertEqual(frame_info["frame"], str(i + 1), frame_info["line"])
143 

References cmd_descs_generate.str, and test-lz4-list.TestVerbose.vinfo_list.

◆ test_frame_type()

def test-lz4-list.TestVerbose.test_frame_type (   self)

Definition at line 144 of file test-lz4-list.py.

144  def test_frame_type(self):
145  for i, frame_info in enumerate(self.cvinfo.frame_list):
146  if "-lz4f-" in self.cvinfo.file_frame_map[i]:
147  self.assertEqual(self.cvinfo.frame_list[i]["type"], "LZ4Frame", self.cvinfo.frame_list[i]["line"])
148  elif "-legc-" in self.cvinfo.file_frame_map[i]:
149  self.assertEqual(self.cvinfo.frame_list[i]["type"], "LegacyFrame", self.cvinfo.frame_list[i]["line"])
150  elif "-skip-" in self.cvinfo.file_frame_map[i]:
151  self.assertEqual(self.cvinfo.frame_list[i]["type"], "SkippableFrame", self.cvinfo.frame_list[i]["line"])
152 

References test-lz4-list.TestVerbose.cvinfo.

◆ test_ratio()

def test-lz4-list.TestVerbose.test_ratio (   self)

Definition at line 181 of file test-lz4-list.py.

181  def test_ratio(self):
182  for i, frame_info in enumerate(self.cvinfo.frame_list):
183  if "--content-size" in self.cvinfo.file_frame_map[i]:
184  self.assertEqual(self.cvinfo.frame_list[i]['ratio'],
185  "{:.2f}%".format(float(self.cvinfo.frame_list[i]['compressed']) / float(self.cvinfo.frame_list[i]['uncompressed']) * 100),
186  self.cvinfo.frame_list[i]["line"])
187 
188 

References test-lz4-list.TestVerbose.cvinfo, and test-lz4-speed.float.

◆ test_uncompressed()

def test-lz4-list.TestVerbose.test_uncompressed (   self)

Definition at line 174 of file test-lz4-list.py.

174  def test_uncompressed(self):
175  for i, frame_info in enumerate(self.cvinfo.frame_list):
176  ffm = self.cvinfo.file_frame_map[i]
177  if "-2f-" not in ffm and "--content-size" in ffm:
178  expected_size_unc = int(ffm[ffm.rindex("_") + 1:ffm.index("M")]) * 1048576
179  self.assertEqual(self.cvinfo.frame_list[i]["uncompressed"], str(expected_size_unc), self.cvinfo.frame_list[i]["line"])
180 

References test-lz4-list.TestVerbose.cvinfo, int, and cmd_descs_generate.str.

Member Data Documentation

◆ cvinfo

◆ vinfo_list

test-lz4-list.TestVerbose.vinfo_list

The documentation for this class was generated from the following file: