Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ jobs:
run: scripts/check-valgrind.sh
- name: sudo some unit tests
run: scripts/check-root.sh
- name: check with linux/9p
run: sudo make check -C tests/kern
Comment on lines -48 to -49
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message typo: expicit

- name: make distcheck
run: make distcheck
- name: get test results on failure
Expand Down
62 changes: 0 additions & 62 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,65 +57,3 @@ Makefile
*.diff
core.*
*.tar.gz

# project specific
diod/diod
scripts/auto.diod
scripts/diod.init
utils/diodcat
utils/dioddate
utils/diodload
utils/diodls
utils/diodmount
utils/diodshowmount
utils/dtop

tests/*/*.diod
tests/misc/tcap
tests/misc/tconf
tests/misc/tfcntl
tests/misc/tfidpool
tests/misc/tlist
tests/misc/tlua
tests/misc/tnpsrv
tests/misc/tnpsrv2
tests/misc/tnpsrv3
tests/misc/topt
tests/misc/tserialize
tests/misc/tsetfsuid
tests/misc/tsetfsuidsupp
tests/misc/tsetuid
tests/misc/tsuppgrp
tests/user/conjoin
tests/user/tattach
tests/user/tattachmt
tests/user/tflush
tests/user/tgetxattr
tests/user/tmkdir
tests/user/tread
tests/user/tremovexattr
tests/user/tsetxattr
tests/user/tstat
tests/user/twrite
tests/user/txattr
tests/kern/dbench/proto.h
tests/kern/dbench/dbench
tests/kern/fsstress/fsstress
tests/kern/fstest/fstest
tests/kern/fsx/fsx
tests/kern/kconjoin
tests/kern/pathwalk
tests/kern/postmark/postmark
tests/kern/tatomic
tests/kern/tcreate
tests/kern/tfcntl2
tests/kern/tfcntl3
tests/kern/tflock
tests/kern/tflock2
tests/kern/tfsgid
tests/kern/trename
tests/kern/tstat
tests/kern/tstatfs
tests/kern/tsuppgrp
tests/kern/t32.dbench
tests/kern/t33.postmark
3 changes: 1 addition & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ SUBDIRS = \
src \
man \
etc \
t \
tests
t

export DEB_BUILD_OPTIONS ?= nocheck terse
deb: debian scripts/debbuild.sh
Expand Down
5 changes: 0 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ AC_CONFIG_FILES( \
src/cmd/Makefile \
src/Makefile \
t/Makefile \
tests/Makefile \
tests/kern/Makefile \
tests/kern/fstest/Makefile \
tests/kern/fsx/Makefile \
tests/kern/fsstress/Makefile \
etc/Makefile \
)

Expand Down
20 changes: 20 additions & 0 deletions src/cmd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ check_PROGRAMS = \
test_tflush \
test_tattach \
test_loadgen \
test_pathwalk \
test_flock \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit message typo: 'the ... test live' -> ' the ... tests live'

test_flock_single \
test_atomic_create \
$(TESTS)

TEST_EXTENSIONS = .t
Expand Down Expand Up @@ -76,3 +80,19 @@ test_tattach_LDADD = \
test_loadgen_SOURCES = test/loadgen.c $(common_sources)
test_loadgen_LDADD = \
$(common_ldadd)

test_pathwalk_SOURCES = test/pathwalk.c $(common_sources)
test_pathwalk_LDADD = \
$(common_ldadd)

test_flock_SOURCES = test/flock.c $(common_sources)
test_flock_LDADD = \
$(common_ldadd)

test_flock_single_SOURCES = test/flock_single.c $(common_sources)
test_flock_single_LDADD = \
$(common_ldadd)

test_atomic_create_SOURCES = test/atomic_create.c $(common_sources)
test_atomic_create_LDADD = \
$(common_ldadd)
8 changes: 4 additions & 4 deletions src/cmd/diodcli.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,15 +835,15 @@ int cmd_ls (Npcfid *root, int argc, char **argv)
*/
void print_stat (struct stat *sb)
{
printf ("mode=%x owner=%d:%d size=%ju blocks=%ju blocksize=%lu"
" links=%lu device=%x:%x mtime=%ju ctime=%ju atime=%ju\n",
printf ("mode=%x owner=%d:%d size=%ju blocks=%ju blocksize=%ju"
" links=%ju device=%x:%x mtime=%ju ctime=%ju atime=%ju\n",
sb->st_mode,
sb->st_uid,
sb->st_gid,
(uintmax_t)sb->st_size,
(uintmax_t)sb->st_blocks,
sb->st_blksize,
sb->st_nlink,
(uintmax_t)sb->st_blksize,
(uintmax_t)sb->st_nlink,
major (sb->st_rdev),
minor (sb->st_rdev),
(uintmax_t)sb->st_mtime,
Expand Down
29 changes: 13 additions & 16 deletions tests/kern/tatomic.c → src/cmd/test/atomic_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,20 @@

int main(int argc, char *argv[])
{
int fd;
int fd;

/* first create the file */
fd = open(argv[1], O_CREAT|O_WRONLY, 0644);
if (fd < 0) {
perror("open");
return -1;
}
/* first create the file */
fd = open(argv[1], O_CREAT|O_WRONLY, 0644);
if (fd < 0) {
perror("open");
return 1;
}
close(fd);

/* Now opening same file with O_CREAT|O_EXCL should fail */
fd = open(argv[1], O_CREAT|O_EXCL, 0644);
if (fd < 0 && errno == EEXIST)
printf("test case pass\n");
else
printf("test case failed\n");
close(fd);
return 0;
/* Now opening same file with O_CREAT|O_EXCL should fail */
fd = open(argv[1], O_CREAT|O_EXCL, 0644);
if (!(fd < 0 && errno == EEXIST))
return 1;
close(fd);
return 0;
}

101 changes: 100 additions & 1 deletion tests/kern/tflock.c → src/cmd/test/flock.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,106 @@

#include "src/libdiod/diod_log.h"

#include "test.h"
static inline void
_lock (pthread_mutex_t *l)
{
int n = pthread_mutex_lock (l);
if (n)
errn_exit (n, "_lock");
}
static inline void
_unlock (pthread_mutex_t *l)
{
int n = pthread_mutex_unlock (l);
if (n)
errn_exit (n, "_unlock");
}
static inline void
_condsig (pthread_cond_t *c)
{
int n = pthread_cond_signal (c);
if (n)
errn_exit (n, "_condsig");
}
static inline void
_condwait (pthread_cond_t *c, pthread_mutex_t *l)
{
int n = pthread_cond_wait (c, l);
if (n)
errn_exit (n, "_condwait");
}
static inline void
_create (pthread_t *t, void *(f)(void *), void *a)
{
int n = pthread_create (t, NULL, f, a);
if (n)
errn_exit (n,"_create");
}
static inline void
_join (pthread_t t, void **a)
{
int n = pthread_join (t, a);
if (n)
errn_exit (n,"_join");
}
static inline int
_mkstemp (char *p)
{
int fd = mkstemp (p);
if (fd < 0)
err_exit ("_mkstemp");
return fd;
}
static inline void
_fstat (int fd, struct stat *sb)
{
if (fstat (fd, sb) < 0)
err_exit ("_fstat");
}
static inline void
_unlink (char *p)
{
if (unlink (p) < 0)
err_exit ("_unlink");
}
static inline void
_fchown (int fd, uid_t u, gid_t g)
{
if (fchown (fd, u, g) < 0)
err_exit ("_fchown");
}
static inline void
_fchmod (int fd, mode_t m)
{
if (fchmod (fd, m) < 0)
err_exit ("_fchmod");
}
static inline void
_setgroups (size_t s, gid_t *g)
{
if (setgroups (s, g) < 0)
err_exit ("_setgroups");
}
static inline int
_getgroups (size_t s, gid_t *g)
{
int n = getgroups (s, g);
if (n < 0)
err_exit ("_getgroups");
return n;
}
static inline void
_setreuid (uid_t r, uid_t u)
{
if (setreuid (r, u) < 0)
err_exit ("_setreuid");
}
static inline void
_setregid (gid_t r, gid_t g)
{
if (setregid (r, g) < 0)
err_exit ("_setregid");
}

int
main (int argc, char *argv[])
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion t/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ TESTSCRIPTS = \
t0021-postmark.t \
t0022-scrub.t \
t0023-rsync.t \
t0024-selfhost.t
t0024-selfhost.t \
t0025-pathwalk.t

# make check runs these TAP tests directly (both scripts and programs)
TESTS = \
Expand Down
54 changes: 54 additions & 0 deletions t/t0010-v9fs-runasuser.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ umountcmd="$SUDO umount --lazy"
mountcmd="$SUDO mount -n -t 9p"
mountopts="trans=unix,uname=$(id -un)"

test_flock=$SHARNESS_BUILD_DIRECTORY/src/cmd/test_flock
test_flock_single=$SHARNESS_BUILD_DIRECTORY/src/cmd/test_flock_single
test_atomic_create=$SHARNESS_BUILD_DIRECTORY/src/cmd/test_atomic_create

# usage: create_file name [block_count]
create_file() {
local name=$1
Expand Down Expand Up @@ -156,6 +160,12 @@ test_expect_success FLOCK 'flock-write a file' '
test_expect_success FLOCK 'flock-read a file' '
$PATH_FLOCK -s mnt/dir/d true
'
test_expect_success 'run flock concurrency test' '
$test_flock mnt/dir/d
'
test_expect_success 'run flock single-process test' '
$test_flock_single mnt/dir/d
'
test_expect_success 'chown a file to current owner' '
chown $(id -u) mnt/dir/d
'
Expand Down Expand Up @@ -231,6 +241,50 @@ test_expect_success 'root cannot create file' '
test_must_fail $SUDO touch mnt/dir/asroot 2>rootwrite.err &&
grep "not permitted" rootwrite.err
'

# Usage: makefiles dir
makefiles () {
local path=$1
local seq=0
local rc=0
local u g o
for u in 0 1 2 3 4 5 6 7; do
for g in 0 1 2 3 4 5 6 7; do
for o in 0 1 2 3 4 5 6 7; do
install -m 0$u$g$o /dev/null $path/f.$seq || rc=1
seq=$(($seq + 1))
done
done
done
return $rc
}
# Usage: checkmodes dir
checkmodes () {
local path=$1
local seq=0
local rc=0
local u g o
for u in 0 1 2 3 4 5 6 7; do
for g in 0 1 2 3 4 5 6 7; do
for o in 0 1 2 3 4 5 6 7; do
test "$($PATH_STAT -c "%a" $path/f.$seq)" -eq "$u$g$o" || rc=1
seq=$(($seq + 1))
done
done
done
return $rc
}

test_expect_success 'atomically create files with all the modes' '
mkdir mnt/ptest &&
makefiles mnt/ptest
'
test_expect_success 'all the modes were set on the server' '
checkmodes exp/ptest
'
test_expect_success 'creating a file with O_CREAT|OEXCL fails if file exists' '
$test_atomic_create mnt/atomic_create
'
test_expect_success 'mount filesystem with access=any on mnt2' '
$mountcmd \
-oaname=$exportdir,$mountopts,access=any \
Expand Down
Loading