- 23 8月, 2019 1 次提交
-
-
由 Roman Bolshakov 提交于
macOS syscall interface (/usr/lib/system/libsystem_kernel.dylib) has three kinds of stat but only one of them can be used to fill "struct stat": stat$INODE64. virmockstathelpers looks up regular stat instead of stat$INODE64. That causes a failure in qemufirmwaretest because "struct stat" is laid out differently from the values returned by stat. Introduce VIR_MOCK_REAL_INIT_ALIASED that can be used to lookup stat$INODE64 and lstat$INODE64 and use it to setup real functions on macOS. Signed-off-by: NRoman Bolshakov <r.bolshakov@yadro.com>
-
- 19 6月, 2019 1 次提交
-
-
由 Jonathon Jongsma 提交于
Signed-off-by: NJonathon Jongsma <jjongsma@redhat.com> Reviewed-by: NJán Tomko <jtomko@redhat.com> Signed-off-by: NJán Tomko <jtomko@redhat.com>
-
- 03 4月, 2019 1 次提交
-
-
由 Daniel P. Berrangé 提交于
Quite a few of the tests have a need to mock the stat() / lstat() functions and they are taking somewhat different & inconsistent approaches none of which are actually fully correct. This is shown by fact that 'make check' fails on 32-bit hosts. Investigation revealed that the code was calling into the native C library impl, not getting intercepted by our mocks. The POSIX stat() function might resolve to any number of different symbols in the C library. The may be an additional stat64() function exposed by the headers too. On 64-bit hosts the stat & stat64 functions are identical, always refering to the 64-bit ABI. On 32-bit hosts they refer to the 32-bit & 64-bit ABIs respectively. Libvirt uses _FILE_OFFSET_BITS=64 on 32-bit hosts, which causes the C library to transparently rewrite stat() calls to be stat64() calls. Libvirt will never see the 32-bit ABI from the traditional stat() call. We cannot assume this rewriting is done using a macro. It might be, but on GLibC it is done with a magic __asm__ statement to apply the rewrite at link time instead of at preprocessing. In GLibC there may be two additional functions exposed by the headers, __xstat() and __xstat64(). When these exist, stat() and stat64() are transparently rewritten to call __xstat() and __xstat64() respectively. The former symbols will not actally exist in the library at all, only the header. The leading "__" indicates the symbols are a private impl detail of the C library that applications should not care about. Unfortunately, because we are trying to mock replace the C library, we need to know about this internal impl detail. With all this in mind the list of functions we have to mock will depend on several factors - If _FILE_OFFSET_BITS is set, then we are on a 32-bit host, and we only need to mock stat64 and __xstat64. The other stat / __xstat functions exist, but we'll never call them so they can be ignored for mocking. - If _FILE_OFFSET_BITS is not set, then we are on a 64-bit host and we should mock stat, stat64, __xstat & __xstat64. Either may be called by app code. - If __xstat & __xstat64 exist, then stat & stat64 will not exist as symbols in the library, so the latter should not be mocked. The same all applies to lstat() These rules are complex enough that we don't want to duplicate them across every mock file, so this centralizes all the logic in a helper file virmockstathelper.c that should be #included when needed. The code merely need to provide a filename rewriting callback called virMockStatRedirect(). Optionally VIR_MOCK_STAT_HOOK can be defined as a macro if further processing is needed inline. Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
-
- 07 3月, 2019 1 次提交
-
-
由 Michal Privoznik 提交于
It may happen that both symbols are present. Especially when chaining mocks. For instance if a test is using virpcimock and then both stat and __xstat would be present in the address space as virpcimock implements both. Then, if the test would try to use say virfilewrapper (which again uses VIR_MOCK_REAL_INIT_ALT() to init real_stat and real___xstat) it would find stat() from virpcimock and stop there. The virfilewrapper.c:real___xstat wouldn't be initialized and thus it may result in a segfault. The reason for segfault is that sys/stat.h may redefine stat() to call __xstat(). Signed-off-by: NMichal Privoznik <mprivozn@redhat.com> Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
-
- 14 12月, 2018 1 次提交
-
-
由 Daniel P. Berrangé 提交于
Require that all headers are guarded by a symbol named LIBVIRT_$FILENAME where $FILENAME is the uppercased filename, with all characters outside a-z changed into '_'. Note we do not use a leading __ because that is technically a namespace reserved for the toolchain. Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
-
- 05 12月, 2018 1 次提交
-
-
由 Yuri Chornoivan 提交于
Signed-off-by: NYuri Chornoivan <yurchor@ukr.net> Reviewed-by: NJán Tomko <jtomko@redhat.com> Signed-off-by: NJán Tomko <jtomko@redhat.com>
-
- 20 9月, 2018 2 次提交
-
-
由 Erik Skultety 提交于
All of the ones being removed are pulled in by internal.h. The only exception is sanlock which expects the application to include <stdint.h> before sanlock's headers, because sanlock prototypes use fixed width int, but they don't include stdint.h themselves, so we have to leave that one in place. Signed-off-by: NErik Skultety <eskultet@redhat.com> Acked-by: NMichal Privoznik <mprivozn@redhat.com>
-
由 Erik Skultety 提交于
It doesn't really make sense for us to have stdlib.h and string.h but not stdio.h in the internal.h header. Signed-off-by: NErik Skultety <eskultet@redhat.com> Acked-by: NMichal Privoznik <mprivozn@redhat.com>
-
- 03 11月, 2017 1 次提交
-
-
由 Andrea Bolognani 提交于
Right-aligning backslashes when defining macros or using complex commands in Makefiles looks cute, but as soon as any changes is required to the code you end up with either distractingly broken alignment or unnecessarily big diffs where most of the changes are just pushing all backslashes a few characters to one side. Generated using $ git grep -El '[[:blank:]][[:blank:]]\\$' | \ grep -E '*\.([chx]|am|mk)$$' | \ while read f; do \ sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \ done Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
-
- 20 5月, 2016 1 次提交
-
-
由 Michal Privoznik 提交于
It wasn't as great idea as I thought. Thing around stat() are more complicated than that. Therefore we need to revert 86d1705a plus drop use of the macro as introduced in later patches. Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
-
- 14 5月, 2016 2 次提交
-
-
由 Michal Privoznik 提交于
There is some magic going on when it comes to stat() or lstat(). Basically, stat() can either be a regular function, an inline function that calls __xstat(_STAT_VER, ...) or a macro that does the same as the inline func. Don't ask why is that, just read the documentation in sys/stat.h and make sure you have a bucket next to you. Anyway, currently there will not be both stat and __xstat symbols at the same time, as one of them gets overwritten to the other one during compilation. But this is not true anymore once we start chaining our mocking libraries. Therefore we need a wrapper that calls desired function from glibc. Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
-
由 Michal Privoznik 提交于
Instead of introducing our own wrapper for dlsym() we can use the one provided by virmock.h. Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
-
- 27 11月, 2014 1 次提交
-
-
由 Martin Kletzander 提交于
It looks like it was copy-pasted, so in case anyone wonders what some of those methods do without looking at them, and for the sake of completeness, fix them. Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
-
- 12 9月, 2014 1 次提交
-
-
由 Daniel P. Berrange 提交于
Rename the VIR_MOCK_IMPL* macros to VIR_MOCK_WRAP* and add new VIR_MOCK_IMPL macros which let you directly implement overrides in the preloaded source. Signed-off-by: NDaniel P. Berrange <berrange@redhat.com> Signed-off-by: NJim Fehlig <jfehlig@suse.com>
-
- 25 4月, 2014 1 次提交
-
-
由 Daniel P. Berrange 提交于
dlfcn.h does not exist on Win32 so must only be used conditionally Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
-
- 08 4月, 2014 1 次提交
-
-
由 Daniel P. Berrange 提交于
Introduce virmock.h which provides some macros to assist in creation of LD_PRELOAD overrides. When these are used, the LD_PRELOAD code simply has some stubs which forward to a wrapper function inside the main test case. This means that logic for the test no longer has to be split between the virXXXtest.c and virXXXmock.c files. It will also make it possible to provide some common reusable modules for mocking code like DBus. Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
-