Skip to content

Commit d623bd8

Browse files
8 tests after first read.
1 parent 3fe6ac1 commit d623bd8

File tree

5 files changed

+524
-29
lines changed

5 files changed

+524
-29
lines changed

tests/Makefile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# $NetBSD: Makefile,v 1.2 2012/02/14 00:13:54 martin Exp $
2+
3+
NOMAN= # defined
4+
WARNS=4
5+
6+
.include <bsd.own.mk>
7+
8+
TESTSDIR= ${TESTSBASE}/lib/libc/gen/posix_spawn
9+
10+
TESTS_C= t_spawn
11+
TESTS_C+= t_fileactions
12+
TESTS_C+= t_spawnattr
13+
14+
BINDIR= ${TESTSDIR}
15+
SCRIPTSDIR= ${TESTSDIR}
16+
17+
PROGS= h_fileactions
18+
PROGS+= h_spawn
19+
PROGS+= h_spawnattr
20+
PROGS+= h_fa-spawn
21+
SCRIPTS= h_nonexec h_zero
22+
23+
h_zero:
24+
dd if=/dev/zero of=h_zero bs=1k count=2
25+
chmod a+x h_zero
26+
27+
CLEANFILES+= h_nonexec h_zero
28+
29+
.include <bsd.test.mk>

tests/h_fa-spawn.c

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "h_fa-spawn.h"
2+
3+
off_t
4+
filesize(const char * restrict fname)
5+
{
6+
struct stat st;
7+
int err;
8+
9+
err = stat(fname, &st);
10+
ATF_REQUIRE(err == 0);
11+
return st.st_size;
12+
}
13+
14+
void
15+
empty_outfile(const char *restrict filename)
16+
{
17+
FILE *f;
18+
19+
f = fopen(filename, "w");
20+
ATF_REQUIRE(f != NULL);
21+
fclose(f);
22+
}

tests/h_fa-spawn.h

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <atf-c.h>
2+
3+
#include <sys/stat.h>
4+
5+
#include <stdio.h>
6+
#include <string.h>
7+
8+
off_t filesize(const char * restrict fname);
9+
void empty_outfile(const char *restrict filename);

tests/t_fileactions.c

+2-26
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,16 @@
3131
*/
3232

3333

34-
#include <atf-c.h>
35-
3634
#include <sys/wait.h>
37-
#include <sys/stat.h>
3835

39-
#include <stdio.h>
4036
#include <stdlib.h>
41-
#include <string.h>
4237
#include <errno.h>
4338
#include <fcntl.h>
4439
#include <spawn.h>
4540
#include <unistd.h>
4641

42+
#include "h_fa-spawn.h"
43+
4744

4845
ATF_TC(t_spawn_openmode);
4946

@@ -54,17 +51,6 @@ ATF_TC_HEAD(t_spawn_openmode, tc)
5451
atf_tc_set_md_var(tc, "require.progs", "/bin/cat");
5552
}
5653

57-
static off_t
58-
filesize(const char * restrict fname)
59-
{
60-
struct stat st;
61-
int err;
62-
63-
err = stat(fname, &st);
64-
ATF_REQUIRE(err == 0);
65-
return st.st_size;
66-
}
67-
6854
#define TESTFILE "./the_input_data"
6955
#define CHECKFILE "./the_output_data"
7056
#define TESTCONTENT "marry has a little lamb"
@@ -82,16 +68,6 @@ make_testfile(const char *restrict file)
8268
ATF_REQUIRE(written == strlen(TESTCONTENT));
8369
}
8470

85-
static void
86-
empty_outfile(const char *restrict filename)
87-
{
88-
FILE *f;
89-
90-
f = fopen(filename, "w");
91-
ATF_REQUIRE(f != NULL);
92-
fclose(f);
93-
}
94-
9571
ATF_TC_BODY(t_spawn_openmode, tc)
9672
{
9773
int status, err;

0 commit comments

Comments
 (0)