Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
2e6fdf62
Commit
2e6fdf62
authored
Jul 06, 2022
by
Pau Espin Pedrol
Committed by
Mouse
Jul 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests-skeleteons: Add initial check-APER-support.c
parent
e818e32e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
91 additions
and
0 deletions
+91
-0
tests/tests-skeletons/Makefile.am
tests/tests-skeletons/Makefile.am
+5
-0
tests/tests-skeletons/check-APER-support.c
tests/tests-skeletons/check-APER-support.c
+86
-0
No files found.
tests/tests-skeletons/Makefile.am
View file @
2e6fdf62
...
...
@@ -15,6 +15,7 @@ check_PROGRAMS = \
check-OER-support
\
check-OER-INTEGER
\
check-OER-NativeEnumerated
\
check-APER-support
\
check-UPER-support
\
check-UPER-UniversalString
\
check-UPER-INTEGER
\
...
...
@@ -36,6 +37,7 @@ check_PROGRAMS += \
check-32-OER-support
\
check-32-OER-INTEGER
\
check-32-OER-NativeEnumerated
\
check-32-APER-support
\
check-32-UPER-support
\
check-32-UPER-UniversalString
\
check-32-UPER-INTEGER
\
...
...
@@ -83,6 +85,9 @@ check_32_OER_INTEGER_SOURCES=check-OER-INTEGER.c
check_32_OER_NativeEnumerated_CFLAGS
=
$(CFLAGS_M32)
check_32_OER_NativeEnumerated_LDADD
=
$(LDADD_32)
check_32_OER_NativeEnumerated_SOURCES
=
check-OER-NativeEnumerated.c
check_32_APER_support_CFLAGS
=
$(CFLAGS_M32)
check_32_APER_support_LDADD
=
$(LDADD_32)
check_32_APER_support_SOURCES
=
check-APER-support.c
check_32_UPER_support_CFLAGS
=
$(CFLAGS_M32)
check_32_UPER_support_LDADD
=
$(LDADD_32)
check_32_UPER_support_SOURCES
=
check-UPER-support.c
...
...
tests/tests-skeletons/check-APER-support.c
0 → 100644
View file @
2e6fdf62
#include <assert.h>
#include <aper_support.h>
static
void
put
(
asn_per_outp_t
*
po
,
int
range
,
size_t
length
)
{
fprintf
(
stderr
,
"put(%zd)
\n
"
,
length
);
do
{
int
need_eom
=
123
;
ssize_t
may_write
=
aper_put_length
(
po
,
range
,
length
,
&
need_eom
);
fprintf
(
stderr
,
" put %zu
\n
"
,
may_write
);
assert
(
may_write
>=
0
);
assert
((
size_t
)
may_write
<=
length
);
assert
(
need_eom
!=
123
);
length
-=
may_write
;
if
(
need_eom
)
{
assert
(
length
==
0
);
if
(
aper_put_length
(
po
,
range
,
0
,
0
))
{
assert
(
!
"Unreachable"
);
}
fprintf
(
stderr
,
" put EOM 0
\n
"
);
}
}
while
(
length
);
fprintf
(
stderr
,
"put(...) in %zu bits
\n
"
,
po
->
nboff
);
assert
(
po
->
nboff
!=
0
);
assert
(
po
->
flushed_bytes
==
0
);
}
static
size_t
get
(
asn_per_outp_t
*
po
,
int
range
)
{
asn_bit_data_t
data
;
memset
(
&
data
,
0
,
sizeof
(
data
));
data
.
buffer
=
po
->
tmpspace
;
data
.
nboff
=
0
;
data
.
nbits
=
8
*
(
po
->
buffer
-
po
->
tmpspace
)
+
po
->
nboff
;
fprintf
(
stderr
,
"get(): %s
\n
"
,
asn_bit_data_string
(
&
data
));
size_t
length
=
0
;
int
repeat
=
0
;
do
{
ssize_t
n
=
aper_get_length
(
&
data
,
range
,
-
1
,
&
repeat
);
fprintf
(
stderr
,
" get = %zu +%zd
\n
"
,
length
,
n
);
assert
(
n
>=
0
);
length
+=
n
;
}
while
(
repeat
);
fprintf
(
stderr
,
"get() = %zu
\n
"
,
length
);
return
length
;
}
static
void
check_round_trip
(
int
range
,
size_t
length
)
{
fprintf
(
stderr
,
"
\n
Round-trip for range=%d len=%zu
\n
"
,
range
,
length
);
asn_per_outp_t
po
;
memset
(
&
po
,
0
,
sizeof
(
po
));
po
.
buffer
=
po
.
tmpspace
;
po
.
nbits
=
8
*
sizeof
(
po
.
tmpspace
);
put
(
&
po
,
range
,
length
);
size_t
recovered
=
get
(
&
po
,
range
);
assert
(
recovered
==
length
);
}
/*
* Checks that we can get the PER length that we have just put,
* and receive the same value.
*/
static
void
check_round_trips_range65536
()
{
check_round_trip
(
65536
,
0
);
check_round_trip
(
65536
,
1
);
check_round_trip
(
65536
,
127
);
check_round_trip
(
65536
,
128
);
check_round_trip
(
65536
,
129
);
check_round_trip
(
65536
,
255
);
check_round_trip
(
65536
,
256
);
check_round_trip
(
65536
,
65534
);
check_round_trip
(
65536
,
65535
);
check_round_trip
(
65536
,
65536
);
}
int
main
()
{
check_round_trips_range65536
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment