Debian Codegraph @

testsuite/w.test/w.exp

raw ◀ ▶
1 Debian patch touch this file
1 #
2 # Dejagnu tests for w - part of procps
3 #
4 # FIXME - the user lines only go to idle
5 set w "${topdir}src/w"
6
7 set w_uptime "\\s+\\d{2}:\\d{2}:\\d{2} up (\\d+ days?,)?\\s*\\d+( min|:\\d+), +\\d+ users?, +load average: \[0-9.\]+, \[0-9.\]+, \[0-9.\]+\\s+"
•8 set w_from_header "${w_uptime}USER\\s+TTY\\s+LOGIN@\\s+IDLE\\s+JCPU\\s+PCPU\\s+WHAT\\s+"
9 set w_fromshort_header "${w_uptime}USER\\s+TTY\\s+IDLE\\s+WHAT\\s+"
10 set w_std_header "${w_uptime}USER\\s+TTY\\s+FROM\\s+LOGIN@\\s+IDLE\\s+JCPU\\s+PCPU\\s+WHAT\\s+"
11 set w_short_header "${w_uptime}USER\\s+TTY\\s+FROM\\s+IDLE\\s+WHAT\\s+"
12
13 set w_user "\[A-Za-z0-9_-\]+"
14 set w_tty "\[a-z0-9/]+"
15 set w_from "\[A-Za-z0-9.:-\]*"
16 set w_login "\(\\d+\[A-Z\]\[a-z\]{2}\\d+\|\[A-Z\]\[a-z\]{2}\\d+\|\\d+:\\d+\)"
17 set w_idle "\(\\?xdm\\?\|\\?\|\\d+days\|\\d+:\\d+m?\|\\d+.\\d+s\)"
18 set w_ival7 "\(\\?\|\\d+days\|\\d+:\\d+m?\|\\d+.\\d+s\)"
19 set w_what "\[A-Za-z0-9_\/\\-\]+"
20 set w_pids "-?\\d+/\\d+"
•21 set w_from_userlines "\(${w_user}\\s+${w_tty}\\s+${w_login}\\s+${w_idle}\\s+${w_ival7}\\s+${w_ival7}\\s+${w_what}\\s*\)*"
22 set w_fromshort_userlines "\(${w_user}\\s+${w_tty}\\s+${w_idle}\\s+${w_what}\\s*\)*"
23 set w_std_userlines "\(${w_user}\\s+${w_tty}\\s+${w_from}\\s+${w_login}\\s+${w_idle}\\s+${w_ival7}\\s+${w_ival7}\\s+${w_what}\\s*\)*"
24 set w_short_userlines "\(${w_user}\\s+${w_tty}\\s+${w_from}\\s+${w_idle}\\s+${w_what}\\s*\)*"
25 set w_pid_userlines "\(${w_user}\\s+${w_tty}\\s+${w_idle}\\s+${w_pids}\s+${w_what}\\s*\)*"
26
27 set test "w with no arguments"
28 spawn $w
29 expect_pass "$test" "^${w_std_header}${w_std_userlines}"
30
31
32 set test "w with no headers"
33 spawn $w -h
34 expect_pass "$test" "^${w_std_userlines}"
35
36 set test "w with -u flag"
37 spawn $w -u
38 expect_pass "$test" "^${w_std_header}${w_std_userlines}"
39
40 set test "w with short output"
41 spawn $w -s
42 expect_pass "$test" "^${w_short_header}${w_short_userlines}"
43
44 set test "w with from flag"
45 spawn $w -f
46 expect_pass "$test" "^${w_from_header}${w_from_userlines}"
47
48 set test "w with from and short flags"
49 spawn $w -fs
50 expect_pass "$test" "^${w_fromshort_header}${w_fromshort_userlines}"
51
52 set test "w with short and from flags"
53 spawn $w -sf
54 expect_pass "$test" "^${w_fromshort_header}${w_fromshort_userlines}"
55
56 set test "w with pids display"
57 spawn $w -p
58 expect_pass "$test" "^${w_std_header}${w_pid_userlines}"
59
60 set test "w with terminal mode"
61 spawn $w -t
62 expect_pass "$test" "^${w_std_header}${w_std_userlines}"
63
64 set test "w with terminal mode from and short flags"
65 spawn $w -tfs
66 expect_pass "$test" "^${w_fromshort_header}${w_fromshort_userlines}"
67
68 set test "w with terminal mode and pids flag"
69 spawn $w -tp
70 expect_spawn_retval "$test" 0
71 expect_pass "$test" "^${w_std_header}${w_pid_userlines}"