tests: add test for locale decimal processing
[coreutils.git] / tests / misc / sync.sh
blobd930b0feea86bb38733d17b4d6c7d8a9e0e3059c
1 #!/bin/sh
2 # Test various sync(1) operations
4 # Copyright (C) 2015-2019 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ sync
22 touch file || framework_failure_
24 # fdatasync+syncfs is nonsensical
25 returns_ 1 sync --data --file-system || fail=1
27 # fdatasync needs an operand
28 returns_ 1 sync -d || fail=1
30 # Test syncing of file (fsync) (little side effects)
31 sync file || fail=1
33 # Test syncing of write-only file - which failed since adding argument
34 # support to sync in coreutils-8.24.
35 chmod 0200 file || framework_failure_
36 sync file || fail=1
38 # Ensure multiple args are processed and diagnosed
39 returns_ 1 sync file nofile || fail=1
41 # Ensure inaccessible dirs give an appropriate error
42 mkdir norw || framework_failure_
43 chmod 0 norw || framework_failure_
44 if ! test -r norw; then
45 returns_ 1 sync norw 2>errt
46 # AIX gives "Is a directory"
47 sed 's/Is a directory/Permission denied/' <errt >err || framework_failure_
48 printf "sync: error opening 'norw': Permission denied\n" >exp
49 compare exp err || fail=1
52 if test "$fail" != '1'; then
53 # Ensure a fifo doesn't block
54 mkfifo_or_skip_ fifo
55 returns_ 124 timeout 10 sync fifo && fail=1
58 Exit $fail