1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2016-2018 Oracle and/or its affiliates. All Rights Reserved.
4# Copyright (c) International Business Machines  Corp., 2003
5#
6#  PURPOSE: Runs fsstress over an NFS mount point for a specified amount
7#           of time. The purpose of this test is to stress the NFS kernel
8#           code and possibly the underlying filesystem where the export
9#           resides.  A PASS is if the test completes.
10
11TST_TESTFUNC="do_test"
12TST_CLEANUP="do_cleanup"
13. nfs_lib.sh
14
15THREAD_NUM=${THREAD_NUM:-"2"}
16
17do_cleanup()
18{
19	[ -n "$pids" ] && kill -9 $pids
20	nfs_cleanup
21}
22
23do_test()
24{
25	tst_res TINFO "Starting fsstress processes on NFS mounts"
26
27	local n=0
28	local pids
29	for i in $VERSION; do
30		fsstress -l 1 -d $TST_TMPDIR/$i/$n -n 1000 -p $THREAD_NUM -r -c > /dev/null &
31		pids="$pids $!"
32		n=$(( n + 1 ))
33	done
34
35	tst_res TINFO "waiting for pids:$pids"
36	for p in $pids; do
37		wait $p || tst_brk TFAIL "fsstress process failed"
38		tst_res TINFO "fsstress '$p' completed"
39	done
40	pids=
41
42	tst_res TPASS "all fsstress processes completed on '$n' NFS mounts"
43}
44
45tst_run
46