Tests: Style fixes to test_lzip_decoder.c.
This commit is contained in:
parent
65981d8e45
commit
d93fbefcc4
|
@ -34,7 +34,8 @@ static const uint32_t trailing_garbage_crc = 0x87081A60;
|
||||||
|
|
||||||
// Helper function to decode a good file with no flags and plenty high memlimit
|
// Helper function to decode a good file with no flags and plenty high memlimit
|
||||||
static void
|
static void
|
||||||
basic_lzip_decode(const char *src, const uint32_t expected_crc) {
|
basic_lzip_decode(const char *src, const uint32_t expected_crc)
|
||||||
|
{
|
||||||
size_t file_size;
|
size_t file_size;
|
||||||
uint8_t *data = tuktest_file_from_srcdir(src, &file_size);
|
uint8_t *data = tuktest_file_from_srcdir(src, &file_size);
|
||||||
uint32_t checksum = 0;
|
uint32_t checksum = 0;
|
||||||
|
@ -95,7 +96,8 @@ test_options(void)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_v0_decode(void) {
|
test_v0_decode(void)
|
||||||
|
{
|
||||||
// This tests if liblzma can decode lzip version 0 files.
|
// This tests if liblzma can decode lzip version 0 files.
|
||||||
// lzip 1.17 and older can decompress this, but lzip 1.18
|
// lzip 1.17 and older can decompress this, but lzip 1.18
|
||||||
// and newer can no longer decode these files.
|
// and newer can no longer decode these files.
|
||||||
|
@ -104,7 +106,8 @@ test_v0_decode(void) {
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_v1_decode(void) {
|
test_v1_decode(void)
|
||||||
|
{
|
||||||
// This tests decoding a basic lzip v1 file
|
// This tests decoding a basic lzip v1 file
|
||||||
basic_lzip_decode("files/good-1-v1.lz", hello_world_crc);
|
basic_lzip_decode("files/good-1-v1.lz", hello_world_crc);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +117,8 @@ test_v1_decode(void) {
|
||||||
// the lzip stream
|
// the lzip stream
|
||||||
static void
|
static void
|
||||||
trailing_helper(const char *src, const uint32_t expected_data_checksum,
|
trailing_helper(const char *src, const uint32_t expected_data_checksum,
|
||||||
const uint32_t expected_trailing_checksum) {
|
const uint32_t expected_trailing_checksum)
|
||||||
|
{
|
||||||
size_t file_size;
|
size_t file_size;
|
||||||
uint32_t checksum = 0;
|
uint32_t checksum = 0;
|
||||||
uint8_t *data = tuktest_file_from_srcdir(src, &file_size);
|
uint8_t *data = tuktest_file_from_srcdir(src, &file_size);
|
||||||
|
@ -199,14 +203,16 @@ decode_expect_error(const char *src, lzma_ret expected_error)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_v0_trailing(void) {
|
test_v0_trailing(void)
|
||||||
|
{
|
||||||
trailing_helper("files/good-1-v0-trailing-1.lz", hello_world_crc,
|
trailing_helper("files/good-1-v0-trailing-1.lz", hello_world_crc,
|
||||||
trailing_garbage_crc);
|
trailing_garbage_crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_v1_trailing(void) {
|
test_v1_trailing(void)
|
||||||
|
{
|
||||||
trailing_helper("files/good-1-v1-trailing-1.lz", hello_world_crc,
|
trailing_helper("files/good-1-v1-trailing-1.lz", hello_world_crc,
|
||||||
trailing_garbage_crc);
|
trailing_garbage_crc);
|
||||||
|
|
||||||
|
@ -296,7 +302,8 @@ test_concatentated(void)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_crc(void) {
|
test_crc(void)
|
||||||
|
{
|
||||||
// Test invalid checksum
|
// Test invalid checksum
|
||||||
lzma_stream strm = LZMA_STREAM_INIT;
|
lzma_stream strm = LZMA_STREAM_INIT;
|
||||||
size_t file_size;
|
size_t file_size;
|
||||||
|
@ -344,7 +351,8 @@ test_crc(void) {
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_invalid_magic_bytes(void) {
|
test_invalid_magic_bytes(void)
|
||||||
|
{
|
||||||
uint8_t lzip_id_string[] = { 0x4C, 0x5A, 0x49, 0x50 };
|
uint8_t lzip_id_string[] = { 0x4C, 0x5A, 0x49, 0x50 };
|
||||||
lzma_stream strm = LZMA_STREAM_INIT;
|
lzma_stream strm = LZMA_STREAM_INIT;
|
||||||
|
|
||||||
|
@ -383,7 +391,8 @@ test_invalid_version(void)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_invalid_dictionary_size(void) {
|
test_invalid_dictionary_size(void)
|
||||||
|
{
|
||||||
// First file has too small dictionary size field
|
// First file has too small dictionary size field
|
||||||
decode_expect_error("files/bad-1-v1-dict-1.lz", LZMA_DATA_ERROR);
|
decode_expect_error("files/bad-1-v1-dict-1.lz", LZMA_DATA_ERROR);
|
||||||
|
|
||||||
|
@ -393,7 +402,8 @@ test_invalid_dictionary_size(void) {
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_invalid_uncomp_size(void) {
|
test_invalid_uncomp_size(void)
|
||||||
|
{
|
||||||
// Test invalid v0 lzip file uncomp size
|
// Test invalid v0 lzip file uncomp size
|
||||||
decode_expect_error("files/bad-1-v0-uncomp-size.lz",
|
decode_expect_error("files/bad-1-v0-uncomp-size.lz",
|
||||||
LZMA_DATA_ERROR);
|
LZMA_DATA_ERROR);
|
||||||
|
@ -405,14 +415,16 @@ test_invalid_uncomp_size(void) {
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_invalid_member_size(void) {
|
test_invalid_member_size(void)
|
||||||
|
{
|
||||||
decode_expect_error("files/bad-1-v1-member-size.lz",
|
decode_expect_error("files/bad-1-v1-member-size.lz",
|
||||||
LZMA_DATA_ERROR);
|
LZMA_DATA_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_invalid_memlimit(void) {
|
test_invalid_memlimit(void)
|
||||||
|
{
|
||||||
// A very low memlimit should prevent decoding.
|
// A very low memlimit should prevent decoding.
|
||||||
// Should be able to update the memlimit after failing
|
// Should be able to update the memlimit after failing
|
||||||
size_t file_size;
|
size_t file_size;
|
||||||
|
|
Loading…
Reference in New Issue