gating: sync with the gating test for c10s

Resolves: RHEL-69609

Signed-off-by: Boyang Xue <bxue@redhat.com>
This commit is contained in:
Boyang Xue 2024-12-02 18:09:07 +08:00
parent 328824e633
commit dffdbb4acc
9 changed files with 2266 additions and 17 deletions

View File

@ -1,7 +1,5 @@
--- !Policy
product_versions:
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

8
plan.fmf Normal file
View File

@ -0,0 +1,8 @@
summary: fuse gating test
execute:
how: tmt
discover:
how: fmf
test: [
"fuse-sanity-test",
]

View File

@ -1,14 +0,0 @@
summary: fuse gating test
discover:
how: fmf
url: https://gitlab.cee.redhat.com/kernel-qe/kernel.git
test: [
"filesystems/fuse/gating/fuse2",
]
environment:
FSTYP: ext4
TEST_GROUP: fuse
AVC_ERROR: +no_avc_check
execute:
how: tmt

View File

@ -0,0 +1,70 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /kernel/filesystems/fuse/gating/fuse2
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2022 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Author and description of the test
AUTHOR=Zorro Lang <zlang@redhat.com>
DESCRIPTION=The gating test case of fuse-2.x
# The name of the test.
export TEST=/kernel/filesystems/fuse/gating/fuse2
# Version of the test. Used with make tag.
export TESTVERSION=1.0
# data files, .c files, scripts anything needed to either compile the test and/or run it.
FILES=$(METADATA) runtest.sh PURPOSE fusexmp_fh.c fusetest.c
run: $(FILES) build
./runtest.sh
build: $(BUILT_FILES) $(FILES)
chmod a+x ./runtest.sh
clean:
rm -f *~
# Include Common Makefile
include /usr/share/rhts/lib/rhts-make.include
# Generate the testinfo.desc here:
$(METADATA): Makefile
@echo "Owner: $(AUTHOR)" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "License: GPLv2" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Description: $(DESCRIPTION)" >> $(METADATA)
@echo "TestTime: 12h" >> $(METADATA)
@echo "RunFor: fuse" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "Requires: fuse" >> $(METADATA)
@echo "Requires: fuse-devel" >> $(METADATA)
@echo "Requires: fuse-libs" >> $(METADATA)
@echo "Requires: pkgconf-pkg-config" >> $(METADATA)
@echo "Requires: gcc" >> $(METADATA)
@echo "Requires: glibc-headers" >> $(METADATA)
@echo "Requires: procps-ng" >> $(METADATA)
rhts-lint $(METADATA)
# The include package trys to install all the potential dependencies.
# Not each them are available on all RHEL old/new systems.

View File

@ -0,0 +1,3 @@
Description:
This's a simple gating test case for fuse-2.x.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,539 @@
/*
Copy from upstream libfuse/example/fusexmp_fh.c, then make some
local changes.
gcc -Wall fusexmp_fh.c `pkg-config fuse --cflags --libs` -lulockmgr -o fusexmp_fh
*/
#define FUSE_USE_VERSION 26
#define _GNU_SOURCE
#include <fuse.h>
#include <ulockmgr.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/xattr.h>
#include <sys/file.h> /* flock(2) */
static int xmp_getattr(const char *path, struct stat *stbuf)
{
int res;
res = lstat(path, stbuf);
if (res == -1)
return -errno;
return 0;
}
static int xmp_fgetattr(const char *path, struct stat *stbuf,
struct fuse_file_info *fi)
{
int res;
(void) path;
res = fstat(fi->fh, stbuf);
if (res == -1)
return -errno;
return 0;
}
static int xmp_access(const char *path, int mask)
{
int res;
res = access(path, mask);
if (res == -1)
return -errno;
return 0;
}
static int xmp_readlink(const char *path, char *buf, size_t size)
{
int res;
res = readlink(path, buf, size - 1);
if (res == -1)
return -errno;
buf[res] = '\0';
return 0;
}
struct xmp_dirp {
DIR *dp;
struct dirent *entry;
off_t offset;
};
static int xmp_opendir(const char *path, struct fuse_file_info *fi)
{
int res;
struct xmp_dirp *d = malloc(sizeof(struct xmp_dirp));
if (d == NULL)
return -ENOMEM;
d->dp = opendir(path);
if (d->dp == NULL) {
res = -errno;
free(d);
return res;
}
d->offset = 0;
d->entry = NULL;
fi->fh = (unsigned long) d;
return 0;
}
static inline struct xmp_dirp *get_dirp(struct fuse_file_info *fi)
{
return (struct xmp_dirp *) (uintptr_t) fi->fh;
}
static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
{
struct xmp_dirp *d = get_dirp(fi);
(void) path;
if (offset != d->offset) {
seekdir(d->dp, offset);
d->entry = NULL;
d->offset = offset;
}
while (1) {
struct stat st;
off_t nextoff;
if (!d->entry) {
d->entry = readdir(d->dp);
if (!d->entry)
break;
}
memset(&st, 0, sizeof(st));
st.st_ino = d->entry->d_ino;
st.st_mode = d->entry->d_type << 12;
nextoff = telldir(d->dp);
if (filler(buf, d->entry->d_name, &st, nextoff))
break;
d->entry = NULL;
d->offset = nextoff;
}
return 0;
}
static int xmp_releasedir(const char *path, struct fuse_file_info *fi)
{
struct xmp_dirp *d = get_dirp(fi);
(void) path;
closedir(d->dp);
free(d);
return 0;
}
static int xmp_mknod(const char *path, mode_t mode, dev_t rdev)
{
int res;
if (S_ISFIFO(mode))
res = mkfifo(path, mode);
else
res = mknod(path, mode, rdev);
if (res == -1)
return -errno;
return 0;
}
static int xmp_mkdir(const char *path, mode_t mode)
{
int res;
res = mkdir(path, mode);
if (res == -1)
return -errno;
return 0;
}
static int xmp_unlink(const char *path)
{
int res;
res = unlink(path);
if (res == -1)
return -errno;
return 0;
}
static int xmp_rmdir(const char *path)
{
int res;
res = rmdir(path);
if (res == -1)
return -errno;
return 0;
}
static int xmp_symlink(const char *from, const char *to)
{
int res;
res = symlink(from, to);
if (res == -1)
return -errno;
return 0;
}
static int xmp_rename(const char *from, const char *to)
{
int res;
res = rename(from, to);
if (res == -1)
return -errno;
return 0;
}
static int xmp_link(const char *from, const char *to)
{
int res;
res = link(from, to);
if (res == -1)
return -errno;
return 0;
}
static int xmp_chmod(const char *path, mode_t mode)
{
int res;
res = chmod(path, mode);
if (res == -1)
return -errno;
return 0;
}
static int xmp_chown(const char *path, uid_t uid, gid_t gid)
{
int res;
res = lchown(path, uid, gid);
if (res == -1)
return -errno;
return 0;
}
static int xmp_truncate(const char *path, off_t size)
{
int res;
res = truncate(path, size);
if (res == -1)
return -errno;
return 0;
}
static int xmp_ftruncate(const char *path, off_t size,
struct fuse_file_info *fi)
{
int res;
(void) path;
res = ftruncate(fi->fh, size);
if (res == -1)
return -errno;
return 0;
}
static int xmp_utimens(const char *path, const struct timespec ts[2])
{
int res;
/* don't use utime/utimes since they follow symlinks */
res = utimensat(0, path, ts, AT_SYMLINK_NOFOLLOW);
if (res == -1)
return -errno;
return 0;
}
static int xmp_create(const char *path, mode_t mode, struct fuse_file_info *fi)
{
int fd;
fd = open(path, fi->flags, mode);
if (fd == -1)
return -errno;
fi->fh = fd;
return 0;
}
static int xmp_open(const char *path, struct fuse_file_info *fi)
{
int fd;
fd = open(path, fi->flags);
if (fd == -1)
return -errno;
fi->fh = fd;
return 0;
}
static int xmp_read(const char *path, char *buf, size_t size, off_t offset,
struct fuse_file_info *fi)
{
int res;
(void) path;
res = pread(fi->fh, buf, size, offset);
if (res == -1)
res = -errno;
return res;
}
static int xmp_read_buf(const char *path, struct fuse_bufvec **bufp,
size_t size, off_t offset, struct fuse_file_info *fi)
{
struct fuse_bufvec *src;
(void) path;
src = malloc(sizeof(struct fuse_bufvec));
if (src == NULL)
return -ENOMEM;
*src = FUSE_BUFVEC_INIT(size);
src->buf[0].flags = FUSE_BUF_IS_FD | FUSE_BUF_FD_SEEK;
src->buf[0].fd = fi->fh;
src->buf[0].pos = offset;
*bufp = src;
return 0;
}
static int xmp_write(const char *path, const char *buf, size_t size,
off_t offset, struct fuse_file_info *fi)
{
int res;
(void) path;
res = pwrite(fi->fh, buf, size, offset);
if (res == -1)
res = -errno;
return res;
}
static int xmp_write_buf(const char *path, struct fuse_bufvec *buf,
off_t offset, struct fuse_file_info *fi)
{
struct fuse_bufvec dst = FUSE_BUFVEC_INIT(fuse_buf_size(buf));
(void) path;
dst.buf[0].flags = FUSE_BUF_IS_FD | FUSE_BUF_FD_SEEK;
dst.buf[0].fd = fi->fh;
dst.buf[0].pos = offset;
return fuse_buf_copy(&dst, buf, FUSE_BUF_SPLICE_NONBLOCK);
}
static int xmp_statfs(const char *path, struct statvfs *stbuf)
{
int res;
res = statvfs(path, stbuf);
if (res == -1)
return -errno;
return 0;
}
static int xmp_flush(const char *path, struct fuse_file_info *fi)
{
int res;
(void) path;
/* This is called from every close on an open file, so call the
close on the underlying filesystem. But since flush may be
called multiple times for an open file, this must not really
close the file. This is important if used on a network
filesystem like NFS which flush the data/metadata on close() */
res = close(dup(fi->fh));
if (res == -1)
return -errno;
return 0;
}
static int xmp_release(const char *path, struct fuse_file_info *fi)
{
(void) path;
close(fi->fh);
return 0;
}
static int xmp_fsync(const char *path, int isdatasync,
struct fuse_file_info *fi)
{
int res;
(void) path;
if (isdatasync)
res = fdatasync(fi->fh);
else
res = fsync(fi->fh);
if (res == -1)
return -errno;
return 0;
}
static int xmp_fallocate(const char *path, int mode,
off_t offset, off_t length, struct fuse_file_info *fi)
{
(void) path;
if (mode)
return -EOPNOTSUPP;
return -posix_fallocate(fi->fh, offset, length);
}
/* xattr operations are optional and can safely be left unimplemented */
static int xmp_setxattr(const char *path, const char *name, const char *value,
size_t size, int flags)
{
int res = lsetxattr(path, name, value, size, flags);
if (res == -1)
return -errno;
return 0;
}
static int xmp_getxattr(const char *path, const char *name, char *value,
size_t size)
{
int res = lgetxattr(path, name, value, size);
if (res == -1)
return -errno;
return res;
}
static int xmp_listxattr(const char *path, char *list, size_t size)
{
int res = llistxattr(path, list, size);
if (res == -1)
return -errno;
return res;
}
static int xmp_removexattr(const char *path, const char *name)
{
int res = lremovexattr(path, name);
if (res == -1)
return -errno;
return 0;
}
static int xmp_lock(const char *path, struct fuse_file_info *fi, int cmd,
struct flock *lock)
{
(void) path;
return ulockmgr_op(fi->fh, cmd, lock, &fi->lock_owner,
sizeof(fi->lock_owner));
}
static int xmp_flock(const char *path, struct fuse_file_info *fi, int op)
{
int res;
(void) path;
res = flock(fi->fh, op);
if (res == -1)
return -errno;
return 0;
}
static struct fuse_operations xmp_oper = {
.getattr = xmp_getattr,
.fgetattr = xmp_fgetattr,
.access = xmp_access,
.readlink = xmp_readlink,
.opendir = xmp_opendir,
.readdir = xmp_readdir,
.releasedir = xmp_releasedir,
.mknod = xmp_mknod,
.mkdir = xmp_mkdir,
.symlink = xmp_symlink,
.unlink = xmp_unlink,
.rmdir = xmp_rmdir,
.rename = xmp_rename,
.link = xmp_link,
.chmod = xmp_chmod,
.chown = xmp_chown,
.truncate = xmp_truncate,
.ftruncate = xmp_ftruncate,
.utimens = xmp_utimens,
.create = xmp_create,
.open = xmp_open,
.read = xmp_read,
.read_buf = xmp_read_buf,
.write = xmp_write,
.write_buf = xmp_write_buf,
.statfs = xmp_statfs,
.flush = xmp_flush,
.release = xmp_release,
.fsync = xmp_fsync,
.fallocate = xmp_fallocate,
.setxattr = xmp_setxattr,
.getxattr = xmp_getxattr,
.listxattr = xmp_listxattr,
.removexattr = xmp_removexattr,
.lock = xmp_lock,
.flock = xmp_flock,
.flag_nullpath_ok = 1,
.flag_utime_omit_ok = 1,
};
int main(int argc, char *argv[])
{
umask(0);
return fuse_main(argc, argv, &xmp_oper, NULL);
}

View File

@ -0,0 +1,17 @@
summary: The gating test case of fuse-2.x
description: This's a simple gating test case for fuse-2.x.
contact: Zorro Lang <zlang@redhat.com>
component:
- fuse
test: ./runtest.sh
framework: shell
recommend:
- fuse
- fuse-devel
- fuse-libs
- pkgconf-pkg-config
- gcc
- glibc-headers
- procps-ng
- beakerlib
duration: 12h

136
tests/fuse-sanity-test/runtest.sh Executable file
View File

@ -0,0 +1,136 @@
#!/bin/bash
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Description: Run for fuse-2.x CI gating test
# Author: Zorro Lang <zlang@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2022 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing
# to use, modify, copy, or redistribute it subject to the terms
# and conditions of the GNU General Public License version 2.
#
# This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TEST_DIR=/mnt/fuse2-gating
status=1
trap "cleanup;" 0 1 2 3 9 15
# test exits here
cleanup()
{
pkill fusetest
umount $TEST_DIR
pkill fusexmp_fh 2>/dev/null
if [ $status -eq 0 ];then
_report "CLEAN" PASS
else
_report "CLEAN" FAIL
fi
exit $status
}
if [ -z "$RECIPEID" -o -z "$TASKID" ]; then
OUTPUTFILE=`pwd`/output.log
echo "No RECIPEID or TASKID, maybe local manual test" | tee $OUTPUTFILE
fi
function echoo()
{
echo $@ | tee -a $OUTPUTFILE
}
# Wrapper to log the output of the command
function xlog()
{
echoo "$@"
$@ 2>&1 | tee -a $OUTPUTFILE
return $?
}
# Wrapper to report_result, clears $OUTPUTFILE
function _report()
{
local what="$FSTYP:$1"
local status="$2"
local score="$3"
test -z "$score" && score=0
echoo "---------------------------------------------"
echoo -e "|Report:\t" "$what\t" "$status\t" "$score|"
echoo "---------------------------------------------"
rhts-report-result "$what" "$status" "$OUTPUTFILE" "$score"
if [ -f "$OUTPUTFILE" ];then
rm -f $OUTPUTFILE
touch $OUTPUTFILE
fi
}
function prepare_test()
{
yum --enablerepo=* -y --nogpgcheck --setopt=skip_if_unavailable=True install fuse fuse-libs fuse-devel \
pkgconf-pkg-config gcc glibc-headers procps-ng
if [ $? -ne 0 ];then
_report prepare_test FAIL
exit 1
fi
_report prepare_test PASS
}
function build_test()
{
xlog gcc -Wall fusexmp_fh.c `pkg-config fuse --cflags --libs` -lulockmgr -o fusexmp_fh
if [ $? -ne 0 ];then
_report build_test:fusexmp_fh FAIL
exit 1
fi
xlog gcc -Wall fusetest.c -o fusetest
if [ $? -ne 0 ];then
_report build_test:fusetest FAIL
exit 1
fi
_report build_test PASS
}
function do_test()
{
mkdir -p $TEST_DIR 2>/dev/null
if [ ! -d $TEST_DIR ];then
_report do_test:TEST_DIR_missing FAIL
exit 1
fi
xlog ./fusexmp_fh $TEST_DIR
if [ $? -ne 0 ] || (! findmnt $TEST_DIR >/dev/null 2>&1 );then
_report do_test:mount FAIL
exit 1
fi
xlog ./fusetest $TEST_DIR
if [ $? -eq 0 ];then
_report do_test:fusetest PASS
else
_report do_test:fusetest FAIL
exit 1
fi
}
prepare_test
build_test
do_test
status=0
exit 0