Skip to content

Commit 790852f

Browse files
authored
Merge pull request #8403 from sylvestre/ls-others
ls: improve the test when running selinux
2 parents 386acd0 + 7e320a7 commit 790852f

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tests/by-util/test_ls.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55
// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc neee naaaaa nbcdef nfffff dired subdired tmpfs mdir COLORTERM mexe bcdef mfoo
6-
// spell-checker:ignore (words) fakeroot setcap drwxr
6+
// spell-checker:ignore (words) fakeroot setcap drwxr bcdlps
77
#![allow(
88
clippy::similar_names,
99
clippy::too_many_lines,
@@ -1132,7 +1132,7 @@ fn test_ls_long_format() {
11321132
// and followed by a single space.
11331133
// Whatever comes after is irrelevant to this specific test.
11341134
let re = &Regex::new(
1135-
r"\n[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}\.? +\d+ [^ ]+ +[^ ]+( +[^ ]+)? +\d+ [A-Z][a-z]{2} {0,2}\d{0,2} {0,2}[0-9:]+ "
1135+
r"\n[-bcCdDlMnpPsStTx?]([r-][w-][xt-]){3}[.+]? +\d+ [^ ]+ +[^ ]+( +[^ ]+)? +\d+ [A-Z][a-z]{2} {0,2}\d{0,2} {0,2}[0-9:]+ "
11361136
).unwrap();
11371137

11381138
for arg in LONG_ARGS {
@@ -1146,7 +1146,7 @@ fn test_ls_long_format() {
11461146

11471147
// This checks for the line with the .. entry. The uname and group should be digits.
11481148
scene.ucmd().arg("-lan").arg("test-long-dir").succeeds().stdout_matches(&Regex::new(
1149-
r"\nd([r-][w-][xt-]){3}\.? +\d+ \d+ +\d+( +\d+)? +\d+ [A-Z][a-z]{2} {0,2}\d{0,2} {0,2}[0-9:]+ \.\."
1149+
r"\nd([r-][w-][xt-]){3}[.+]? +\d+ \d+ +\d+( +\d+)? +\d+ [A-Z][a-z]{2} {0,2}\d{0,2} {0,2}[0-9:]+ \.\."
11501150
).unwrap());
11511151
}
11521152

@@ -1493,28 +1493,28 @@ fn test_ls_long_formats() {
14931493
// Zero or one "." for indicating a file with security context
14941494

14951495
// Regex for three names, so all of author, group and owner
1496-
let re_three = Regex::new(r"[xrw-]{9}\.? \d ([-0-9_a-z.A-Z]+ ){3}0").unwrap();
1496+
let re_three = Regex::new(r"[xrw-]{9}[.+]? \d ([-0-9_a-z.A-Z]+ ){3}0").unwrap();
14971497

14981498
#[cfg(unix)]
1499-
let re_three_num = Regex::new(r"[xrw-]{9}\.? \d (\d+ ){3}0").unwrap();
1499+
let re_three_num = Regex::new(r"[xrw-]{9}[.+]? \d (\d+ ){3}0").unwrap();
15001500

15011501
// Regex for two names, either:
15021502
// - group and owner
15031503
// - author and owner
15041504
// - author and group
1505-
let re_two = Regex::new(r"[xrw-]{9}\.? \d ([-0-9_a-z.A-Z]+ ){2}0").unwrap();
1505+
let re_two = Regex::new(r"[xrw-]{9}[.+]? \d ([-0-9_a-z.A-Z]+ ){2}0").unwrap();
15061506

15071507
#[cfg(unix)]
1508-
let re_two_num = Regex::new(r"[xrw-]{9}\.? \d (\d+ ){2}0").unwrap();
1508+
let re_two_num = Regex::new(r"[xrw-]{9}[.+]? \d (\d+ ){2}0").unwrap();
15091509

15101510
// Regex for one name: author, group or owner
1511-
let re_one = Regex::new(r"[xrw-]{9}\.? \d [-0-9_a-z.A-Z]+ 0").unwrap();
1511+
let re_one = Regex::new(r"[xrw-]{9}[.+]? \d [-0-9_a-z.A-Z]+ 0").unwrap();
15121512

15131513
#[cfg(unix)]
1514-
let re_one_num = Regex::new(r"[xrw-]{9}\.? \d \d+ 0").unwrap();
1514+
let re_one_num = Regex::new(r"[xrw-]{9}[.+]? \d \d+ 0").unwrap();
15151515

15161516
// Regex for no names
1517-
let re_zero = Regex::new(r"[xrw-]{9}\.? \d 0").unwrap();
1517+
let re_zero = Regex::new(r"[xrw-]{9}[.+]? \d 0").unwrap();
15181518

15191519
scene
15201520
.ucmd()
@@ -2836,7 +2836,8 @@ fn test_ls_inode() {
28362836
at.touch(file);
28372837

28382838
let re_short = Regex::new(r" *(\d+) test_inode").unwrap();
2839-
let re_long = Regex::new(r" *(\d+) [xrw-]{10}\.? \d .+ test_inode").unwrap();
2839+
let re_long =
2840+
Regex::new(r" *(\d+) [-bcdlpsDx]([r-][w-][xt-]){3}[.+]? +\d .+ test_inode").unwrap();
28402841

28412842
let result = scene.ucmd().arg("test_inode").arg("-i").succeeds();
28422843
assert!(re_short.is_match(result.stdout_str()));

0 commit comments

Comments
 (0)