summaryrefslogtreecommitdiff
path: root/tests/generic/477
blob: d1fce7ed927f654ab35493a346254268b0b3e2d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2018 CTERA Networks. All Rights Reserved.
#
# FS QA Test No. 477
#
# Check open by file handle after cycle mount.
#
# This test uses load and store of file handles from a temp file to test
# decoding file handles after cycle mount and after directory renames.
#
. ./common/preamble
_begin_fstest auto quick exportfs

# Import common functions.
. ./common/filter

# real QA test starts here

# Modify as appropriate.
_supported_fs generic
_require_test
# _require_exportfs already requires open_by_handle, but let's not count on it
_require_test_program "open_by_handle"
_require_exportfs

NUMFILES=10
testroot=$TEST_DIR/$seq-dir
testdir=$testroot/testdir

# Create test dir and test files, encode file handles and store to tmp file
create_test_files()
{
	rm -rf $testdir
	mkdir -p $testdir
	$here/src/open_by_handle -cwp -o $tmp.handles_file $testdir $NUMFILES
}

# Decode file handles loaded from tmp file
test_file_handles()
{
	local opt=$1
	local when=$2

	echo test_file_handles after $when
	$here/src/open_by_handle $opt -i $tmp.handles_file $TEST_DIR $NUMFILES
}

# Decode file handles of files/dir after cycle mount
create_test_files
_test_cycle_mount
test_file_handles -rp "cycle mount"

# Decode file handles of files/dir after rename of parent and cycle mount
create_test_files $testdir
rm -rf $testdir.renamed
mv $testdir $testdir.renamed/
_test_cycle_mount
test_file_handles -rp "rename parent"

# Decode file handles of files/dir after rename of grandparent and cycle mount
create_test_files $testdir
rm -rf $testroot.renamed
mv $testroot $testroot.renamed/
_test_cycle_mount
test_file_handles -rp "rename grandparent"

# Decode file handles of files/dir after move to new parent and cycle mount
create_test_files $testdir
rm -rf $testdir.new
mkdir -p $testdir.new
mv $testdir/* $testdir.new/
_test_cycle_mount
test_file_handles -r "move to new parent"

status=0
exit