Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Heatshrink
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grant Kim
Heatshrink
Commits
6d785443
Commit
6d785443
authored
9 years ago
by
Scott Vokes
Browse files
Options
Downloads
Patches
Plain Diff
Vary decoder buffer size in property tests.
This should stress the suspending/resuming as buffers fill more often.
parent
196bfb2d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test_heatshrink_dynamic_theft.c
+46
-3
46 additions, 3 deletions
test_heatshrink_dynamic_theft.c
with
46 additions
and
3 deletions
test_heatshrink_dynamic_theft.c
+
46
−
3
View file @
6d785443
...
...
@@ -28,6 +28,7 @@ typedef struct {
int
limit
;
int
fails
;
int
dots
;
uint16_t
decoder_buffer_size
;
}
test_env
;
typedef
struct
{
...
...
@@ -213,6 +214,44 @@ static struct theft_type_info lookahead_info = {
.
print
=
lookahead_print_cb
,
};
static
void
*
decoder_buf_alloc_cb
(
struct
theft
*
t
,
theft_seed
seed
,
void
*
env
)
{
uint16_t
*
size
=
malloc
(
sizeof
(
uint16_t
));
if
(
size
==
NULL
)
{
return
THEFT_ERROR
;
}
/* Get a random uint16_t, and only keep bottom 0-15 bits at random,
* to bias towards smaller buffers. */
*
size
=
seed
&
0xFFFF
;
*
size
&=
(
1
<<
(
theft_random
(
t
)
&
0xF
))
-
1
;
if
(
*
size
==
0
)
{
*
size
=
1
;
}
// round up to 1
(
void
)
t
;
(
void
)
env
;
return
size
;
}
static
void
decoder_buf_free_cb
(
void
*
instance
,
void
*
env
)
{
free
(
instance
);
(
void
)
env
;
}
static
theft_hash
decoder_buf_hash_cb
(
void
*
instance
,
void
*
env
)
{
(
void
)
env
;
return
*
(
uint16_t
*
)
instance
;
}
static
void
decoder_buf_print_cb
(
FILE
*
f
,
void
*
instance
,
void
*
env
)
{
fprintf
(
f
,
"%u"
,
(
*
(
uint16_t
*
)
instance
));
(
void
)
env
;
}
static
struct
theft_type_info
decoder_buf_info
=
{
.
alloc
=
decoder_buf_alloc_cb
,
.
free
=
decoder_buf_free_cb
,
.
hash
=
decoder_buf_hash_cb
,
.
print
=
decoder_buf_print_cb
,
};
static
theft_progress_callback_res
progress_cb
(
struct
theft_trial_info
*
info
,
void
*
env
)
{
test_env
*
te
=
(
test_env
*
)
env
;
...
...
@@ -383,7 +422,8 @@ static bool do_uncompress(heatshrink_decoder *hsd,
}
static
theft_trial_res
prop_encoded_and_decoded_data_should_match
(
void
*
input
,
void
*
window
,
void
*
lookahead
)
{
prop_encoded_and_decoded_data_should_match
(
void
*
input
,
void
*
window
,
void
*
lookahead
,
void
*
decoder_buffer_size
)
{
assert
(
window
);
uint8_t
window_sz2
=
*
(
uint8_t
*
)
window
;
assert
(
lookahead
);
...
...
@@ -392,7 +432,10 @@ prop_encoded_and_decoded_data_should_match(void *input, void *window, void *look
heatshrink_encoder
*
hse
=
heatshrink_encoder_alloc
(
window_sz2
,
lookahead_sz2
);
if
(
hse
==
NULL
)
{
return
THEFT_TRIAL_ERROR
;
}
heatshrink_decoder
*
hsd
=
heatshrink_decoder_alloc
(
4096
,
window_sz2
,
lookahead_sz2
);
assert
(
decoder_buffer_size
);
uint16_t
buf_size
=
*
(
uint16_t
*
)
decoder_buffer_size
;
heatshrink_decoder
*
hsd
=
heatshrink_decoder_alloc
(
buf_size
,
window_sz2
,
lookahead_sz2
);
if
(
hsd
==
NULL
)
{
return
THEFT_TRIAL_ERROR
;
}
rbuf
*
r
=
(
rbuf
*
)
input
;
...
...
@@ -432,7 +475,7 @@ TEST encoded_and_decoded_data_should_match(void) {
struct
theft_cfg
cfg
=
{
.
name
=
__func__
,
.
fun
=
prop_encoded_and_decoded_data_should_match
,
.
type_info
=
{
&
rbuf_info
,
&
window_info
,
&
lookahead_info
},
.
type_info
=
{
&
rbuf_info
,
&
window_info
,
&
lookahead_info
,
&
decoder_buf_info
,
},
.
seed
=
seed
,
.
trials
=
1000000
,
.
env
=
&
env
,
...
...
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