Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
be6b32cb
Commit
be6b32cb
authored
Aug 14, 2008
by
dinesh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commiting changes for test case of grab_file
parent
cc1e3419
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
17 deletions
+33
-17
ccan/string/test/run-grab.c
ccan/string/test/run-grab.c
+32
-3
ccan/string/test/run.c
ccan/string/test/run.c
+1
-14
No files found.
ccan/string/test/run-grab.c
View file @
be6b32cb
/* This is test for grab_file() function */
/*
/* This is test for grab_file() function
*
* Example:
*
* void *grab_file(const void *ctx, const char *filename)
...
...
@@ -22,4 +21,34 @@
* }
*/
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <sys/stat.h>
#include "string/string.h"
#include "string/string.c"
#include "tap/tap.h"
int
main
(
int
argc
,
char
*
argv
[])
{
unsigned
int
i
;
char
**
split
,
*
str
;
int
length
;
struct
stat
st
;
str
=
grab_file
(
NULL
,
"ccan/string/test/run-grab.c"
);
split
=
strsplit
(
NULL
,
str
,
"
\n
"
,
NULL
);
length
=
strlen
(
split
[
0
]);
ok1
(
streq
(
split
[
0
],
"/* This is test for grab_file() function"
));
for
(
i
=
1
;
split
[
i
];
i
++
)
length
+=
strlen
(
split
[
i
]);
ok1
(
streq
(
split
[
i
-
1
],
"/* End of grab_file() test */"
));
if
(
stat
(
"ccan/string/test/run-grab.c"
,
&
st
)
!=
0
)
err
(
1
,
"Could not stat self"
);
ok1
(
st
.
st_size
==
length
+
i
);
return
0
;
}
/* End of grab_file() test */
ccan/string/test/run.c
View file @
be6b32cb
...
...
@@ -27,9 +27,7 @@ int main(int argc, char *argv[])
char
**
split
,
*
str
;
void
*
ctx
;
char
*
strings
[
NUM_SUBSTRINGS
*
NUM_SUBSTRINGS
];
int
length
;
struct
stat
st
;
n
=
0
;
for
(
i
=
0
;
i
<
NUM_SUBSTRINGS
;
i
++
)
{
for
(
j
=
0
;
j
<
NUM_SUBSTRINGS
;
j
++
)
{
...
...
@@ -117,16 +115,5 @@ int main(int argc, char *argv[])
ok1
(
talloc_parent
(
str
)
==
ctx
);
talloc_free
(
ctx
);
str
=
grab_file
(
NULL
,
"ccan/string/test/run-grab.c"
);
split
=
strsplit
(
NULL
,
str
,
"
\n
"
,
NULL
);
length
=
strlen
(
split
[
0
]);
ok1
(
streq
(
split
[
0
],
"/* This is test for grab_file() function */"
));
for
(
i
=
1
;
split
[
i
];
i
++
)
length
+=
strlen
(
split
[
i
]);
ok1
(
streq
(
split
[
i
-
1
],
"/* End of grab_file() test */"
));
if
(
stat
(
"ccan/string/test/run-grab.c"
,
&
st
)
!=
0
)
err
(
1
,
"Could not stat self"
);
ok1
(
st
.
st_size
==
length
);
return
exit_status
();
}
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