Skip to content
Snippets Groups Projects
Commit 860b18fd authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

Merge branch 'model-file-size-mismatch' into 'master'

Add pre-commit configuration file

See merge request !35
parents 96d7c3ac 0702169e
Branches
Tags v0.14
1 merge request!35Add model file size mismatch check and update version to 0.14
...@@ -85,6 +85,8 @@ jobs: ...@@ -85,6 +85,8 @@ jobs:
pip install meson ninja pytest pip install meson ninja pytest
sudo apt-get update sudo apt-get update
sudo apt-get install gcc-mingw-w64 wine64 sudo apt-get install gcc-mingw-w64 wine64
- name: Update PATH for wine
run: echo "/usr/lib/wine" >> "$GITHUB_PATH"
- name: mingw cross-compilation and testing - name: mingw cross-compilation and testing
run: | run: |
meson setup \ meson setup \
...@@ -101,7 +103,6 @@ jobs: ...@@ -101,7 +103,6 @@ jobs:
name: MinGW cross compile Testlog name: MinGW cross compile Testlog
path: builddir_cross_win/meson-logs/testlog.txt path: builddir_cross_win/meson-logs/testlog.txt
mingw-build-test: mingw-build-test:
runs-on: windows-latest runs-on: windows-latest
defaults: defaults:
......
repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v5.0.0
hooks:
- id: trailing-whitespace
args:
- '--markdown-linebreak-ext=md'
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-case-conflict
- repo: 'https://github.com/codespell-project/codespell'
rev: v2.3.0
hooks:
- id: codespell
- repo: 'https://github.com/jorisroovers/gitlint'
rev: v0.19.1
hooks:
- id: gitlint
- repo: 'https://github.com/dloidolt/pre-commit-checkpatch'
rev: v0.1.0
hooks:
- id: checkpatch-files
args:
- '--fix-inplace'
- '--show-types'
- '--ignore=SPDX_LICENSE_TAG,PREFER_DEFINED_ATTRIBUTE_MACRO,INLINE'
- repo: 'https://github.com/bbastin/pre-commit-meson.git'
rev: v1.0.0
hooks:
- id: meson-test
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [0.14] - 16-01-2025
### Added
- check for model file size mismatch errors
## [0.13] - 08-11-2024 ## [0.13] - 08-11-2024
### Added ### Added
- added chunk-specific compression parameter guessing functionality - added chunk-specific compression parameter guessing functionality
......
project('cmp_tool', 'c', project('cmp_tool', 'c',
version : '0.13', version : '0.14',
meson_version : '>= 0.63', meson_version : '>= 0.63',
license : 'GPL-2.0', license : 'GPL-2.0',
default_options : [ default_options : [
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* @warning this part of the software is not intended to run on-board on the ICU. * @warning this part of the software is not intended to run on-board on the ICU.
*/ */
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -553,7 +554,8 @@ int cmp_mode_parse(const char *cmp_mode_str, enum cmp_mode *cmp_mode) ...@@ -553,7 +554,8 @@ int cmp_mode_parse(const char *cmp_mode_str, enum cmp_mode *cmp_mode)
} }
} }
return -1; return -1;
} else { }
{
uint32_t read_val; uint32_t read_val;
if (atoui32(cmp_mode_str, cmp_mode_str, &read_val)) if (atoui32(cmp_mode_str, cmp_mode_str, &read_val))
...@@ -916,7 +918,8 @@ static int parse_info(FILE *fp, struct cmp_info *info) ...@@ -916,7 +918,8 @@ static int parse_info(FILE *fp, struct cmp_info *info)
fprintf(stderr, "%s: Error read in cmp_mode_used.\n", fprintf(stderr, "%s: Error read in cmp_mode_used.\n",
PROGRAM_NAME); PROGRAM_NAME);
return -1; return -1;
} else { }
{
uint32_t tmp; uint32_t tmp;
if (atoui32(token1, token2, &tmp)) if (atoui32(token1, token2, &tmp))
...@@ -1443,10 +1446,10 @@ ssize_t read_file_data(const char *file_name, enum cmp_type cmp_type, ...@@ -1443,10 +1446,10 @@ ssize_t read_file_data(const char *file_name, enum cmp_type cmp_type,
switch (cmp_type) { switch (cmp_type) {
case CMP_TYPE_RDCU: case CMP_TYPE_RDCU:
err = be_to_cpu_data_type(buf, (uint32_t)size, DATA_TYPE_IMAGETTE); err = be_to_cpu_data_type(buf, buf_size, DATA_TYPE_IMAGETTE);
break; break;
case CMP_TYPE_CHUNK: case CMP_TYPE_CHUNK:
err = be_to_cpu_chunk(buf, (uint32_t)size); err = be_to_cpu_chunk(buf, buf_size);
break; break;
case CMP_TYPE_ERROR: case CMP_TYPE_ERROR:
default: default:
......
...@@ -122,14 +122,14 @@ static const struct option long_options[] = { ...@@ -122,14 +122,14 @@ static const struct option long_options[] = {
static const char *output_prefix = DEFAULT_OUTPUT_PREFIX; static const char *output_prefix = DEFAULT_OUTPUT_PREFIX;
/* if non zero additional RDCU parameters are included in the compression /* if non zero additional RDCU parameters are included in the compression
* configuration and decompression information files */ * configuration and decompression information files
*/
static int add_rdcu_pars; static int add_rdcu_pars;
/* if non zero generate RDCU setup packets */ /* if non zero generate RDCU setup packets */
static int rdcu_pkt_mode; static int rdcu_pkt_mode;
/* file name of the last compression information file to generate parallel RDCU /* file name of the last compression information file to generate parallel RDCU setup packets */
* setup packets */
static const char *last_info_file_name; static const char *last_info_file_name;
/* option flags for file IO */ /* option flags for file IO */
...@@ -511,6 +511,11 @@ int main(int argc, char **argv) ...@@ -511,6 +511,11 @@ int main(int argc, char **argv)
model_size, io_flags); model_size, io_flags);
if (size < 0) if (size < 0)
goto fail; goto fail;
if (size != (ssize_t)model_size) {
fprintf(stderr, "%s: %s: Error: Model file size does not match original data size.\n", PROGRAM_NAME, model_file_name);
goto fail;
}
printf("DONE\n"); printf("DONE\n");
rcfg.model_buf = input_model_buf; rcfg.model_buf = input_model_buf;
...@@ -628,7 +633,7 @@ static int guess_cmp_pars(struct rdcu_cfg *rcfg, struct cmp_par *chunk_par, ...@@ -628,7 +633,7 @@ static int guess_cmp_pars(struct rdcu_cfg *rcfg, struct cmp_par *chunk_par,
if (cmp_is_error(result)) if (cmp_is_error(result))
return -1; return -1;
else
cmp_size_bit = 8 * result; cmp_size_bit = 8 * result;
printf("DONE\n"); printf("DONE\n");
......
[wrap-file] [wrap-file]
directory = Unity-2.6.0 directory = Unity-2.6.1
source_url = https://github.com/ThrowTheSwitch/Unity/archive/refs/tags/v2.6.0.tar.gz source_url = https://github.com/ThrowTheSwitch/Unity/archive/refs/tags/v2.6.1.tar.gz
source_filename = Unity-2.6.0.tar.gz source_filename = Unity-2.6.1.tar.gz
source_hash = aa4c9fb1ae5fc5242f914c65f3557e817e40cb37f04a31e5ff76d1ab89dbf674 source_hash = b41a66d45a6b99758fb3202ace6178177014d52fc524bf1f72687d93e9867292
[provide] [provide]
unity = unity_dep unity = unity_dep
...@@ -1311,7 +1311,6 @@ def test_model_fiel_erros(): ...@@ -1311,7 +1311,6 @@ def test_model_fiel_erros():
returncode, stdout, stderr = call_cmp_tool( returncode, stdout, stderr = call_cmp_tool(
" -c "+cfg_file_name+" -d "+data_file_name + " -m "+model_file_name+" -o "+output_prefix) " -c "+cfg_file_name+" -d "+data_file_name + " -m "+model_file_name+" -o "+output_prefix)
assert(returncode == EXIT_FAILURE) assert(returncode == EXIT_FAILURE)
print(stdout)
assert(stdout == CMP_START_STR_CMP + assert(stdout == CMP_START_STR_CMP +
"Importing configuration file %s ... DONE\n" % (cfg_file_name) + "Importing configuration file %s ... DONE\n" % (cfg_file_name) +
"Importing data file %s ... DONE\n" % (data_file_name) + "Importing data file %s ... DONE\n" % (data_file_name) +
...@@ -1332,6 +1331,33 @@ def test_model_fiel_erros(): ...@@ -1332,6 +1331,33 @@ def test_model_fiel_erros():
del_file(output_prefix+"_upmodel.dat") del_file(output_prefix+"_upmodel.dat")
def test_decmp_model_fiel_original_size_miss_match():
cmp_data = b'8000000d000029000004097ce800cbd5097ce800cbfe00010108d01001000000001001001110078700'
to_large_model = b'111111111111' # should be 4 byte large in normal case
output_prefix = 'model_file_to_large'
cmp_data_file_name = 'binary_cmp_data.cmp'
model_file_name = 'to_large_model.dat'
try:
with open(cmp_data_file_name, 'wb') as f:
f.write(bytes.fromhex(cmp_data.decode()))
with open(model_file_name, 'wb') as f:
f.write(bytes.fromhex(to_large_model.decode()))
returncode, stdout, stderr = call_cmp_tool(
" --binary -d "+cmp_data_file_name + " -m " + model_file_name + " -o "+output_prefix)
assert(returncode == EXIT_FAILURE)
assert(stdout == CMP_START_STR_DECMP +
"Importing compressed data file %s ... DONE\n" % (cmp_data_file_name) +
"Importing model file %s ... FAILED\n" % (model_file_name))
assert(stderr == "cmp_tool: %s: Error: Model file size does not match original data size.\n" % (model_file_name))
finally:
del_file(cmp_data_file_name)
del_file(model_file_name)
def test_rdcu_pkt(): def test_rdcu_pkt():
# generate test data # generate test data
data = '00 01 00 02 00 03 00 04 00 05 \n' data = '00 01 00 02 00 03 00 04 00 05 \n'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment