Project

General

Profile

Bug #13397 ยป 13397.sh

Peter Tribble, 2021-06-08 08:20 PM

 
1
#!/bin/sh
2
#
3
# simplistic test of ls for bug #13397 
4
#
5

    
6
LS1=${HOME}/Illumos/13397-gate/proto/root_i386/usr/bin/ls
7
LS2=/usr/bin/ls
8

    
9
dols() {
10
  echo "Check $1 $2"
11
  out1=$($LS1 $1 $2)
12
  out2=$($LS2 $1 $2)
13
  if [ "$out1" != "$out2" ]; then
14
      echo FAIL $1 $2
15
  fi
16
}
17

    
18
#
19
# the old version called time() thrice for each argument
20
# the new version calls time() just thrice
21
# we test with 10,000 arguments
22
# therefore the original calls time() 30000 times, the new one just 3
23
#
24
timels1() {
25
    echo 
26
    echo "New time"
27
    nsys0=$(kstat -p cpu::sys:syscall | awk '{s += $NF} END { print s}')
28
    ptime $LS1 $(perl -e 'print "/etc/motd "x10000;') > /dev/null
29
    echo "Old time"
30
    nsys1=$(kstat -p cpu::sys:syscall | awk '{s += $NF} END { print s}')
31
    ptime $LS2 $(perl -e 'print "/etc/motd "x10000;') > /dev/null
32
    nsys2=$(kstat -p cpu::sys:syscall | awk '{s += $NF} END { print s}')
33
    echo 
34
    echo Expect about 30000 difference
35
    nd1=$((nsys1-nsys0))
36
    nd2=$((nsys2-nsys1))
37
    echo New syscalls $nd1
38
    echo Old syscalls $nd2
39
    echo Observed $((nd2-nd1))
40
}
41

    
42
#
43
# same but multiplied by the number of entries in /etc
44
#
45
timels2() {
46
    echo 
47
    echo "New time"
48
    nsys0=$(kstat -p cpu::sys:syscall | awk '{s += $NF} END { print s}')
49
    ptime $LS1 $(perl -e 'print "/etc "x10000;') > /dev/null
50
    echo "Old time"
51
    nsys1=$(kstat -p cpu::sys:syscall | awk '{s += $NF} END { print s}')
52
    ptime $LS2 $(perl -e 'print "/etc "x10000;') > /dev/null
53
    nsys2=$(kstat -p cpu::sys:syscall | awk '{s += $NF} END { print s}')
54
    echo
55
    nf=$(ls /etc|wc -l)
56
    echo Expect about $((nf*30000)) difference
57
    nd1=$((nsys1-nsys0))
58
    nd2=$((nsys2-nsys1))
59
    echo New syscalls $nd1
60
    echo Old syscalls $nd2
61
    echo Observed $((nd2-nd1)) difference
62
}
63

    
64
#
65
# time-based flags l t c u e E
66
#
67

    
68
dols -l /usr/bin
69
dols -lt /usr/bin
70
dols -ltr /usr/bin
71
dols -tr /usr/bin
72
dols -r /usr/bin
73
dols -t /usr/bin
74
dols -cl /usr/bin
75
dols -clt /usr/bin
76
dols -cltr /usr/bin
77
dols -ctr /usr/bin
78
dols -cr /usr/bin
79
dols -ct /usr/bin
80

    
81
dols -e /usr/bin
82
dols -et /usr/bin
83
dols -etr /usr/bin
84
dols -E /usr/bin
85
dols -Et /usr/bin
86
dols -Etr /usr/bin
87

    
88
dols -lu /usr/bin
89
dols -lur /usr/bin
90
dols -ur /usr/bin
91
dols -u /usr/bin
92

    
93
dols "-l --time-style iso" /usr/bin
94
dols "-l --time-style long-iso" /usr/bin
95

    
96
dols -l /system
97
dols -l /system/contract
98
dols -l /system/object
99
dols -l /etc
100
dols -l /etc/mnttab
101
dols -l /var/run
102

    
103
timels1
104
timels2
    (1-1/1)