~colin-king/ecryptfs/new-tests

« back to all changes in this revision

Viewing changes to tests/kernel/lp-613873.sh

  • Committer: Colin King
  • Date: 2012-03-08 17:14:21 UTC
  • Revision ID: colin.king@canonical.com-20120308171421-5xa9c27dgetcvhib
test case for stat modify time

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
#
 
3
# lp-613873.sh: Test for https://launchpad.net/bugs/613873
 
4
# Author: Colin Ian King <colin.king@canonical.com>
 
5
#
 
6
# Copyright (C) 2012 Canonical, Ltd.
 
7
#
 
8
# This program is free software; you can redistribute it and/or
 
9
# modify it under the terms of the GNU General Public License
 
10
# as published by the Free Software Foundation; either version 2
 
11
# of the License, or (at your option) any later version.
 
12
#
 
13
# This program is distributed in the hope that it will be useful,
 
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
# GNU General Public License for more details.
 
17
#
 
18
# You should have received a copy of the GNU General Public License
 
19
# along with this program; if not, write to the Free Software
 
20
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 
21
 
 
22
test_script_dir=$(dirname $0)
 
23
rc=1
 
24
test_dir=""
 
25
 
 
26
. ${test_script_dir}/../lib/etl_funcs.sh
 
27
 
 
28
test_cleanup()
 
29
{
 
30
        etl_remove_test_dir $test_dir
 
31
        etl_umount
 
32
        etl_lumount
 
33
        etl_unlink_keys
 
34
        exit $rc
 
35
}
 
36
trap test_cleanup 0 1 2 3 15
 
37
 
 
38
etl_add_keys || exit
 
39
etl_lmount || exit
 
40
etl_mount_i || exit
 
41
test_dir=$(etl_create_test_dir `basename $0`) || exit
 
42
 
 
43
#
 
44
# Test that modify time does not change
 
45
#
 
46
date > $test_dir/testfile
 
47
stat_before=`stat -c%Y $test_dir/testfile`
 
48
#
 
49
# Wait a little
 
50
#
 
51
sleep 0.25
 
52
chmod 0600 $test_dir/testfile
 
53
stat_after=`stat -c%Y $test_dir/testfile`
 
54
#
 
55
# Modify time should be the same
 
56
#
 
57
if [ $stat_before -eq $stat_after ]; then
 
58
        rc=0
 
59
fi
 
60
 
 
61
rm $test_dir/testfile
 
62
 
 
63
exit