summaryrefslogtreecommitdiff
path: root/tests/ext4/042
blob: 9e5ef22d7dc1e3ef456fa5fe580b5131c6369b80 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2012 Red Hat, Inc.  All Rights Reserved.
#
# FS QA Test No. ext4/042 (was shared/289)
#
# Test overhead & df output for extN filesystems
#
. ./common/preamble
_begin_fstest auto quick

# Import common functions.
. ./common/filter

# real QA test starts here

# Modify as appropriate.
_supported_fs ext2 ext3 ext4
_require_scratch

_scratch_mkfs >> $seqres.full 2>&1

# Get the honest truth about block counts straight from metadata on disk
TOTAL_BLOCKS=`dumpe2fs -h $SCRATCH_DEV 2>/dev/null \
		| awk '/Block count:/{print $3}'`

FREE_BLOCKS=`dumpe2fs -h $SCRATCH_DEV 2>/dev/null \
		| awk '/Free blocks:/{print $3}'`

OVERHEAD=$(($TOTAL_BLOCKS-$FREE_BLOCKS))

#  bsddf|minixdf
#         Set the behaviour  for  the  statfs  system  call.  The  minixdf
#         behaviour is to return in the f_blocks field the total number of
#         blocks of the filesystem, while the bsddf  behaviour  (which  is
#         the default) is to subtract the overhead blocks used by the ext2
#         filesystem and not available for file storage.

# stat -f output looks like this; we get f_blocks from that, which
# varies depending on the df mount options used below:

#   File: "/mnt/test"
#    ID: affc5f2b2f57652 Namelen: 255     Type: ext2/ext3
# Block size: 4096       Fundamental block size: 4096
# Blocks: Total: 5162741    Free: 5118725    Available: 4856465
# Inodes: Total: 1313760    Free: 1313749

_scratch_mount "-o minixdf"
MINIX_F_BLOCKS=`stat -f $SCRATCH_MNT | awk '/^Blocks/{print $3}'`
_scratch_unmount

_scratch_mount "-o bsddf"
BSD_F_BLOCKS=`stat -f $SCRATCH_MNT | awk '/^Blocks/{print $3}'`
_scratch_unmount

# Echo data to $seqres.full for analysis
echo "Overhead is $OVERHEAD blocks out of $TOTAL_BLOCKS ($FREE_BLOCKS free)" >> $seqres.full
echo "MINIX free blocks $MINIX_F_BLOCKS" >> $seqres.full
echo "BSD free blocks $BSD_F_BLOCKS" >> $seqres.full

# minix should be exactly equal (hence tolerance of 0)
_within_tolerance "minix f_blocks" $MINIX_F_BLOCKS $TOTAL_BLOCKS 0 -v
# bsd should be within ... we'll say 1% for some slop
_within_tolerance "bsd f_blocks" $BSD_F_BLOCKS $(($TOTAL_BLOCKS-$OVERHEAD)) 1% -v

# success, all done
status=0
exit