diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d940312d2e2a338b6228c2105b235b9beabdd37..82a8b865939b518e5ace05a6ada9e5d731d5d54c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,25 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [0.08] - 19-01-2021 +### Added +- Relax the requirements on the input format +A whitespace (space (0x20), form feed (0x0c), line feed (0x0a), carriage return +(0x0d), horizontal tab (0x09), or vertical tab (0x0b) or several in a sequence +are used as separators. If a string contains more than three hexadecimal +numeric characters (0123456789abcdefABCDEF) in a row without separators, a +separator is added after every second hexadecimal numeric character. Comments +after a '#' symbol until the end of the line are ignored. +E.g. "# comment\n ABCD 1 2\n34B 12\n" are interpreted as {0xAB, 0xCD, +0x01, 0x02, 0x34, 0x0B, 0x12}. +### Fixed +- Fix a bug in the definition in imagette header + ## [0.07] - 13-12-2021 -- **NOTE:** The behaviour of the cmp_tool has changed. From now on, the compressed data will be preceded by a header by default. The old behaviour can be achieved with the --no_header option the behaviour of the cmp_tool has changed. From now on, the compressed data will be preceded by a header by default. The old behaviour can be achieved with the --no_header option. +- **NOTE:** The behaviour of the cmp_tool has changed. From now on, the compressed data will be preceded by a header by default. The old behaviour can be achieved with the `--no_header` option. - Implement the compression entity header as defined in PLATO-UVIE-PL-UM-0001 for compression and decompression - small bug fixes + ## [0.06] - 12-11-2021 - if samples = 0 the cmp_tool counts the samples in the data file and uses them - if buffer_length = 0 the 2*samples parameter is used as buffer_length @@ -13,25 +28,30 @@ All notable changes to this project will be documented in this file. - some code restructuring - added more detailed error messages - small bug fixes + ## [0.05] - 23-04-2021 ### Removed - discard old file format. Now the only input format is like: 12 AB 23 CD .. .. ### Changed - change to new compression and decompression library + ## [0.05 Beta 2] - 04-12-2020 ### Fixed - packet file number now 4 digits long - now the mtu size in .rdcu_pkt_mode_cfg file for the data packets + ## [0.05 Beta] - 17-11-2020 ### Fixed - fixes small errors when reading the data ### Added - add frame script to mange multiple compression in a raw - add last_info option to generate RMAP packets to read the last compression results in parallel + ## [0.04] - 12-08-2020 ### Fixed - fixes an error when reading compressed data for decompression when compiled for a 32-bit system where a long integer has 4 bytes - fixes a bug that generates wrong packets for reading data from the RDCU with the --rdcu_pkt option + ## [0.03] - 07-07-2020 ### Added - README: add a note for the --rdcu_pkt option @@ -40,6 +60,7 @@ All notable changes to this project will be documented in this file. - if the --rdcu_pkt option is set the program did not build the data and model packets correctly. - if the --rdcu_pkt option is set the program now also sets the RDCU Interrupt Enable bit. - fix typo in Help and README + ## [0.02] - 02-06-2020 ### Added - add --rdcu_pkt option to generate the packets to set a RDCU compression diff --git a/cmp_tool.c b/cmp_tool.c index dddca2c7b1ae7380ccd291f1af48f83b86475758..24587f6bbe0205ee4d259a302fc4e43e320e6f62 100755 --- a/cmp_tool.c +++ b/cmp_tool.c @@ -33,12 +33,12 @@ #include "include/rdcu_pkt_to_file.h" -#define VERSION "0.07" +#define VERSION "0.08" #define BUFFER_LENGTH_DEF_FAKTOR 2 -#define DEFAULT_MODEL_ID 53264 /* random id used as default */ +#define DEFAULT_MODEL_ID 53264 /* random default id */ #define DEFAULT_MODEL_COUNTER 0 @@ -358,7 +358,7 @@ int main(int argc, char **argv) printf("Importing compressed data file %s ... ", data_file_name); buf_size = size = read_file_cmp_entity(data_file_name, - NULL, 0, 0); + NULL, 0, 0); if (size < 0) goto fail; /* to be save allocate at least the size of the cmp_entity struct */ @@ -380,9 +380,26 @@ int main(int argc, char **argv) error = cmp_ent_read_imagette_header(ent, &info); if (error) goto fail; - cmp_data_adr = cmp_ent_get_data_buf(ent); if (verbose_en) print_cmp_info(&info); + + /* we reuse the entity buffer for the compressed data */ + cmp_data_adr = (uint32_t *)decomp_input_buf; + size = cmp_ent_get_cmp_data(ent, cmp_data_adr, buf_size); + ent = NULL; + if (size < 0) + goto fail; + + if (verbose_en) { + size_t i; + printf("\ncompressed data:\n"); + for (i = 0; i < size/sizeof(uint32_t); i++) { + printf("%08X ", cmp_data_adr[i]); + if (i && !((i+1) % 4)) + printf("\n"); + } + printf("\n"); + } } printf("DONE\n"); } @@ -488,7 +505,7 @@ static int guess_cmp_pars(struct cmp_cfg *cfg, const char *guess_cmp_mode, int guess_level) { int error; - uint32_t cmp_size; + uint32_t cmp_size_bit; float cr; printf("Search for a good set of compression parameters (level: %d) ... ", guess_level); @@ -509,12 +526,12 @@ static int guess_cmp_pars(struct cmp_cfg *cfg, const char *guess_cmp_mode, return -1; } - cmp_size = cmp_guess(cfg, guess_level); - if (!cmp_size) + cmp_size_bit = cmp_guess(cfg, guess_level); + if (!cmp_size_bit) return -1; if (include_cmp_header) - cmp_size = CHAR_BIT * (cmp_bit_to_4byte(cmp_size) + + cmp_size_bit = CHAR_BIT * (cmp_bit_to_4byte(cmp_size_bit) + cmp_ent_cal_hdr_size(cmp_ent_map_cmp_mode_data_type(cfg->cmp_mode))); printf("DONE\n"); @@ -525,7 +542,7 @@ static int guess_cmp_pars(struct cmp_cfg *cfg, const char *guess_cmp_mode, return -1; printf("DONE\n"); - cr = (8.0 * cfg->samples * size_of_a_sample(cfg->cmp_mode))/cmp_size; + cr = (8.0 * cfg->samples * size_of_a_sample(cfg->cmp_mode))/cmp_size_bit; printf("Guessed parameters can compress the data with a CR of %.2f.\n", cr); return 0; @@ -569,19 +586,62 @@ static int gen_rdcu_write_pkts(struct cmp_cfg *cfg) } +/* add a compression entity header in front of the data */ +static int add_cmp_ent_hdr(struct cmp_cfg *cfg, struct cmp_info *info, + uint64_t start_time) +{ + int error; + uint32_t red_val; + uint8_t model_counter = DEFAULT_MODEL_COUNTER; + uint16_t model_id = DEFAULT_MODEL_ID; + size_t s, cmp_hdr_size; + struct cmp_entity *ent; + enum cmp_ent_data_type data_type = cmp_ent_map_cmp_mode_data_type(cfg->cmp_mode); + + if (model_id_str) { + error = atoui32("model_id", model_id_str, &red_val); + if (error || red_val > UINT16_MAX) + return -1; + model_id = red_val; + } + if (model_counter_str) { + error = atoui32("model_counter", model_counter_str, &red_val); + if (error || red_val > UINT8_MAX) + return -1; + model_counter = red_val; + } else { + if (model_mode_is_used(cfg->cmp_mode)) + model_counter = DEFAULT_MODEL_COUNTER + 1; + } + + cmp_hdr_size = cmp_ent_cal_hdr_size(data_type); + if (!cmp_hdr_size) + return -1; + memmove((uint8_t *)cfg->icu_output_buf+cmp_hdr_size, cfg->icu_output_buf, + cmp_bit_to_4byte(info->cmp_size)); + + ent = (struct cmp_entity *)cfg->icu_output_buf; + s = cmp_ent_build(ent, data_type, cmp_tool_gen_version_id(VERSION), + start_time, cmp_ent_create_timestamp(NULL), model_id, + model_counter, info, cfg); + if (!s) { + fprintf(stderr, "%s: error occurred while creating the compression entity header.\n", PROGRAM_NAME); + return -1; + } + return 0; +} + + /* compress the data and write the results to files */ static int compression(struct cmp_cfg *cfg, struct cmp_info *info) { int error; uint32_t cmp_size_byte; - uint8_t *out_buf = NULL; - uint32_t out_buf_size; - uint8_t model_counter = DEFAULT_MODEL_COUNTER; - uint16_t model_id = DEFAULT_MODEL_ID; - size_t cmp_hdr_size = 0; - enum cmp_ent_data_type data_type = DATA_TYPE_UNKOWN; + size_t out_buf_size; uint64_t start_time = cmp_ent_create_timestamp(NULL); + cfg->icu_output_buf = NULL; + if (cfg->buffer_length == 0) { cfg->buffer_length = (cfg->samples+1) * BUFFER_LENGTH_DEF_FAKTOR; /* +1 to prevent malloc(0)*/ printf("No buffer_length parameter set. Use buffer_length = %u as compression buffer size.\n", @@ -597,39 +657,14 @@ static int compression(struct cmp_cfg *cfg, struct cmp_info *info) } printf("Compress data ... "); + /* round up to a multiple of 4 */ out_buf_size = (cmp_cal_size_of_data(cfg->buffer_length, cfg->cmp_mode) + 3) & ~0x3U; - if (include_cmp_header) { - uint32_t red_val; - - data_type = cmp_ent_map_cmp_mode_data_type(cfg->cmp_mode); - cmp_hdr_size = cmp_ent_cal_hdr_size(data_type); - if (!cmp_hdr_size) - goto error_cleanup; - - if (model_id_str) { - error = atoui32("model_id", model_id_str, &red_val); - if (error || red_val > UINT16_MAX) - goto error_cleanup; - model_id = red_val; - } - if (model_counter_str) { - error = atoui32("model_counter", model_counter_str, &red_val); - if (error || red_val > UINT8_MAX) - goto error_cleanup; - model_counter = red_val; - } else { - if (model_mode_is_used(cfg->cmp_mode)) - model_counter = DEFAULT_MODEL_COUNTER + 1; - } - } - - out_buf = malloc(out_buf_size + cmp_hdr_size + 3); - if (out_buf == NULL) { + cfg->icu_output_buf = malloc(out_buf_size + sizeof(struct cmp_entity)); + if (cfg->icu_output_buf == NULL) { fprintf(stderr, "%s: Error allocating memory for output buffer.\n", PROGRAM_NAME); goto error_cleanup; } - cfg->icu_output_buf = out_buf + cmp_hdr_size; error = icu_compress_data(cfg, info); if (error || info->cmp_err != 0) { @@ -639,16 +674,16 @@ static int compression(struct cmp_cfg *cfg, struct cmp_info *info) /* fprintf(stderr, "%s: the buffer for the compressed data is too small. Try a larger buffer_length parameter.\n", PROGRAM_NAME); */ goto error_cleanup; } + if (include_cmp_header) { - struct cmp_entity *ent = (struct cmp_entity *)out_buf; - size_t s = cmp_ent_build(ent, data_type, cmp_tool_gen_version_id(VERSION), - start_time, cmp_ent_create_timestamp(NULL), - model_id, model_counter, info, cfg); - if (!s) { - fprintf(stderr, "%s: error occurred while creating the compression entity header.\n", PROGRAM_NAME); + error = add_cmp_ent_hdr(cfg, info, start_time); + if (error) goto error_cleanup; - } + cmp_size_byte = cmp_ent_get_size((struct cmp_entity *)cfg->icu_output_buf); + } else { + cmp_size_byte = cmp_bit_to_4byte(info->cmp_size); } + printf("DONE\n"); if (rdcu_pkt_mode) { @@ -660,13 +695,8 @@ static int compression(struct cmp_cfg *cfg, struct cmp_info *info) } printf("Write compressed data to file %s.cmp ... ", output_prefix); - if (include_cmp_header) - cmp_size_byte = cmp_ent_get_size((struct cmp_entity *)out_buf); - else - cmp_size_byte = cmp_bit_to_4byte(info->cmp_size); - - error = write_cmp_data_file(out_buf, cmp_size_byte, output_prefix, - ".cmp", verbose_en); + error = write_cmp_data_file(cfg->icu_output_buf, cmp_size_byte, + output_prefix, ".cmp", verbose_en); if (error) goto error_cleanup; printf("DONE\n"); @@ -686,13 +716,14 @@ static int compression(struct cmp_cfg *cfg, struct cmp_info *info) printf("\n"); } - free(out_buf); - out_buf = NULL; + free(cfg->icu_output_buf); + cfg->icu_output_buf = NULL; return 0; error_cleanup: - free(out_buf); + free(cfg->icu_output_buf); + cfg->icu_output_buf = NULL; return -1; } diff --git a/include/cmp_entity.h b/include/cmp_entity.h index 46b9ac3b33b7bfc123a87fbce660b95ebd0828d0..45a1b61ca837fda4ddf3d3fb60ce26fb53b3bd42 100644 --- a/include/cmp_entity.h +++ b/include/cmp_entity.h @@ -62,7 +62,7 @@ enum cmp_ent_data_type { }; #define GENERIC_HEADER_SIZE 30 -#define SPECIFIC_IMAGETTE_HEADER_SIZE 6 +#define SPECIFIC_IMAGETTE_HEADER_SIZE 4 #define SPECIFIC_IMAGETTE_ADAPTIVE_HEADER_SIZE 10 #define SPECIFIC_NON_IMAGETTE_HEADER_SIZE 30 /* TBC */ @@ -92,7 +92,6 @@ struct imagette_header { union{ struct { uint8_t spare1; - uint16_t spare2; uint8_t ima_cmp_dat[]; /* compressed data for imagette specific header */ } __attribute__((packed)); struct { @@ -100,7 +99,7 @@ struct imagette_header { uint8_t ap1_golomb_par_used; /* Adaptive Golomb parameter used 1 */ uint16_t ap2_spill_used; /* Adaptive Spillover threshold used 2 */ uint8_t ap2_golomb_par_used; /* Adaptive Golomb parameter used 2 */ - uint8_t spare3; + uint8_t spare2; uint8_t ap_ima_cmp_data[]; /* compressed data for adaptive imagette specific header */ } __attribute__((packed)); }; @@ -296,6 +295,8 @@ uint16_t cmp_ent_get_non_ima_cmp_par6(struct cmp_entity *ent); /* get function for the compressed data buffer in the entity */ void *cmp_ent_get_data_buf(struct cmp_entity *ent); uint32_t cmp_ent_get_cmp_data_size(struct cmp_entity *ent); +ssize_t cmp_ent_get_cmp_data(struct cmp_entity *ent, uint32_t *data_buf, + size_t data_buf_size); /* calculate the size of the compression entity header */ uint32_t cmp_ent_cal_hdr_size(enum cmp_ent_data_type data_type); diff --git a/include/cmp_support.h b/include/cmp_support.h index d2387ba9dce805cda7cff043dc18fb26c60dd746..0c1c90f6288c733d6c9db4c51f99b0b5e09d4c26 100644 --- a/include/cmp_support.h +++ b/include/cmp_support.h @@ -99,7 +99,7 @@ struct cmp_cfg { void *icu_new_model_buf; /* Pointer to the updated model buffer */ uint32_t rdcu_new_model_adr;/* RDCU updated model start address, the address in the RDCU SRAM where the updated model is stored*/ uint32_t samples; /* Number of samples (16 bit value) to compress, length of the data and model buffer */ - void *icu_output_buf; /* Pointer to the compressed data buffer (not used for RDCU compression) */ + uint32_t *icu_output_buf; /* Pointer to the compressed data buffer (not used for RDCU compression) */ uint32_t rdcu_buffer_adr; /* RDCU compressed data start address, the first output data address in the RDCU SRAM */ uint32_t buffer_length; /* Length of the compressed data buffer in number of samples (16 bit values)*/ }; diff --git a/lib/cmp_entity.c b/lib/cmp_entity.c index df0c3052867796aff0f23fbd6b70f2216e0131c7..5572f293752ed09f642a9f1bc98865775692920a 100644 --- a/lib/cmp_entity.c +++ b/lib/cmp_entity.c @@ -88,6 +88,23 @@ uint32_t cmp_ent_cal_hdr_size(enum cmp_ent_data_type data_type) } +/** + * @brief check if the compression entity data product type is supported + * + * @param data_type compression entity data product type to check + * + * @returns zero if data_type is invalid; non-zero if data_type is valid + */ + +int cmp_ent_data_type_valid(enum cmp_ent_data_type data_type) +{ + if (cmp_ent_cal_hdr_size(data_type)) + return 1; + else + return 0; +} + + /** * @brief set ICU ASW Version ID in the compression entity header * @@ -1124,7 +1141,12 @@ enum cmp_ent_data_type cmp_ent_get_data_type(struct cmp_entity *ent) if (!ent) return DATA_TYPE_UNKOWN; - return be16_to_cpu(ent->data_type) & 0X7FFF; + enum cmp_ent_data_type data_type = be16_to_cpu(ent->data_type) & 0X7FFF; + + if (cmp_ent_data_type_valid(data_type)) + return data_type; + else + return DATA_TYPE_UNKOWN; } @@ -1635,6 +1657,62 @@ void *cmp_ent_get_data_buf(struct cmp_entity *ent) } +/** + * @brief copy the data form a compression entity to a buffer + * + * @param ent pointer to the compression entity containing the compressed data + * @param data_buf pointer where the destination data buffer where the + * compressed data is copied to (can be NULL) + * @param data_buf_size size of the destination data buffer + * @param verbose_en print verbose output if not zero + * + * @returns the size in bytes to store the compressed data; negative on error + * + * @note the destination and source buffer can overlap + * @note converts the data to the correct endianness + */ + +ssize_t cmp_ent_get_cmp_data(struct cmp_entity *ent, uint32_t *data_buf, + size_t data_buf_size) +{ + uint32_t *cmp_ent_data_adr; + size_t cmp_size_byte; + + if (!ent) + return -1; + + cmp_ent_data_adr = cmp_ent_get_data_buf(ent); + if (!cmp_ent_data_adr) { + fprintf(stderr, "Error: Compression data type is not supported.\n"); + return -1; + } + + cmp_size_byte = cmp_ent_get_cmp_data_size(ent); + if (cmp_size_byte & 0x3) { + fprintf(stderr, "Error: The compressed data are not correct formatted. Expected multiple of 4 hex words.\n"); + return -1; + } + + if (data_buf) { + size_t i; + uint32_t cmp_data_len_32; + + if (cmp_size_byte > data_buf_size) { + fprintf(stderr, "Error: data_buf size to small to hold the data.\n"); + return -1; + } + + memmove(data_buf, cmp_ent_data_adr, cmp_size_byte); + + cmp_data_len_32 = cmp_size_byte/sizeof(uint32_t); + for (i = 0; i < cmp_data_len_32; i++) + be32_to_cpus(&data_buf[i]); + } + + return cmp_size_byte; +} + + /** * @brief get the size of the compression entity header based on the set data * product type in compression entity @@ -2188,7 +2266,7 @@ static void cmp_ent_parse_generic_header(struct cmp_entity *ent) printf("Data Product Type: unknown!"); raw_bit = cmp_ent_get_data_type_raw_bit(ent); - printf("RAW bit in the Data Product Type is%s set", raw_bit ? "" : "not"); + printf("RAW bit in the Data Product Type is%s set\n", raw_bit ? "" : " not"); cmp_mode_used = cmp_ent_get_cmp_mode(ent); printf("Used Compression Mode: %u\n", cmp_mode_used); diff --git a/lib/cmp_icu.c b/lib/cmp_icu.c index 2a7c6a188b9fb40be61831824a62254e3feb907b..5409045e74899ebcbfb49457b33458e559b5b4bb 100644 --- a/lib/cmp_icu.c +++ b/lib/cmp_icu.c @@ -1286,7 +1286,7 @@ static int encode_raw_S_FX(struct cmp_cfg *cfg, struct encoder_struct *enc) { size_t i; for (i = 0; i < cfg->samples; i++) { - struct S_FX *output_buf = cfg->icu_output_buf; + struct S_FX *output_buf = (void *)cfg->icu_output_buf; output_buf[i].FX = cpu_to_be32(output_buf[i].FX); } } diff --git a/lib/cmp_tool_lib.c b/lib/cmp_tool_lib.c index e35dd9b134b6e4d1cfb35fd9706c338fede69bd8..6028d00a5328ad79610f119be7d074a2a05faefc 100644 --- a/lib/cmp_tool_lib.c +++ b/lib/cmp_tool_lib.c @@ -96,11 +96,7 @@ static FILE *open_file(const char *dirname, const char *filename) } errno = 0; - pathname = (char *) malloc((size_t)n + 1); - if (!pathname) { - perror("malloc failed"); - abort(); - } + pathname = (char *) alloca((size_t)n + 1); errno = 0; n = snprintf(pathname, (size_t)n + 1, "%s%s", dirname, filename); @@ -1277,21 +1273,10 @@ ssize_t read_file32(const char *file_name, uint32_t *buf, uint32_t samples, return size; } -#if 0 -read_file_data(const char *file_name, cmp_mode, samples, verbose_en) - - cfg.samples = size/size_of_a_sample(cfg.cmp_mode); - printf("\nNo samples parameter set. Use samples = %u.\n... ", - cfg.samples); - } -#endif /** * @brief reads a file containing a compression entity * - * @note data must be encoded as 2 hex digits separated by a white space or new - * line character e.g. "AB CD 12 34 AB 12\n" - * * @param file_name file name of the file containing the compression entity * @param ent pointer to the buffer where the content of the file is written (can be NULL) * @param ent_size size in bytes of the compression entity to read in @@ -1308,6 +1293,7 @@ ssize_t read_file_cmp_entity(const char *file_name, struct cmp_entity *ent, size = read_file8(file_name, (uint8_t *)ent, ent_size, 0); if (size < 0) return size; + if (size < GENERIC_HEADER_SIZE) { fprintf(stderr, "%s: %s: Error: The file is too small to contain a compression entity header.\n", PROGRAM_NAME, file_name); @@ -1315,10 +1301,12 @@ ssize_t read_file_cmp_entity(const char *file_name, struct cmp_entity *ent, } if (ent) { - size_t i; - uint32_t *cmp_data; - uint32_t cmp_data_len_32; - + enum cmp_ent_data_type data_type = cmp_ent_get_data_type(ent); + if (data_type == DATA_TYPE_UNKOWN) { + fprintf(stderr, "%s: %s: Error: Compression data type is not supported.\n", + PROGRAM_NAME, file_name); + return -1; + } if (size != cmp_ent_get_size(ent)) { fprintf(stderr, "%s: %s: The size of the compression entity set in the header of the compression entity is not the same size as the read-in file has.\n", PROGRAM_NAME, file_name); @@ -1327,34 +1315,8 @@ ssize_t read_file_cmp_entity(const char *file_name, struct cmp_entity *ent, if (verbose_en) cmp_ent_parse(ent); - - if (cmp_ent_get_cmp_data_size(ent) & 0x3) { - fprintf(stderr, "%s: %s: Error: The compressed data are not correct formatted. Expected multiple of 4 hex words.\n", - PROGRAM_NAME, file_name); - return -1; - - } - - cmp_data = (uint32_t *)cmp_ent_get_data_buf(ent); - if (!cmp_data) { - fprintf(stderr, "%s: %s: Error: Compression data type is not supported.\n", - PROGRAM_NAME, file_name); - return -1; - } - cmp_data_len_32 = cmp_ent_get_cmp_data_size(ent)/sizeof(uint32_t); - for (i = 0; i < cmp_data_len_32; i++) - be32_to_cpus(&cmp_data[i]); - - if (verbose_en) { - printf("\ncompressed data:\n"); - for (i = 0; i < cmp_data_len_32; i++) { - printf("%08X ", cmp_data[i]); - if (i && !((i+1) % 4)) - printf("\n"); - } - printf("\n"); - } } + return size; } @@ -1513,6 +1475,7 @@ static void write_cfg_internal(FILE *fp, const struct cmp_cfg *cfg, int rdcu_cfg } } + /** * @brief prints config struct * @@ -1525,6 +1488,7 @@ void print_cfg(const struct cmp_cfg *cfg, int rdcu_cfg) write_cfg_internal(stdout, cfg, rdcu_cfg); } + /** * @brief write compression configuration to a file * diff --git a/test/cmp_tool/cmp_tool_integration_test.py b/test/cmp_tool/cmp_tool_integration_test.py index 9a8d09d7c630eb67489893c50f522476b9e4ce77..78d2be3c67c9b3bead804dc1f28cb280f24ae08a 100644 --- a/test/cmp_tool/cmp_tool_integration_test.py +++ b/test/cmp_tool/cmp_tool_integration_test.py @@ -116,7 +116,7 @@ def read_in_cmp_header(compressed_string): l += byte_len # skip adaptive stuff if non adaptive header if data_field == 'golomb_par_used' and data_type == 1: - l +=4 + # l +=2 break l += 2 # spare bits @@ -380,7 +380,7 @@ def test_compression_diff(): else: header = read_in_cmp_header(f.read()) assert(header['asw_version_id']['value'] == VERSION) - assert(header['cmp_ent_size']['value'] == 36+4) + assert(header['cmp_ent_size']['value'] == 34+4) assert(header['original_size']['value'] == 10) # todo assert(header['start_time']['value'] < cuc_timestamp(datetime.utcnow())) @@ -565,7 +565,7 @@ def test_raw_mode_compression(): else: header = read_in_cmp_header(f.read()) assert(header['asw_version_id']['value'] == VERSION) - assert(header['cmp_ent_size']['value'] == 36+12) + assert(header['cmp_ent_size']['value'] == 34+12) assert(header['original_size']['value'] == 10) # todo assert(header['start_time']['value'] < cuc_timestamp(datetime.utcnow())) @@ -651,8 +651,8 @@ def test_guess_option(): #cmp_size:15bit-> 4byte cmp_data + 40byte header -> 16bit*5/(44Byte*8) '5.33' elif sub_test == 'guess_level_3': exp_out = ( - '', '3', ' 0%... 6%... 13%... 19%... 25%... 32%... 38%... 44%... 50%... 57%... 64%... 72%... 80%... 88%... 94%... 100%', '0.25') #11.43 - # cmp_size:7 bit -> 4byte cmp_data + 36 byte header -> 16bit*5/(40Byte*8) + '', '3', ' 0%... 6%... 13%... 19%... 25%... 32%... 38%... 44%... 50%... 57%... 64%... 72%... 80%... 88%... 94%... 100%', '0.26') #11.43 + # cmp_size:7 bit -> 4byte cmp_data + 34 byte header -> 16bit*5/(40Byte*8) else: exp_out = ('', '', '') @@ -891,7 +891,7 @@ def test_wrong_formart_cmp_fiel(): def test_sample_used_is_to_big(): - cmp_data_header = '80 07 00 00 28 00 00 0E 03 9E 1D 5A 67 76 03 9E 1D 5A 67 9F 00 01 02 08 42 23 13 00 00 00 00 3C 07 00 00 00 44 44 44 00 \n' + cmp_data_header = '80 07 00 00 26 00 00 0E 03 9E 1D 5A 67 76 03 9E 1D 5A 67 9F 00 01 02 08 42 23 13 00 00 00 00 3C 07 00 44 44 44 00 \n' # ^ wrong samples_used cmp_data_no_header = '44 44 44 00 \n' info = ("cmp_size = 20\n" + "golomb_par_used = 1\n" + "spill_used = 4\n" @@ -949,8 +949,8 @@ def test_read_in_header(): assert(stderr == "cmp_tool: %s: Error read in '!'. The data are not correct formatted.\n" % (cmp_file_name)) # packet to small - header = '80 07 00 00 28 00 00 0C 03 9E 1D 5A 67 76 03 9E 1D 5A 67 9F 00 01 02 08 42 23 13 00 00 00 00 3C 07 00 00 00 44 \n' - # packet cut-off ^^ ^^ + header = '80 07 00 00 26 00 00 0C 03 9E 1D 5A 67 76 03 9E 1D 5A 67 9F 00 01 02 08 42 23 13 00 00 00 00 3C 07 00 44 \n' + # packet cut-off ^^ ^^ with open(cmp_file_name, 'w') as f: f.write(header) returncode, stdout, stderr = call_cmp_tool('-d %s' % (cmp_file_name)) @@ -960,7 +960,7 @@ def test_read_in_header(): assert(stderr == "cmp_tool: %s: The size of the compression entity set in the header of the compression entity is not the same size as the read-in file has.\n" %(cmp_file_name)) # packet false data type - header = '80 07 00 00 28 00 00 0C 03 9E 1D 5A 67 76 03 9E 1D 5A 67 9F FF FF 02 08 42 23 13 00 00 00 00 3C 07 00 00 00 44 44 44 00 \n' + header = '80 07 00 00 26 00 00 0C 03 9E 1D 5A 67 76 03 9E 1D 5A 67 9F 7F FE 02 08 42 23 13 00 00 00 00 3C 07 00 44 44 44 00 \n' # ^^ ^^ false data type with open(cmp_file_name, 'w') as f: f.write(header) @@ -971,7 +971,7 @@ def test_read_in_header(): assert(stderr == "cmp_tool: %s: Error: Compression data type is not supported.\n" % (cmp_file_name)) # packet false data type - header = '80 07 00 00 28 00 00 0C 03 9E 1D 5A 67 76 03 9E 1D 5A 67 9F 00 01 FF 08 42 23 13 00 00 00 00 3C 07 00 00 00 44 44 44 00 \n' + header = '80 07 00 00 26 00 00 0C 03 9E 1D 5A 67 76 03 9E 1D 5A 67 9F 00 01 FF 08 42 23 13 00 00 00 00 3C 07 00 44 44 44 00 \n' # ^^ false cmp_mode_used with open(cmp_file_name, 'w') as f: f.write(header) @@ -986,7 +986,6 @@ def test_read_in_header(): del_file(cmp_file_name) - def test_model_fiel_erros(): # generate test data data = '00 01 00 02 00 03 00 04 00 05 \n' diff --git a/test/cmp_tool/cmp_tool_lib_test.c b/test/cmp_tool/cmp_tool_lib_test.c index d55a715acc64053c16c28d585b90cf9387b17375..ebdbaf8cb871fa97086c55d6937fdcbdc9ea4d46 100644 --- a/test/cmp_tool/cmp_tool_lib_test.c +++ b/test/cmp_tool/cmp_tool_lib_test.c @@ -199,7 +199,7 @@ void test_read_file8(void) n_word = 34; size = read_file8(file_name, buf, n_word, 0); CU_ASSERT_EQUAL(size, -1); - CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "cmp_tool: test_read_file8_2.txt: Error: The files does not contain enough data as given by the n_word parameter.\n"); + CU_ASSERT_STRING_EQUAL(s=read_std_err_log(), "cmp_tool: test_read_file8_2.txt: Error: The files do not contain enough data as requested.\n"); free(s); memset(array, 0xFF, sizeof(array));