mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 01:58:54 +01:00 
			
		
		
		
	tests: Fix assertion failures when running fileutils test as root
This commit is contained in:
		
				
					committed by
					
						
						Philip Withnall
					
				
			
			
				
	
			
			
			
						parent
						
							d5d5fb9b5f
						
					
				
				
					commit
					e2973c9a41
				
			@@ -812,6 +812,9 @@ static void
 | 
			
		||||
test_mkdir_with_parents (void)
 | 
			
		||||
{
 | 
			
		||||
  gchar *cwd, *new_path;
 | 
			
		||||
#ifndef G_OS_WIN32
 | 
			
		||||
  gboolean can_override_dac = check_cap_dac_override (NULL);
 | 
			
		||||
#endif
 | 
			
		||||
  if (g_test_verbose())
 | 
			
		||||
    g_printerr ("checking g_mkdir_with_parents() in subdir ./hum/");
 | 
			
		||||
  test_mkdir_with_parents_1 ("hum");
 | 
			
		||||
@@ -838,10 +841,20 @@ test_mkdir_with_parents (void)
 | 
			
		||||
  g_remove ("./test");
 | 
			
		||||
 | 
			
		||||
#ifndef G_OS_WIN32
 | 
			
		||||
  g_assert_cmpint (g_mkdir_with_parents ("/usr/b/c", 0), ==, -1);
 | 
			
		||||
  /* EPERM or EROFS may be returned if the filesystem as a whole is read-only */
 | 
			
		||||
  if (errno != EPERM && errno != EROFS)
 | 
			
		||||
    g_assert_cmpint (errno, ==, EACCES);
 | 
			
		||||
  if (can_override_dac)
 | 
			
		||||
    {
 | 
			
		||||
      g_assert_cmpint (g_mkdir_with_parents ("/usr/b/c", 0), ==, 0);
 | 
			
		||||
      g_remove ("/usr/b/c");
 | 
			
		||||
      g_remove ("/usr/b");
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      g_assert_cmpint (g_mkdir_with_parents ("/usr/b/c", 0), ==, -1);
 | 
			
		||||
      /* EPERM or EROFS may be returned if the filesystem as a whole is read-only */
 | 
			
		||||
      if (errno != EPERM && errno != EROFS)
 | 
			
		||||
        g_assert_cmpint (errno, ==, EACCES);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  g_assert_cmpint (g_mkdir_with_parents (NULL, 0), ==, -1);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user