~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/ls/stat-free-color

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Show that --color need not use stat, as long as we have d_type support.
3
 
 
4
 
# Copyright (C) 2011 Free Software Foundation, Inc.
5
 
 
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.
10
 
 
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.
15
 
 
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
 
19
 
. "${srcdir=.}/init.sh"; path_prepend_ ../src
20
 
print_ver_ ls
21
 
require_strace_ stat
22
 
require_dirent_d_type_
23
 
 
24
 
for i in 1 2 3; do
25
 
  ln -s nowhere dangle-$i || framework_failure_
26
 
done
27
 
 
28
 
# Disable enough features via LS_COLORS so that ls --color
29
 
# can do its job without calling stat (other than the obligatory
30
 
# one-call-per-command-line argument).
31
 
cat <<EOF > color-without-stat || framework_failure_
32
 
RESET 0
33
 
DIR 01;34
34
 
LINK 01;36
35
 
FIFO 40;33
36
 
SOCK 01;35
37
 
DOOR 01;35
38
 
BLK 40;33;01
39
 
CHR 40;33;01
40
 
ORPHAN 00
41
 
SETUID 00
42
 
SETGID 00
43
 
CAPABILITY 00
44
 
STICKY_OTHER_WRITABLE 00
45
 
OTHER_WRITABLE 00
46
 
STICKY 00
47
 
EXEC 00
48
 
MULTIHARDLINK 00
49
 
EOF
50
 
eval $(dircolors -b color-without-stat)
51
 
 
52
 
# The system may perform additional stat-like calls before main.
53
 
# To avoid counting those, first get a baseline count by running
54
 
# ls with only the --help option.  Then, compare that with the
55
 
# invocation under test.
56
 
strace -o log-help -e stat,lstat,stat64,lstat64 ls --help >/dev/null || fail=1
57
 
n_lines_help=$(wc -l < log-help)
58
 
 
59
 
strace -o log -e stat,lstat,stat64,lstat64 ls --color=always . || fail=1
60
 
n_lines=$(wc -l < log)
61
 
 
62
 
n_stat=$(expr $n_lines - $n_lines_help)
63
 
 
64
 
# Expect one or two stat calls.
65
 
case $n_stat in
66
 
  1) ;;
67
 
  *) fail=1; head -n30 log* ;;
68
 
esac
69
 
 
70
 
Exit $fail