File: gfapi-copy-file-range.t

package info (click to toggle)
glusterfs 11.2-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 28,240 kB
  • sloc: ansic: 471,238; sh: 45,610; python: 16,893; perl: 3,328; makefile: 2,014; yacc: 487; ruby: 171; lisp: 124; xml: 75; lex: 61
file content (95 lines) | stat: -rw-r--r-- 2,487 bytes parent folder | download | duplicates (3)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash

. $(dirname $0)/../../include.rc
. $(dirname $0)/../../volume.rc

cleanup;

case $OSTYPE in
Linux)
        ;;
*)
        echo "Skip test: copy_file_range(2) is specific to Linux" >&2
        SKIP_TESTS
        exit 0
        ;;
esac

grep -q copy_file_range /proc/kallsyms
if [ $? -ne 0 ]; then
    echo "Skip test: copy_file_range(2) is not supported by current kernel" >&2
    SKIP_TESTS
    exit 0
fi

mkfs.xfs 2>&1 | grep reflink
if [ $? -ne 0 ]; then
    echo "Skip test: XFS reflink feature is not supported" >&2
    SKIP_TESTS
    exit
fi


TEST glusterd

TEST truncate -s 2G $B0/xfs_image
# for now, a xfs filesystem with reflink support is created.
# In future, better to make changes in MKFS_LOOP so that,
# once can create a xfs filesystem with reflink enabled in
# generic and simple way, instead of doing below steps each
# time.
TEST mkfs.xfs -f -i size=512 -m reflink=1 $B0/xfs_image;

TEST mkdir $B0/bricks
TEST mount -t xfs -o loop $B0/xfs_image $B0/bricks

# Just a single brick volume. More test cases need to be
# added in future for distribute, replicate,
# distributed replicate and distributed replicated sharded
# volumes.
TEST $CLI volume create $V0 $H0:$B0/bricks/brick1;
EXPECT 'Created' volinfo_field $V0 'Status';

TEST $CLI volume start $V0;
EXPECT 'Started' volinfo_field $V0 'Status';

TEST glusterfs --volfile-id=/$V0 --volfile-server=$H0 $M0

TEST dd if=/dev/urandom of=$M0/file bs=1M count=555;

# check for the existence of the created file
TEST stat  $M0/file;

# grab the size of the file
SRC_SIZE=$(stat -c %s $M0/file);

logdir=`gluster --print-logdir`

TEST build_tester $(dirname $0)/glfs-copy-file-range.c -lgfapi

TEST ./$(dirname $0)/glfs-copy-file-range $H0 $V0 $logdir/gfapi-copy-file-range.log /file /new

# check whether the destination file is created or not
TEST stat $M0/new

# check the size of the destination file
DST_SIZE=$(stat -c %s $M0/new);

# The sizes of the source and destination should be same.
# Atleast it ensures that, copy_file_range API is working
# as expected. Whether the actual cloning happened via reflink
# or a read/write happened is different matter.
TEST [ $SRC_SIZE == $DST_SIZE ];

# Go again (test case with already existing target)
# XXX this will fail
# TEST ./$(dirname $0)/glfs-copy-file-range $H0 $V0 $logdir/gfapi-copy-file-range.log /file /new

cleanup_tester $(dirname $0)/glfs-copy-file-range

TEST $CLI volume stop $V0
TEST $CLI volume delete $V0

UMOUNT_LOOP $B0/bricks;

cleanup;