зеркало из https://github.com/microsoft/BuildXL.git
Merged PR 787486: Fix failed tests on Ubuntu 22.04
There are three failures. 1. Operation is not using OS utilities for probe operation in test. 2. cp command in Ubuntu 22.04 reports read access before probe access, which is weird. The read access will be cached, and sandbox will skip the following probe access on same path. Add a version check before assert the event log id count. 3. fstat is used in Ubuntu 22.04 instead of __fxstat. Assert specific system call based on ubuntu version. Related work items: #2182474
This commit is contained in:
Родитель
06f67cd7c9
Коммит
5799d43c25
|
@ -20,6 +20,7 @@ using Test.BuildXL.TestUtilities;
|
|||
using Test.BuildXL.TestUtilities.Xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
using BuildXL.Interop.Linux;
|
||||
|
||||
namespace Test.BuildXL.Processes
|
||||
{
|
||||
|
@ -136,7 +137,14 @@ namespace Test.BuildXL.Processes
|
|||
// fd = open(symlinkDir/symlink.txt);
|
||||
// __fxstat(fd)
|
||||
// For the __fxstat report, we should associate the file descriptor to the real path, with the symlinks resolved
|
||||
AssertLogContains(GetRegex("__fxstat", realFile));
|
||||
if (Ipc.IsGLibC234OrGreater)
|
||||
{
|
||||
AssertLogContains(GetRegex("fstat", realFile));
|
||||
}
|
||||
else
|
||||
{
|
||||
AssertLogContains(GetRegex("__fxstat", realFile));
|
||||
}
|
||||
|
||||
// At some point (namely, on open) we also should get reports for the intermediate symlinks that got us to the file
|
||||
AssertLogContains(GetRegex("_readlink", link));
|
||||
|
|
|
@ -27,6 +27,7 @@ using BuildXL.Scheduler.Fingerprints;
|
|||
using BuildXL.Scheduler.Tracing;
|
||||
using BuildXL.Storage;
|
||||
using BuildXL.Storage.Fingerprints;
|
||||
using BuildXL.Utilities;
|
||||
using BuildXL.Utilities.Collections;
|
||||
using BuildXL.Utilities.Configuration;
|
||||
using BuildXL.Utilities.Configuration.Mutable;
|
||||
|
@ -1349,7 +1350,10 @@ namespace Test.BuildXL.Scheduler
|
|||
|
||||
// Expecting 3 events, of which 2 are collapsed into one due to similar file access type.
|
||||
// Events ignore the function used for the access.
|
||||
AssertInformationalEventLogged(ProcessesLogEventId.PipProcessDisallowedFileAccessAllowlistedCacheable, count: 2);
|
||||
// In Ubuntu 22.04, it will only be logged once. cp command reports back FILEOP_CREATE_FILE (read) before VNODE_PROBE (probe).
|
||||
// LinuxSandbox cached the FILEOP_CREATE_FILE as read access, and read access implies probe.
|
||||
// So VNODE_PROBE access will be skipped because it is found in cache.
|
||||
AssertInformationalEventLogged(ProcessesLogEventId.PipProcessDisallowedFileAccessAllowlistedCacheable, count: 1, allowMore: true);
|
||||
|
||||
await testRunChecker.VerifyUpToDate(env, pip, Contents);
|
||||
AssertInformationalEventLogged(ProcessesLogEventId.PipProcessDisallowedFileAccessAllowlistedCacheable, count: 0);
|
||||
|
|
|
@ -1431,7 +1431,7 @@ namespace Test.BuildXL.Executables.TestProcess
|
|||
|
||||
private void DoProbe()
|
||||
{
|
||||
File.Exists(PathAsString);
|
||||
FileUtilities.Exists(PathAsString);
|
||||
}
|
||||
|
||||
private void DoDirProbe()
|
||||
|
|
|
@ -44,14 +44,14 @@ namespace BuildXL.Interop.Unix
|
|||
/// glibc 2.34 consolidated libpthread into the libc shared object.
|
||||
/// Use LibC for 2.34 and higher version.
|
||||
/// </summary>
|
||||
public static bool UseLibC()
|
||||
public static bool IsGLibC234OrGreater()
|
||||
{
|
||||
string libcVersionString = Marshal.PtrToStringAnsi(gnu_get_libc_version());
|
||||
var components = libcVersionString.Split('.');
|
||||
int majorVersion = Convert.ToInt32(components[0]);
|
||||
int minorVersion = Convert.ToInt32(components[1]);
|
||||
|
||||
return majorVersion >= 2 && minorVersion >= 34;
|
||||
return majorVersion > 2 || (majorVersion == 2 && minorVersion >= 34);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace BuildXL.Interop.Linux
|
|||
/// <summary>
|
||||
/// Whether to use LibC for semaphore related operations.
|
||||
/// </summary>
|
||||
public static bool UseLibC => UseLibC();
|
||||
public static bool IsGLibC234OrGreater => IsGLibC234OrGreater();
|
||||
|
||||
/// <summary>
|
||||
/// Create or open an existing semaphore.
|
||||
|
@ -36,7 +36,7 @@ namespace BuildXL.Interop.Linux
|
|||
|
||||
// O_CREAT will create a new semaphore if one doesn't exist
|
||||
// O_EXCL will return an error if the specified semaphore name already exists
|
||||
semaphore = UseLibC
|
||||
semaphore = IsGLibC234OrGreater
|
||||
? sem_open_libc(name, (int)(O_Flags.O_CREAT | O_Flags.O_EXCL), mode: /*0644*/ 0x1a4, value: initialCount)
|
||||
: sem_open_libpthread(name, (int)(O_Flags.O_CREAT | O_Flags.O_EXCL), mode: /*0644*/ 0x1a4, value: initialCount);
|
||||
if (semaphore == IntPtr.Zero)
|
||||
|
@ -57,7 +57,7 @@ namespace BuildXL.Interop.Linux
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
int error = UseLibC ? sem_trywait_libc(semaphore) : sem_trywait_libpthread(semaphore);
|
||||
int error = IsGLibC234OrGreater ? sem_trywait_libc(semaphore) : sem_trywait_libpthread(semaphore);
|
||||
if (error != 0)
|
||||
{
|
||||
error = Marshal.GetLastWin32Error();
|
||||
|
@ -76,7 +76,7 @@ namespace BuildXL.Interop.Linux
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
int error = UseLibC ? sem_wait_libc(semaphore) : sem_wait_libpthread(semaphore);
|
||||
int error = IsGLibC234OrGreater ? sem_wait_libc(semaphore) : sem_wait_libpthread(semaphore);
|
||||
if (error != 0)
|
||||
{
|
||||
error = Marshal.GetLastWin32Error();
|
||||
|
@ -95,7 +95,7 @@ namespace BuildXL.Interop.Linux
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
var error = UseLibC ? sem_post_libc(semaphore) : sem_post_libpthread(semaphore);
|
||||
var error = IsGLibC234OrGreater ? sem_post_libc(semaphore) : sem_post_libpthread(semaphore);
|
||||
if (error != 0)
|
||||
{
|
||||
error = Marshal.GetLastWin32Error();
|
||||
|
@ -114,7 +114,7 @@ namespace BuildXL.Interop.Linux
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
var error = UseLibC ? sem_getvalue_libc(semaphore, out value) : sem_getvalue_libpthread(semaphore, out value);
|
||||
var error = IsGLibC234OrGreater ? sem_getvalue_libc(semaphore, out value) : sem_getvalue_libpthread(semaphore, out value);
|
||||
if (error != 0)
|
||||
{
|
||||
error = Marshal.GetLastWin32Error();
|
||||
|
@ -133,7 +133,7 @@ namespace BuildXL.Interop.Linux
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
var error = UseLibC ? sem_close_libc(semaphore) : sem_close_libpthread(semaphore);
|
||||
var error = IsGLibC234OrGreater ? sem_close_libc(semaphore) : sem_close_libpthread(semaphore);
|
||||
if (error != 0)
|
||||
{
|
||||
error = Marshal.GetLastWin32Error();
|
||||
|
@ -152,7 +152,7 @@ namespace BuildXL.Interop.Linux
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
var error = UseLibC ? sem_unlink_libc(name) : sem_unlink_libpthread(name);
|
||||
var error = IsGLibC234OrGreater ? sem_unlink_libc(name) : sem_unlink_libpthread(name);
|
||||
if (error != 0)
|
||||
{
|
||||
error = Marshal.GetLastWin32Error();
|
||||
|
|
Загрузка…
Ссылка в новой задаче