Skip test that fails with EPERM
This commit is contained in:
parent
3f8f3d8deb
commit
0f73587c24
43
0001-Skip-test-if-unshare-fails.patch
Normal file
43
0001-Skip-test-if-unshare-fails.patch
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
From dd796f67352de9a8b3602a20d37d68b3a903cc78 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
||||||
|
Date: Wed, 1 Dec 2021 16:15:08 +0100
|
||||||
|
Subject: [PATCH] Skip test if unshare fails
|
||||||
|
|
||||||
|
---
|
||||||
|
tests/test_cases.rs | 14 +++++++++++---
|
||||||
|
1 file changed, 11 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tests/test_cases.rs b/tests/test_cases.rs
|
||||||
|
index 66023137e6..1d8c5e6d65 100644
|
||||||
|
--- a/tests/test_cases.rs
|
||||||
|
+++ b/tests/test_cases.rs
|
||||||
|
@@ -6,18 +6,26 @@ use anyhow::Result;
|
||||||
|
use fs_extra::dir::{copy, CopyOptions};
|
||||||
|
use std::fs;
|
||||||
|
use std::io::{self, Write};
|
||||||
|
+use log::warn;
|
||||||
|
use std::path::Path;
|
||||||
|
-use std::process::Command;
|
||||||
|
+use std::process::{Command, exit};
|
||||||
|
use tempfile::TempDir;
|
||||||
|
|
||||||
|
#[ctor::ctor]
|
||||||
|
fn unshorn() {
|
||||||
|
- use nix::{mount, sched, unistd};
|
||||||
|
+ use nix::{errno, mount, sched, unistd};
|
||||||
|
use std::os::unix::fs::symlink;
|
||||||
|
|
||||||
|
let (uid, gid) = (unistd::geteuid(), unistd::getegid());
|
||||||
|
if !uid.is_root() {
|
||||||
|
- sched::unshare(sched::CloneFlags::CLONE_NEWUSER).expect("unshare(NEWUSER)");
|
||||||
|
+ match sched::unshare(sched::CloneFlags::CLONE_NEWUSER) {
|
||||||
|
+ Ok(_) => {}
|
||||||
|
+ Err(errno::Errno::EPERM) => {
|
||||||
|
+ warn!("No permission to unshare namespace, skipping tests");
|
||||||
|
+ exit(0);
|
||||||
|
+ }
|
||||||
|
+ Err(err) => panic!("Unexpected error: {}", err),
|
||||||
|
+ }
|
||||||
|
fs::write("/proc/self/setgroups", b"deny").unwrap();
|
||||||
|
fs::write("/proc/self/uid_map", format!("0 {} 1", uid)).unwrap();
|
||||||
|
fs::write("/proc/self/gid_map", format!("0 {} 1", gid)).unwrap();
|
@ -14,6 +14,8 @@ URL: https://crates.io/crates/zram-generator
|
|||||||
Source: %{crates_source}
|
Source: %{crates_source}
|
||||||
Source1: zram-generator.conf
|
Source1: zram-generator.conf
|
||||||
|
|
||||||
|
Patch1: 0001-Skip-test-if-unshare-fails.patch
|
||||||
|
|
||||||
ExclusiveArch: %{rust_arches}
|
ExclusiveArch: %{rust_arches}
|
||||||
|
|
||||||
BuildRequires: rust-packaging
|
BuildRequires: rust-packaging
|
||||||
|
Loading…
Reference in New Issue
Block a user