[Spice-devel] [PATCH vd_agent_linux] test-file-xfers: Make test succeed if run as root

Frediano Ziglio fziglio at redhat.com
Wed Jan 16 11:40:48 UTC 2019


If test is run with root (for instance on Gitlab CI) creating
a file on a directory with no permission will succeed and
test will fail.
Instead create a link trying to create a file in /proc/1
directory (which fails also using root account).

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 tests/test-file-xfers.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

CI results at https://gitlab.freedesktop.org/fziglio/vd_agent/pipelines/15140

diff --git a/tests/test-file-xfers.c b/tests/test-file-xfers.c
index 41d333e..9995336 100644
--- a/tests/test-file-xfers.c
+++ b/tests/test-file-xfers.c
@@ -65,8 +65,8 @@ int main(int argc, char *argv[])
     test_file("subdir/test.txt", "./test-dir/subdir/test.txt");
 
     // create a file in a directory with no permissions
-    assert(system("chmod 555 test-dir/subdir") == 0);
-    test_file("subdir/test2.txt", NULL);
+    assert(system("ln -s /proc/1 test-dir/baddir") == 0);
+    test_file("baddir/test2.txt", NULL);
 
     // try to create a file with a path where there's a file (should fail)
     test_file("test.txt/out", NULL);
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
     // create a file with same name above, should not strip the filename
     test_file("sub.dir/test", "./test-dir/sub.dir/test (1)");
 
-    assert(system("chmod 755 test-dir/subdir && rm -rf test-dir") == 0);
+    assert(system("rm -rf test-dir") == 0);
 
     return 0;
 }
-- 
2.20.1



More information about the Spice-devel mailing list