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
c9b2f28b
Commit
c9b2f28b
authored
7 years ago
by
Lev Walkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace incompatible awk with C
parent
3f52df00
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
7 deletions
+80
-7
.gitignore
.gitignore
+3
-0
tests/tests-randomized/Makefile.am
tests/tests-randomized/Makefile.am
+2
-0
tests/tests-randomized/check-bundles.sh
tests/tests-randomized/check-bundles.sh
+2
-7
tests/tests-randomized/test-param-helper.c
tests/tests-randomized/test-param-helper.c
+73
-0
No files found.
.gitignore
View file @
c9b2f28b
...
@@ -47,6 +47,9 @@ stamp-h*
...
@@ -47,6 +47,9 @@ stamp-h*
/tests/tests-skeletons/check-*
/tests/tests-skeletons/check-*
!/tests/tests-skeletons/check-*.c
!/tests/tests-skeletons/check-*.c
# /tests/tests-randomized
/tests/tests-randomized/test-param-helper
# /doc/docsrc
# /doc/docsrc
doc/docsrc/*.aux
doc/docsrc/*.aux
doc/docsrc/*.dvi
doc/docsrc/*.dvi
...
...
This diff is collapsed.
Click to expand it.
tests/tests-randomized/Makefile.am
View file @
c9b2f28b
@CODE_COVERAGE_RULES@
@CODE_COVERAGE_RULES@
check_PROGRAMS
=
test-param-helper
dist_check_SCRIPTS
=
check-bundles.sh
dist_check_SCRIPTS
=
check-bundles.sh
#Filter out the coverage options from CFLAGS as we don't need
#Filter out the coverage options from CFLAGS as we don't need
...
@@ -19,6 +20,7 @@ TESTS_ENVIRONMENT= \
...
@@ -19,6 +20,7 @@ TESTS_ENVIRONMENT= \
FUZZ_TIME
=
"
${FUZZ_TIME}
"
\
FUZZ_TIME
=
"
${FUZZ_TIME}
"
\
ASAN_ENV_FLAGS
=
"@ASAN_ENV_FLAGS@"
\
ASAN_ENV_FLAGS
=
"@ASAN_ENV_FLAGS@"
\
srcdir
=
${srcdir}
\
srcdir
=
${srcdir}
\
builddir
=
${builddir}
\
abs_top_srcdir
=
${abs_top_srcdir}
\
abs_top_srcdir
=
${abs_top_srcdir}
\
abs_top_builddir
=
${abs_top_builddir}
\
abs_top_builddir
=
${abs_top_builddir}
\
${srcdir}
/check-bundles.sh
${srcdir}
/check-bundles.sh
...
...
This diff is collapsed.
Click to expand it.
tests/tests-randomized/check-bundles.sh
View file @
c9b2f28b
...
@@ -29,6 +29,7 @@ usage() {
...
@@ -29,6 +29,7 @@ usage() {
RNDTEMP
=
"
${
RNDTEMP
:-
.tmp.random
}
"
RNDTEMP
=
"
${
RNDTEMP
:-
.tmp.random
}
"
srcdir
=
"
${
srcdir
:-
.
}
"
srcdir
=
"
${
srcdir
:-
.
}
"
builddir
=
"
${
builddir
:-
.
}
"
abs_top_srcdir
=
"
${
abs_top_srcdir
:-
`
pwd
`
/../../
}
"
abs_top_srcdir
=
"
${
abs_top_srcdir
:-
`
pwd
`
/../../
}
"
abs_top_builddir
=
"
${
abs_top_builddir
:-
`
pwd
`
/../../
}
"
abs_top_builddir
=
"
${
abs_top_builddir
:-
`
pwd
`
/../../
}
"
MAKE
=
"
${
MAKE
:-
make
}
"
MAKE
=
"
${
MAKE
:-
make
}
"
...
@@ -140,13 +141,7 @@ get_param() {
...
@@ -140,13 +141,7 @@ get_param() {
default
=
"
$2
"
default
=
"
$2
"
asn
=
"
$3
"
asn
=
"
$3
"
if
nawk
''
>
/dev/null 2>&1
;
then
"
${
builddir
}
/test-param-helper"
"
${
param
}
"
"
${
default
}
"
"
${
asn
}
"
AWK
=
nawk
else
AWK
=
awk
fi
echo
"
$asn
"
|
${
AWK
}
"BEGIN{FS=
\"
[^
${
param
}
=0-9]+
\"
};/
$param
=/{for(i=1;i<=NF;i++)if(substr(
\$
i,0,length(
\"
${
param
}
=
\"
))==
\"
${
param
}
=
\"
)PARAM=substr(
\$
i,length(
\"
${
param
}
=
\"
)+1)}END{if(PARAM)print PARAM;else print
\"
${
default
}
\"
;}"
}
}
# compile_and_test "<text>" "<where found>"
# compile_and_test "<text>" "<where found>"
...
...
This diff is collapsed.
Click to expand it.
tests/tests-randomized/test-param-helper.c
0 → 100644
View file @
c9b2f28b
/*
* Since working awk is not present on every supported platform
* (notably Solaris), and nawk is not the same on Solaris and Linux,
* this program is a replacement for it to extract test parameter from the.
* string specified in the command line.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
static
void
usage
(
const
char
*
progname
)
{
fprintf
(
stderr
,
"Search PARAM=VALUE pattern in the given string
\n
"
);
fprintf
(
stderr
,
"Usage: %s <parameter-name> <default-value> <string>
\n
"
,
progname
);
}
static
const
char
*
search
(
const
char
*
param
,
const
char
*
haystack
)
{
const
char
*
p
=
strstr
(
haystack
,
param
);
if
(
p
&&
p
[
strlen
(
param
)]
==
'='
)
{
const
char
*
param_begin
=
&
p
[
strlen
(
param
)
+
1
];
const
char
*
param_end
=
param_begin
;
for
(
param_end
=
param_begin
;
param_end
;
param_end
++
)
{
switch
(
*
param_end
)
{
case
'0'
...
'9'
:
continue
;
default:
break
;
}
break
;
}
static
char
static_buf
[
64
];
if
((
param_end
-
param_begin
)
<=
0
)
{
fprintf
(
stderr
,
"Parameter %s is malformed after '='
\n
"
,
param
);
return
NULL
;
}
if
((
param_end
-
param_begin
)
>=
(
ssize_t
)
sizeof
(
static_buf
))
{
fprintf
(
stderr
,
"Parameter %s value exceeds buffer size %zu
\n
"
,
param
,
sizeof
(
static_buf
));
return
NULL
;
}
memcpy
(
static_buf
,
param_begin
,
param_end
-
param_begin
);
static_buf
[
param_end
-
param_begin
]
=
'\0'
;
return
static_buf
;
}
else
if
(
p
)
{
fprintf
(
stderr
,
"Parameter %s should contain '='
\n
"
,
param
);
return
NULL
;
}
return
NULL
;
}
int
main
(
int
ac
,
char
**
av
)
{
if
(
ac
!=
4
)
{
usage
(
av
[
0
]);
exit
(
EX_USAGE
);
}
const
char
*
value
=
search
(
av
[
1
],
av
[
3
]);
if
(
value
)
{
printf
(
"%s
\n
"
,
value
);
}
else
{
printf
(
"%s
\n
"
,
av
[
2
]);
}
}
This diff is collapsed.
Click to expand it.
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