Skip to content

Commit 0f18267

Browse files
authored
Merge pull request #10150 from ChrisDryden/fix-rootfs-gnu-test-v2
ci: add df/skip-rootfs test to SMACK/ROOTFS CI
2 parents b684d16 + fc60a33 commit 0f18267

File tree

3 files changed

+48
-47
lines changed

3 files changed

+48
-47
lines changed

.github/workflows/GnuTests.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ env:
3131
TEST_STTY_FULL_SUMMARY_FILE: 'gnu-stty-full-result.json'
3232
TEST_SELINUX_FULL_SUMMARY_FILE: 'selinux-gnu-full-result.json'
3333
TEST_SELINUX_ROOT_FULL_SUMMARY_FILE: 'selinux-root-gnu-full-result.json'
34-
TEST_SMACK_FULL_SUMMARY_FILE: 'smack-gnu-full-result.json'
34+
TEST_QEMU_FULL_SUMMARY_FILE: 'qemu-gnu-full-result.json'
3535

3636
jobs:
3737
native:
@@ -317,8 +317,8 @@ jobs:
317317
gnu/tests-selinux/*.log
318318
gnu/tests-selinux/*/*.log.gz
319319
320-
smack:
321-
name: Run GNU tests (SMACK)
320+
qemu:
321+
name: Run GNU tests (SMACK/ROOTFS)
322322
runs-on: ubuntu-24.04
323323
steps:
324324
- name: Checkout code (uutils)
@@ -338,30 +338,30 @@ jobs:
338338
run: |
339339
sudo apt-get update
340340
sudo apt-get install -y qemu-system-x86 zstd cpio
341-
- name: Run GNU SMACK tests
341+
- name: Run GNU SMACK/ROOTFS tests
342342
run: |
343343
cd uutils
344-
bash util/run-gnu-tests-smack-ci.sh "$GITHUB_WORKSPACE/gnu" "$GITHUB_WORKSPACE/gnu/tests-smack"
344+
bash util/run-gnu-tests-smack-ci.sh "$GITHUB_WORKSPACE/gnu" "$GITHUB_WORKSPACE/gnu/tests-qemu"
345345
- name: Extract testing info into JSON
346346
run: |
347-
python3 uutils/util/gnu-json-result.py gnu/tests-smack > ${{ env.TEST_SMACK_FULL_SUMMARY_FILE }}
348-
- name: Upload SMACK json results
347+
python3 uutils/util/gnu-json-result.py gnu/tests-qemu > ${{ env.TEST_QEMU_FULL_SUMMARY_FILE }}
348+
- name: Upload SMACK/ROOTFS json results
349349
uses: actions/upload-artifact@v6
350350
with:
351-
name: smack-gnu-full-result
352-
path: ${{ env.TEST_SMACK_FULL_SUMMARY_FILE }}
353-
- name: Compress SMACK test logs
354-
run: gzip gnu/tests-smack/*/*.log 2>/dev/null || true
355-
- name: Upload SMACK test logs
351+
name: qemu-gnu-full-result
352+
path: ${{ env.TEST_QEMU_FULL_SUMMARY_FILE }}
353+
- name: Compress SMACK/ROOTFS test logs
354+
run: gzip gnu/tests-qemu/*/*.log 2>/dev/null || true
355+
- name: Upload SMACK/ROOTFS test logs
356356
uses: actions/upload-artifact@v6
357357
with:
358-
name: smack-test-logs
358+
name: qemu-test-logs
359359
path: |
360-
gnu/tests-smack/*.log
361-
gnu/tests-smack/*/*.log.gz
360+
gnu/tests-qemu/*.log
361+
gnu/tests-qemu/*/*.log.gz
362362
363363
aggregate:
364-
needs: [native, selinux, smack]
364+
needs: [native, selinux, qemu]
365365
permissions:
366366
actions: read # for dawidd6/action-download-artifact to query and download artifacts
367367
contents: read # for actions/checkout to fetch code
@@ -426,10 +426,10 @@ jobs:
426426
name: selinux-root-gnu-full-result
427427
path: results
428428
merge-multiple: true
429-
- name: Download smack json results
429+
- name: Download SMACK/ROOTFS json results
430430
uses: actions/download-artifact@v7
431431
with:
432-
name: smack-gnu-full-result
432+
name: qemu-gnu-full-result
433433
path: results
434434
merge-multiple: true
435435
- name: Extract/summarize testing info

.vscode/cspell.dictionaries/jargon.wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pseudoprime
126126
pseudoprimes
127127
quantiles
128128
readonly
129+
ROOTFS
129130
reparse
130131
rposition
131132
seedable

util/run-gnu-tests-smack-ci.sh

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#!/bin/bash
2-
# Run GNU SMACK tests in QEMU with SMACK-enabled kernel
2+
# Run GNU SMACK/ROOTFS tests in QEMU with SMACK-enabled kernel
33
# Usage: run-gnu-tests-smack-ci.sh [GNU_DIR] [OUTPUT_DIR]
44
# spell-checker:ignore rootfs zstd unzstd cpio newc nographic smackfs devtmpfs tmpfs poweroff libm libgcc libpthread libdl librt sysfs rwxat setuidgid
55
set -e
66

77
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
88
REPO_DIR="$(dirname "$SCRIPT_DIR")"
99
GNU_DIR="${1:-$REPO_DIR/../gnu}"
10-
OUTPUT_DIR="${2:-$REPO_DIR/target/smack-test-results}"
11-
SMACK_DIR="$REPO_DIR/target/smack-test"
10+
OUTPUT_DIR="${2:-$REPO_DIR/target/qemu-test-results}"
11+
QEMU_DIR="$REPO_DIR/target/qemu-test"
1212

13-
echo "Setting up SMACK test environment..."
14-
rm -rf "$SMACK_DIR"
15-
mkdir -p "$SMACK_DIR"/{rootfs/{bin,lib64,proc,sys,dev,tmp,etc,gnu},kernel}
13+
echo "Setting up SMACK/ROOTFS test environment..."
14+
rm -rf "$QEMU_DIR"
15+
mkdir -p "$QEMU_DIR"/{rootfs/{bin,lib64,proc,sys,dev,tmp,etc,gnu},kernel}
1616

1717
# Download Arch Linux kernel (has SMACK built-in)
1818
if [ ! -f /tmp/arch-vmlinuz ]; then
@@ -24,31 +24,31 @@ if [ ! -f /tmp/arch-vmlinuz ]; then
2424
mv "/tmp/$VMLINUZ_PATH" /tmp/arch-vmlinuz
2525
rm -rf /tmp/usr /tmp/arch-kernel.pkg.tar /tmp/arch-kernel.pkg.tar.zst
2626
fi
27-
cp /tmp/arch-vmlinuz "$SMACK_DIR/kernel/vmlinuz"
27+
cp /tmp/arch-vmlinuz "$QEMU_DIR/kernel/vmlinuz"
2828

2929
# Setup busybox
3030
BUSYBOX=/tmp/busybox
3131
[ -f "$BUSYBOX" ] || curl -sL -o "$BUSYBOX" https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox
3232
chmod +x "$BUSYBOX"
33-
cp "$BUSYBOX" "$SMACK_DIR/rootfs/bin/"
34-
(cd "$SMACK_DIR/rootfs/bin" && "$BUSYBOX" --list | xargs -I{} ln -sf busybox {} 2>/dev/null)
33+
cp "$BUSYBOX" "$QEMU_DIR/rootfs/bin/"
34+
(cd "$QEMU_DIR/rootfs/bin" && "$BUSYBOX" --list | xargs -I{} ln -sf busybox {} 2>/dev/null)
3535

3636
# Copy required libraries
3737
for lib in ld-linux-x86-64.so.2 libc.so.6 libm.so.6 libgcc_s.so.1 libpthread.so.0 libdl.so.2 librt.so.1; do
3838
path=$(ldconfig -p | grep "$lib" | head -1 | awk '{print $NF}')
39-
[ -n "$path" ] && [ -f "$path" ] && cp -L "$path" "$SMACK_DIR/rootfs/lib64/" 2>/dev/null || true
39+
[ -n "$path" ] && [ -f "$path" ] && cp -L "$path" "$QEMU_DIR/rootfs/lib64/" 2>/dev/null || true
4040
done
4141

4242
# Create minimal config files
43-
echo -e "root:x:0:0:root:/root:/bin/sh\nnobody:x:65534:65534:nobody:/nonexistent:/bin/sh" > "$SMACK_DIR/rootfs/etc/passwd"
44-
echo -e "root:x:0:\nnobody:x:65534:" > "$SMACK_DIR/rootfs/etc/group"
45-
touch "$SMACK_DIR/rootfs/etc/mtab"
43+
echo -e "root:x:0:0:root:/root:/bin/sh\nnobody:x:65534:65534:nobody:/nonexistent:/bin/sh" > "$QEMU_DIR/rootfs/etc/passwd"
44+
echo -e "root:x:0:\nnobody:x:65534:" > "$QEMU_DIR/rootfs/etc/group"
45+
touch "$QEMU_DIR/rootfs/etc/mtab"
4646

4747
# Copy GNU tests
48-
cp -r "$GNU_DIR/tests" "$SMACK_DIR/rootfs/gnu/"
48+
cp -r "$GNU_DIR/tests" "$QEMU_DIR/rootfs/gnu/"
4949

5050
# Create init script
51-
cat > "$SMACK_DIR/rootfs/init" << 'INIT'
51+
cat > "$QEMU_DIR/rootfs/init" << 'INIT'
5252
#!/bin/sh
5353
mount -t proc proc /proc
5454
mount -t sysfs sys /sys
@@ -73,24 +73,24 @@ fi
7373
echo "EXIT:$?"
7474
poweroff -f
7575
INIT
76-
chmod +x "$SMACK_DIR/rootfs/init"
76+
chmod +x "$QEMU_DIR/rootfs/init"
7777

78-
# Build utilities with SMACK support
79-
echo "Building utilities with SMACK support..."
80-
cargo build --release --manifest-path="$REPO_DIR/Cargo.toml" --package uu_id --features uu_id/smack --package uu_ls --features uu_ls/smack --package uu_mkdir --features uu_mkdir/smack --package uu_mkfifo --features uu_mkfifo/smack --package uu_mknod --features uu_mknod/smack
78+
# Build utilities for SMACK/ROOTFS tests
79+
echo "Building utilities for SMACK/ROOTFS tests..."
80+
cargo build --release --manifest-path="$REPO_DIR/Cargo.toml" --package uu_id --features uu_id/smack --package uu_ls --features uu_ls/smack --package uu_mkdir --features uu_mkdir/smack --package uu_mkfifo --features uu_mkfifo/smack --package uu_mknod --features uu_mknod/smack --package uu_df
8181

82-
# Find SMACK tests
83-
SMACK_TESTS=$(grep -l 'require_smack_' -r "$GNU_DIR/tests/" 2>/dev/null || true)
84-
[ -z "$SMACK_TESTS" ] && { echo "No SMACK tests found"; exit 0; }
82+
# Find SMACK tests and tests requiring rootfs in mtab (only available in QEMU environment)
83+
QEMU_TESTS=$(grep -l -E 'require_smack_|rootfs in mtab' -r "$GNU_DIR/tests/" 2>/dev/null | sort -u || true)
84+
[ -z "$QEMU_TESTS" ] && { echo "No SMACK/ROOTFS tests found"; exit 0; }
8585

86-
echo "Found $(echo "$SMACK_TESTS" | wc -l) SMACK tests"
86+
echo "Found $(echo "$QEMU_TESTS" | wc -l) SMACK/ROOTFS tests"
8787

8888
# Create output directory
8989
rm -rf "$OUTPUT_DIR"
9090
mkdir -p "$OUTPUT_DIR"
9191

9292
# Run each test
93-
for TEST_PATH in $SMACK_TESTS; do
93+
for TEST_PATH in $QEMU_TESTS; do
9494
TEST_REL="${TEST_PATH#"$GNU_DIR"/tests/}"
9595
TEST_DIR=$(dirname "$TEST_REL")
9696
TEST_NAME=$(basename "$TEST_REL" .sh)
@@ -104,12 +104,12 @@ for TEST_PATH in $SMACK_TESTS; do
104104
fi
105105

106106
# Create working copy
107-
WORK="/tmp/smack-test-$$"
107+
WORK="/tmp/qemu-test-$$"
108108
rm -rf "$WORK" "$WORK.gz"
109-
cp -a "$SMACK_DIR/rootfs" "$WORK"
109+
cp -a "$QEMU_DIR/rootfs" "$WORK"
110110

111-
# Copy built utilities with SMACK support
112-
for U in id ls mkdir mkfifo mknod; do
111+
# Copy built utilities for SMACK/ROOTFS tests
112+
for U in id ls mkdir mkfifo mknod df; do
113113
rm -f "$WORK/bin/$U"
114114
cp "$REPO_DIR/target/release/$U" "$WORK/bin/$U"
115115
done
@@ -126,7 +126,7 @@ for TEST_PATH in $SMACK_TESTS; do
126126
(cd "$WORK" && find . | cpio -o -H newc 2>/dev/null | gzip > "$WORK.gz")
127127

128128
OUTPUT=$(timeout 120 qemu-system-x86_64 \
129-
-kernel "$SMACK_DIR/kernel/vmlinuz" \
129+
-kernel "$QEMU_DIR/kernel/vmlinuz" \
130130
-initrd "$WORK.gz" \
131131
-append "console=ttyS0 quiet panic=-1 security=smack lsm=smack" \
132132
-nographic -m 256M -no-reboot 2>&1) || true

0 commit comments

Comments
 (0)