mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
tests: fix mocking of virFileGetXAttrQuiet on FreeBSD
The qemusecuritytest is failing on FreeBSD 11/12, reporting that files are not correctly restored. Debugging code printfs show that the virFileGetXAttrQuiet mock is returning 0, but the virFileGetXAttr function is seeing -1 as the return value. Essentially there appears to be some kind of optimization between the real virFileGetXAttrQuiet and the real virFileGetXAttr, which breaks when we mock virFileGetXAttrQuiet. Rather than trying to figure out how to avoid this, it is simpler to just mock virFileGetXAttr too since it is very short code. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
586cc43760
commit
b5ee13e329
@ -156,6 +156,34 @@ virFileGetXAttrQuiet(const char *path,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This may look redundant but is needed to work around an
|
||||
* compiler quirk. The call from the real virFileGetXAttr
|
||||
* to the real virFileGetXAttrQuiet has a quirk where the
|
||||
* return value from virFileGetXAttrQuiet gets scrambled
|
||||
* if we mock virFileGetXAttrQuiet, returning -1 instead
|
||||
* of 0 despite succeeding. This happens on FreeBSD 11/12
|
||||
* hosts with CLang, and is suspected to be some kind of
|
||||
* compiler optimization. By mocking this function too we
|
||||
* can workaround it.
|
||||
*/
|
||||
int
|
||||
virFileGetXAttr(const char *path,
|
||||
const char *name,
|
||||
char **value)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((ret = virFileGetXAttrQuiet(path, name, value)) < 0) {
|
||||
virReportSystemError(errno,
|
||||
"Unable to get XATTR %s on %s",
|
||||
name, path);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int virFileSetXAttr(const char *path,
|
||||
const char *name,
|
||||
const char *value)
|
||||
|
Loading…
Reference in New Issue
Block a user