Skip to content

Commit 69a7dec

Browse files
authored
Merge pull request #158 from garlick/kern_tests
testsuite: complete sharness framework conversion
2 parents 087b787 + b2e5c85 commit 69a7dec

260 files changed

Lines changed: 339 additions & 14847 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/main.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ jobs:
4545
run: scripts/check-valgrind.sh
4646
- name: sudo some unit tests
4747
run: scripts/check-root.sh
48-
- name: check with linux/9p
49-
run: sudo make check -C tests/kern
5048
- name: make distcheck
5149
run: make distcheck
5250
- name: get test results on failure

‎.gitignore‎

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -57,65 +57,3 @@ Makefile
5757
*.diff
5858
core.*
5959
*.tar.gz
60-
61-
# project specific
62-
diod/diod
63-
scripts/auto.diod
64-
scripts/diod.init
65-
utils/diodcat
66-
utils/dioddate
67-
utils/diodload
68-
utils/diodls
69-
utils/diodmount
70-
utils/diodshowmount
71-
utils/dtop
72-
73-
tests/*/*.diod
74-
tests/misc/tcap
75-
tests/misc/tconf
76-
tests/misc/tfcntl
77-
tests/misc/tfidpool
78-
tests/misc/tlist
79-
tests/misc/tlua
80-
tests/misc/tnpsrv
81-
tests/misc/tnpsrv2
82-
tests/misc/tnpsrv3
83-
tests/misc/topt
84-
tests/misc/tserialize
85-
tests/misc/tsetfsuid
86-
tests/misc/tsetfsuidsupp
87-
tests/misc/tsetuid
88-
tests/misc/tsuppgrp
89-
tests/user/conjoin
90-
tests/user/tattach
91-
tests/user/tattachmt
92-
tests/user/tflush
93-
tests/user/tgetxattr
94-
tests/user/tmkdir
95-
tests/user/tread
96-
tests/user/tremovexattr
97-
tests/user/tsetxattr
98-
tests/user/tstat
99-
tests/user/twrite
100-
tests/user/txattr
101-
tests/kern/dbench/proto.h
102-
tests/kern/dbench/dbench
103-
tests/kern/fsstress/fsstress
104-
tests/kern/fstest/fstest
105-
tests/kern/fsx/fsx
106-
tests/kern/kconjoin
107-
tests/kern/pathwalk
108-
tests/kern/postmark/postmark
109-
tests/kern/tatomic
110-
tests/kern/tcreate
111-
tests/kern/tfcntl2
112-
tests/kern/tfcntl3
113-
tests/kern/tflock
114-
tests/kern/tflock2
115-
tests/kern/tfsgid
116-
tests/kern/trename
117-
tests/kern/tstat
118-
tests/kern/tstatfs
119-
tests/kern/tsuppgrp
120-
tests/kern/t32.dbench
121-
tests/kern/t33.postmark

‎Makefile.am‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ SUBDIRS = \
22
src \
33
man \
44
etc \
5-
t \
6-
tests
5+
t
76

87
export DEB_BUILD_OPTIONS ?= nocheck terse
98
deb: debian scripts/debbuild.sh

‎configure.ac‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ AC_CONFIG_FILES( \
178178
src/cmd/Makefile \
179179
src/Makefile \
180180
t/Makefile \
181-
tests/Makefile \
182-
tests/kern/Makefile \
183-
tests/kern/fstest/Makefile \
184-
tests/kern/fsx/Makefile \
185-
tests/kern/fsstress/Makefile \
186181
etc/Makefile \
187182
)
188183

‎src/cmd/Makefile.am‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ check_PROGRAMS = \
4949
test_tflush \
5050
test_tattach \
5151
test_loadgen \
52+
test_pathwalk \
53+
test_flock \
54+
test_flock_single \
55+
test_atomic_create \
5256
$(TESTS)
5357

5458
TEST_EXTENSIONS = .t
@@ -76,3 +80,19 @@ test_tattach_LDADD = \
7680
test_loadgen_SOURCES = test/loadgen.c $(common_sources)
7781
test_loadgen_LDADD = \
7882
$(common_ldadd)
83+
84+
test_pathwalk_SOURCES = test/pathwalk.c $(common_sources)
85+
test_pathwalk_LDADD = \
86+
$(common_ldadd)
87+
88+
test_flock_SOURCES = test/flock.c $(common_sources)
89+
test_flock_LDADD = \
90+
$(common_ldadd)
91+
92+
test_flock_single_SOURCES = test/flock_single.c $(common_sources)
93+
test_flock_single_LDADD = \
94+
$(common_ldadd)
95+
96+
test_atomic_create_SOURCES = test/atomic_create.c $(common_sources)
97+
test_atomic_create_LDADD = \
98+
$(common_ldadd)

‎src/cmd/diodcli.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -835,15 +835,15 @@ int cmd_ls (Npcfid *root, int argc, char **argv)
835835
*/
836836
void print_stat (struct stat *sb)
837837
{
838-
printf ("mode=%x owner=%d:%d size=%ju blocks=%ju blocksize=%lu"
839-
" links=%lu device=%x:%x mtime=%ju ctime=%ju atime=%ju\n",
838+
printf ("mode=%x owner=%d:%d size=%ju blocks=%ju blocksize=%ju"
839+
" links=%ju device=%x:%x mtime=%ju ctime=%ju atime=%ju\n",
840840
sb->st_mode,
841841
sb->st_uid,
842842
sb->st_gid,
843843
(uintmax_t)sb->st_size,
844844
(uintmax_t)sb->st_blocks,
845-
sb->st_blksize,
846-
sb->st_nlink,
845+
(uintmax_t)sb->st_blksize,
846+
(uintmax_t)sb->st_nlink,
847847
major (sb->st_rdev),
848848
minor (sb->st_rdev),
849849
(uintmax_t)sb->st_mtime,
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,20 @@
1919

2020
int main(int argc, char *argv[])
2121
{
22-
int fd;
22+
int fd;
2323

24-
/* first create the file */
25-
fd = open(argv[1], O_CREAT|O_WRONLY, 0644);
26-
if (fd < 0) {
27-
perror("open");
28-
return -1;
29-
}
24+
/* first create the file */
25+
fd = open(argv[1], O_CREAT|O_WRONLY, 0644);
26+
if (fd < 0) {
27+
perror("open");
28+
return 1;
29+
}
3030
close(fd);
3131

32-
/* Now opening same file with O_CREAT|O_EXCL should fail */
33-
fd = open(argv[1], O_CREAT|O_EXCL, 0644);
34-
if (fd < 0 && errno == EEXIST)
35-
printf("test case pass\n");
36-
else
37-
printf("test case failed\n");
38-
close(fd);
39-
return 0;
32+
/* Now opening same file with O_CREAT|O_EXCL should fail */
33+
fd = open(argv[1], O_CREAT|O_EXCL, 0644);
34+
if (!(fd < 0 && errno == EEXIST))
35+
return 1;
36+
close(fd);
37+
return 0;
4038
}
41-
Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,106 @@
3333

3434
#include "src/libdiod/diod_log.h"
3535

36-
#include "test.h"
36+
static inline void
37+
_lock (pthread_mutex_t *l)
38+
{
39+
int n = pthread_mutex_lock (l);
40+
if (n)
41+
errn_exit (n, "_lock");
42+
}
43+
static inline void
44+
_unlock (pthread_mutex_t *l)
45+
{
46+
int n = pthread_mutex_unlock (l);
47+
if (n)
48+
errn_exit (n, "_unlock");
49+
}
50+
static inline void
51+
_condsig (pthread_cond_t *c)
52+
{
53+
int n = pthread_cond_signal (c);
54+
if (n)
55+
errn_exit (n, "_condsig");
56+
}
57+
static inline void
58+
_condwait (pthread_cond_t *c, pthread_mutex_t *l)
59+
{
60+
int n = pthread_cond_wait (c, l);
61+
if (n)
62+
errn_exit (n, "_condwait");
63+
}
64+
static inline void
65+
_create (pthread_t *t, void *(f)(void *), void *a)
66+
{
67+
int n = pthread_create (t, NULL, f, a);
68+
if (n)
69+
errn_exit (n,"_create");
70+
}
71+
static inline void
72+
_join (pthread_t t, void **a)
73+
{
74+
int n = pthread_join (t, a);
75+
if (n)
76+
errn_exit (n,"_join");
77+
}
78+
static inline int
79+
_mkstemp (char *p)
80+
{
81+
int fd = mkstemp (p);
82+
if (fd < 0)
83+
err_exit ("_mkstemp");
84+
return fd;
85+
}
86+
static inline void
87+
_fstat (int fd, struct stat *sb)
88+
{
89+
if (fstat (fd, sb) < 0)
90+
err_exit ("_fstat");
91+
}
92+
static inline void
93+
_unlink (char *p)
94+
{
95+
if (unlink (p) < 0)
96+
err_exit ("_unlink");
97+
}
98+
static inline void
99+
_fchown (int fd, uid_t u, gid_t g)
100+
{
101+
if (fchown (fd, u, g) < 0)
102+
err_exit ("_fchown");
103+
}
104+
static inline void
105+
_fchmod (int fd, mode_t m)
106+
{
107+
if (fchmod (fd, m) < 0)
108+
err_exit ("_fchmod");
109+
}
110+
static inline void
111+
_setgroups (size_t s, gid_t *g)
112+
{
113+
if (setgroups (s, g) < 0)
114+
err_exit ("_setgroups");
115+
}
116+
static inline int
117+
_getgroups (size_t s, gid_t *g)
118+
{
119+
int n = getgroups (s, g);
120+
if (n < 0)
121+
err_exit ("_getgroups");
122+
return n;
123+
}
124+
static inline void
125+
_setreuid (uid_t r, uid_t u)
126+
{
127+
if (setreuid (r, u) < 0)
128+
err_exit ("_setreuid");
129+
}
130+
static inline void
131+
_setregid (gid_t r, gid_t g)
132+
{
133+
if (setregid (r, g) < 0)
134+
err_exit ("_setregid");
135+
}
37136

38137
int
39138
main (int argc, char *argv[])

0 commit comments

Comments
 (0)