Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cmp_tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominik Loidolt
cmp_tool
Commits
d28f80e1
Commit
d28f80e1
authored
1 year ago
by
Dominik Loidolt
Browse files
Options
Downloads
Patches
Plain Diff
Add test case for a chunk decompression with the cmp_tool
parent
76ff252a
No related branches found
No related tags found
1 merge request
!33
Fix cmp_tool chunk compression entity header
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/cmp_tool/cmp_tool_integration_test.py
+55
-1
55 additions, 1 deletion
test/cmp_tool/cmp_tool_integration_test.py
test/cmp_tool/gen_test_data.c
+41
-0
41 additions, 0 deletions
test/cmp_tool/gen_test_data.c
test/cmp_tool/meson.build
+11
-1
11 additions, 1 deletion
test/cmp_tool/meson.build
with
107 additions
and
2 deletions
test/cmp_tool/cmp_tool_integration_test.py
+
55
−
1
View file @
d28f80e1
...
...
@@ -7,6 +7,7 @@ import os
import
math
import
shutil
from
pathlib
import
Path
import
hashlib
from
datetime
import
datetime
from
datetime
import
timedelta
...
...
@@ -1415,7 +1416,6 @@ def test_rdcu_pkt():
assert
(
f1
.
read
()
==
f2
.
read
())
finally
:
pass
del_directory
(
'
TC_FILES
'
)
del_file
(
data_file_name
)
del_file
(
cfg_file_name
)
...
...
@@ -1427,5 +1427,59 @@ def test_rdcu_pkt():
del_file
(
output_prefix2
+
'
_upmodel.dat
'
)
def
test_chunk_compression
():
# decompress the test data
output_prefix1
=
"
ref_short_cadence_1
"
cmp_data_path1
=
"
test/cmp_tool/ref_short_cadence_1_cmp.cmp
"
output_prefix2
=
"
ref_short_cadence_2
"
cmp_data_path2
=
"
test/cmp_tool/ref_short_cadence_2_cmp.cmp
"
try
:
returncode
,
stdout
,
stderr
=
call_cmp_tool
(
"
--binary -d
"
+
cmp_data_path1
+
"
-o
"
+
output_prefix1
)
assert
(
stderr
==
""
)
assert
(
stdout
==
CMP_START_STR_DECMP
+
"
Importing compressed data file %s ... DONE
\n
"
%
(
cmp_data_path1
)
+
"
Decompress data ... DONE
\n
"
+
"
Write decompressed data to file %s.dat ... DONE
\n
"
%
(
output_prefix1
))
assert
(
returncode
==
EXIT_SUCCESS
)
with
open
(
output_prefix1
+
'
.dat
'
,
'
rb
'
)
as
f
:
sha1
=
hashlib
.
sha1
()
while
True
:
chunk
=
f
.
read
(
16
*
1024
)
if
not
chunk
:
break
sha1
.
update
(
chunk
)
assert
(
sha1
.
hexdigest
()
==
"
7d8d94d2ac904f9ff4f934bb691b469a7391ce9e
"
)
returncode
,
stdout
,
stderr
=
call_cmp_tool
(
"
--binary -d
"
+
cmp_data_path2
+
"
-m
"
+
output_prefix1
+
"
.dat -o
"
+
output_prefix2
)
assert
(
stderr
==
""
)
assert
(
stdout
==
CMP_START_STR_DECMP
+
"
Importing compressed data file %s ... DONE
\n
"
%
(
cmp_data_path2
)
+
"
Importing model file %s.dat ... DONE
\n
"
%
(
output_prefix1
)
+
"
Decompress data ... DONE
\n
"
+
"
Write decompressed data to file %s.dat ... DONE
\n
"
%
(
output_prefix2
)
+
"
Write updated model to file %s_upmodel.dat ... DONE
\n
"
%
(
output_prefix2
))
assert
(
returncode
==
EXIT_SUCCESS
)
with
open
(
output_prefix2
+
'
.dat
'
,
'
rb
'
)
as
f
:
sha1
=
hashlib
.
sha1
()
while
True
:
chunk
=
f
.
read
(
16
*
1024
)
if
not
chunk
:
break
sha1
.
update
(
chunk
)
assert
(
sha1
.
hexdigest
()
==
"
28ecc82a0c44ae7a461c26112b00f65b9b54e66a
"
)
finally
:
del_file
(
output_prefix1
+
'
.dat
'
)
del_file
(
output_prefix2
+
'
.dat
'
)
del_file
(
output_prefix2
+
'
_upmodel.dat
'
)
# TODO: random test
This diff is collapsed.
Click to expand it.
test/cmp_tool/gen_test_data.c
0 → 100644
+
41
−
0
View file @
d28f80e1
#include
<stdio.h>
#include
<string.h>
#include
"../bench/ref_short_cadence_1_cmp.h"
#include
"../bench/ref_short_cadence_2_cmp.h"
int
main
(
int
argc
,
char
*
argv
[])
{
int
i
;
FILE
*
fp
;
size_t
s
;
if
(
argc
<
1
)
return
1
;
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strstr
(
argv
[
i
],
"ref_short_cadence_1_cmp"
))
{
fp
=
fopen
(
argv
[
i
],
"wb"
);
if
(
!
fp
)
return
1
;
s
=
fwrite
(
ref_short_cadence_1_cmp
,
1
,
ref_short_cadence_1_cmp_len
,
fp
);
fclose
(
fp
);
if
(
s
!=
ref_short_cadence_1_cmp_len
)
return
1
;
}
else
if
(
strstr
(
argv
[
i
],
"ref_short_cadence_2_cmp"
))
{
fp
=
fopen
(
argv
[
i
],
"wb"
);
if
(
!
fp
)
return
1
;
s
=
fwrite
(
ref_short_cadence_2_cmp
,
1
,
ref_short_cadence_2_cmp_len
,
fp
);
fclose
(
fp
);
if
(
s
!=
ref_short_cadence_2_cmp_len
)
return
1
;
}
else
{
fprintf
(
stderr
,
"Unknown test data
\n
"
);
return
1
;
}
}
return
0
;
}
This diff is collapsed.
Click to expand it.
test/cmp_tool/meson.build
+
11
−
1
View file @
d28f80e1
int_test_file
=
files
(
'cmp_tool_integration_test.py'
)
gen_test_data
=
executable
(
'gen_test_data'
,
'gen_test_data.c'
,
c_args
:
'-Wno-overlength-strings'
,
)
test_data
=
custom_target
(
'gen_test_data'
,
output
:
[
'ref_short_cadence_1_cmp.cmp'
,
'ref_short_cadence_2_cmp.cmp'
],
command
:
[
gen_test_data
,
'@OUTPUT@'
]
)
pytest
=
find_program
(
'pytest'
,
required
:
false
)
if
pytest
.
found
()
test
(
'cmp_tool Interface Test'
,
pytest
,
args
:
[
'--color=yes'
,
'-vvv'
,
int_test_file
],
env
:
test_env
,
depends
:
cmp_tool_exe
,
depends
:
[
cmp_tool_exe
,
test_data
],
timeout
:
100
,
workdir
:
meson
.
project_build_root
())
else
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment