tests: reformat using new code style

Signed-off-by: Marcel Cornu <marcel.d.cornu@intel.com>
This commit is contained in:
Marcel Cornu 2024-04-19 17:10:01 +01:00 committed by Pablo de Lara
parent ae951677ab
commit 9ab5a9e579
5 changed files with 217 additions and 211 deletions

View File

@ -6,7 +6,8 @@
#include <assert.h> #include <assert.h>
#include "igzip_lib.h" #include "igzip_lib.h"
int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size) int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ {
struct inflate_state state; struct inflate_state state;
z_stream zstate; z_stream zstate;
@ -58,10 +59,10 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
/* If zlib errors, assert isal errors, excluding a few /* If zlib errors, assert isal errors, excluding a few
* cases where zlib is overzealous and when zlib notices * cases where zlib is overzealous and when zlib notices
* an error faster than isal */ * an error faster than isal */
assert(iret < 0 || strcmp(zstate.msg, z_msg_invalid_code_set) == 0 assert(iret < 0 || strcmp(zstate.msg, z_msg_invalid_code_set) == 0 ||
|| strcmp(zstate.msg, z_msg_invalid_dist_set) == 0 strcmp(zstate.msg, z_msg_invalid_dist_set) == 0 ||
|| strcmp(zstate.msg, z_msg_invalid_lit_len_set) == 0 strcmp(zstate.msg, z_msg_invalid_lit_len_set) == 0 ||
|| (iret == ISAL_END_INPUT && zstate.avail_in < 3)); (iret == ISAL_END_INPUT && zstate.avail_in < 3));
} else } else
/* If zlib did not finish or error, assert isal did not finish /* If zlib did not finish or error, assert isal did not finish

View File

@ -6,7 +6,8 @@
#define DNAME_MAX 256 #define DNAME_MAX 256
#define FNAME_MAX (DNAME_MAX + 81) #define FNAME_MAX (DNAME_MAX + 81)
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
uint8_t *buf; uint8_t *buf;
int i, len, err; int i, len, err;

View File

@ -7,9 +7,11 @@
#include "igzip_lib.h" #include "igzip_lib.h"
#include "test.h" #include "test.h"
extern int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size); extern int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
FILE *in = NULL; FILE *in = NULL;
unsigned char *in_buf = NULL; unsigned char *in_buf = NULL;

View File

@ -3,7 +3,8 @@
#include <stddef.h> #include <stddef.h>
#include "igzip_lib.h" #include "igzip_lib.h"
int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size) int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ {
struct inflate_state state; struct inflate_state state;
uint8_t *isal_out_buf = (uint8_t *) (malloc(size * 2)); uint8_t *isal_out_buf = (uint8_t *) (malloc(size * 2));

View File

@ -11,30 +11,31 @@
#define HEADER_BITS 3 #define HEADER_BITS 3
#define LVL_BUF_BITS 3 #define LVL_BUF_BITS 3
#define LEVEL_BIT_MASK ((1<<LEVEL_BITS) - 1) #define LEVEL_BIT_MASK ((1 << LEVEL_BITS) - 1)
#define HEADER_BIT_MASK ((1<<HEADER_BITS) - 1) #define HEADER_BIT_MASK ((1 << HEADER_BITS) - 1)
#define TYPE0_HDR_SIZE 5 #define TYPE0_HDR_SIZE 5
#define TYPE0_MAX_SIZE 65535 #define TYPE0_MAX_SIZE 65535
#define MIN(x,y) (((x) > (y)) ? y : x ) #define MIN(x, y) (((x) > (y)) ? y : x)
const int header_size[] = { const int header_size[] = {
0, //IGZIP_DEFLATE 0, // IGZIP_DEFLATE
10, //IGZIP_GZIP 10, // IGZIP_GZIP
0, //IGZIP_GZIP_NO_HDR 0, // IGZIP_GZIP_NO_HDR
2, //IGZIP_ZLIB 2, // IGZIP_ZLIB
0, //IGZIP_ZLIB_NO_HDR 0, // IGZIP_ZLIB_NO_HDR
}; };
const int trailer_size[] = { const int trailer_size[] = {
0, //IGZIP_DEFLATE 0, // IGZIP_DEFLATE
8, //IGZIP_GZIP 8, // IGZIP_GZIP
8, //IGZIP_GZIP_NO_HDR 8, // IGZIP_GZIP_NO_HDR
4, //IGZIP_ZLIB 4, // IGZIP_ZLIB
4, //IGZIP_ZLIB_NO_HDR 4, // IGZIP_ZLIB_NO_HDR
}; };
int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size) int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{ {
struct inflate_state istate; struct inflate_state istate;
struct isal_zstream cstate; struct isal_zstream cstate;
@ -58,23 +59,23 @@ int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
switch (level) { switch (level) {
case 0: case 0:
lev_buf_size = ISAL_DEF_LVL0_MIN + (in_param) * lev_buf_size = ISAL_DEF_LVL0_MIN +
(ISAL_DEF_LVL0_EXTRA_LARGE / LEVEL_BIT_MASK); (in_param) * (ISAL_DEF_LVL0_EXTRA_LARGE / LEVEL_BIT_MASK);
break; break;
case 1: case 1:
lev_buf_size = ISAL_DEF_LVL1_MIN + (in_param) * lev_buf_size = ISAL_DEF_LVL1_MIN +
(ISAL_DEF_LVL1_EXTRA_LARGE / LEVEL_BIT_MASK); (in_param) * (ISAL_DEF_LVL1_EXTRA_LARGE / LEVEL_BIT_MASK);
break; break;
#ifdef ISAL_DEF_LVL2_MIN #ifdef ISAL_DEF_LVL2_MIN
case 2: case 2:
lev_buf_size = ISAL_DEF_LVL2_MIN + (in_param) * lev_buf_size = ISAL_DEF_LVL2_MIN +
(ISAL_DEF_LVL2_EXTRA_LARGE / LEVEL_BIT_MASK); (in_param) * (ISAL_DEF_LVL2_EXTRA_LARGE / LEVEL_BIT_MASK);
break; break;
#endif #endif
#ifdef ISAL_DEF_LVL3_MIN #ifdef ISAL_DEF_LVL3_MIN
case 3: case 3:
lev_buf_size = ISAL_DEF_LVL3_MIN + (in_param) * lev_buf_size = ISAL_DEF_LVL3_MIN +
(ISAL_DEF_LVL3_EXTRA_LARGE / LEVEL_BIT_MASK); (in_param) * (ISAL_DEF_LVL3_EXTRA_LARGE / LEVEL_BIT_MASK);
break; break;
#endif #endif
} }