Skip to content

Commit

Permalink
tests: Fix t_testbed_fs_ops() on NixOS
Browse files Browse the repository at this point in the history
The sandbox has no /sys, thus `trap_path()`'s realpath() fails and
relative paths into /sys don't work. Skip that part of the test in that
case.
  • Loading branch information
martinpitt committed Jan 3, 2021
1 parent 536e632 commit 5b97ebd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test-umockdev-vala.vala
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ assert_listdir (string path, string[] entries)
void
t_testbed_fs_ops ()
{
var have_real_sys = FileUtils.test("/sys", FileTest.EXISTS);
var tb = new UMockdev.Testbed ();
var orig_cwd = Environment.get_current_dir ();

Expand All @@ -150,7 +151,12 @@ t_testbed_fs_ops ()
assert_cmpint (Posix.chdir ("/sys/class"), Op.EQ, -1);
assert_cmpint (Posix.errno, Op.EQ, Posix.ENOENT);

// relative paths into trapped /sys
// relative paths into trapped /sys; this only works if the real /sys exists, as otherwise realpath() fails in trap_path()
if (!have_real_sys) {
stdout.printf ("[SKIP relative paths: environment has no real /sys]\n");
return;
}

assert_cmpint (Posix.chdir ("/"), Op.EQ, 0);
assert_listdir ("sys", {"bus", "devices"});
assert_listdir ("sys/devices", {"dev1"});
Expand Down

0 comments on commit 5b97ebd

Please sign in to comment.