Skip to content

Commit 5f6a7d0

Browse files
authored
Merge pull request #7440 from sylvestre/selinux
CI: add a new job to test with Selinux
2 parents eb11961 + a193073 commit 5f6a7d0

File tree

6 files changed

+50
-2
lines changed

6 files changed

+50
-2
lines changed

.github/workflows/CICD.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,3 +1034,38 @@ jobs:
10341034
echo "Running tests with --features=$f and --no-default-features"
10351035
cargo test --features=$f --no-default-features
10361036
done
1037+
1038+
test_selinux:
1039+
name: Build/SELinux
1040+
needs: [ min_version, deps ]
1041+
runs-on: ubuntu-latest
1042+
steps:
1043+
- uses: actions/checkout@v4
1044+
with:
1045+
persist-credentials: false
1046+
- uses: dtolnay/rust-toolchain@stable
1047+
- name: Setup Lima
1048+
uses: lima-vm/lima-actions/setup@v1
1049+
id: lima-actions-setup
1050+
- name: Cache ~/.cache/lima
1051+
uses: actions/cache@v4
1052+
with:
1053+
path: ~/.cache/lima
1054+
key: lima-${{ steps.lima-actions-setup.outputs.version }}
1055+
- name: Start Fedora VM with SELinux
1056+
run: limactl start --plain --name=default --cpus=1 --disk=30 --memory=4 --network=lima:user-v2 template://fedora
1057+
- name: Setup SSH
1058+
uses: lima-vm/lima-actions/ssh@v1
1059+
- run: rsync -v -a -e ssh . lima-default:~/work/
1060+
- name: Setup Rust and other build deps in VM
1061+
run: |
1062+
lima sudo dnf install gcc g++ git rustup libselinux-devel clang-devel -y
1063+
lima rustup-init -y --default-toolchain stable
1064+
- name: Verify SELinux Status
1065+
run: |
1066+
lima getenforce
1067+
lima ls -laZ /etc/selinux
1068+
- name: Build and Test with SELinux
1069+
run: |
1070+
lima ls
1071+
lima bash -c "cd work && cargo test --features 'feat_selinux'"

tests/by-util/test_chcon.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ fn valid_reference_repeat_flags() {
527527
}
528528

529529
#[test]
530+
#[ignore = "issue #7443"]
530531
fn valid_reference_repeated_reference() {
531532
let (dir, mut cmd) = at_and_ucmd!();
532533

tests/by-util/test_dd.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// file that was distributed with this source code.
55
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi nabcde nabcdefg abcdefg fifoname seekable
66

7-
#[cfg(unix)]
7+
#[cfg(all(unix, not(feature = "feat_selinux")))]
88
use crate::common::util::run_ucmd_as_root_with_stdin_stdout;
99
use crate::common::util::TestScenario;
1010
#[cfg(all(not(windows), feature = "printf"))]
@@ -1552,6 +1552,8 @@ fn test_nocache_file() {
15521552

15531553
#[test]
15541554
#[cfg(unix)]
1555+
#[cfg(not(feature = "feat_selinux"))]
1556+
// Disabled on SELinux for now
15551557
fn test_skip_past_dev() {
15561558
// NOTE: This test intends to trigger code which can only be reached with root permissions.
15571559
let ts = TestScenario::new(util_name!());
@@ -1573,6 +1575,7 @@ fn test_skip_past_dev() {
15731575

15741576
#[test]
15751577
#[cfg(unix)]
1578+
#[cfg(not(feature = "feat_selinux"))]
15761579
fn test_seek_past_dev() {
15771580
// NOTE: This test intends to trigger code which can only be reached with root permissions.
15781581
let ts = TestScenario::new(util_name!());

tests/by-util/test_df.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ fn test_type_option() {
285285

286286
#[test]
287287
#[cfg(not(any(target_os = "freebsd", target_os = "windows")))] // FIXME: fix test for FreeBSD & Win
288+
#[cfg(not(feature = "feat_selinux"))]
288289
fn test_type_option_with_file() {
289290
let fs_type = new_ucmd!()
290291
.args(&["--output=fstype", "."])

tests/by-util/test_ls.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,8 @@ fn test_ls_long() {
11021102

11031103
#[cfg(not(windows))]
11041104
#[test]
1105+
#[cfg(not(feature = "feat_selinux"))]
1106+
// Disabled on the SELinux runner for now
11051107
fn test_ls_long_format() {
11061108
let scene = TestScenario::new(util_name!());
11071109
let at = &scene.fixtures;
@@ -1474,6 +1476,8 @@ fn test_ls_long_total_size() {
14741476
}
14751477

14761478
#[test]
1479+
#[cfg(not(feature = "feat_selinux"))]
1480+
// Disabled on the SELinux runner for now
14771481
fn test_ls_long_formats() {
14781482
let scene = TestScenario::new(util_name!());
14791483
let at = &scene.fixtures;
@@ -2749,6 +2753,8 @@ fn test_ls_color() {
27492753

27502754
#[cfg(unix)]
27512755
#[test]
2756+
#[cfg(not(feature = "feat_selinux"))]
2757+
// Disabled on the SELinux runner for now
27522758
fn test_ls_inode() {
27532759
let scene = TestScenario::new(util_name!());
27542760
let at = &scene.fixtures;
@@ -5279,6 +5285,8 @@ fn test_acl_display() {
52795285
// setting is also configured).
52805286
#[cfg(unix)]
52815287
#[test]
5288+
#[cfg(not(feature = "feat_selinux"))]
5289+
// Disabled on the SELinux runner for now
52825290
fn test_ls_color_norm() {
52835291
let scene = TestScenario::new(util_name!());
52845292
let at = &scene.fixtures;

tests/by-util/test_runcon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn invalid() {
5151
"unconfined_u:unconfined_r:unconfined_t:s0",
5252
"inexistent-file",
5353
];
54-
new_ucmd!().args(args).fails_with_code(1);
54+
new_ucmd!().args(args).fails_with_code(127);
5555

5656
let args = &["invalid", "/bin/true"];
5757
new_ucmd!().args(args).fails_with_code(1);

0 commit comments

Comments
 (0)