1. 03 4月, 2019 2 次提交
    • D
    • D
      tests: fix mocking of stat() / lstat() functions · ff376c62
      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>
      ff376c62
  2. 25 3月, 2019 1 次提交
    • E
      snapshot: Add tests of virsh -c test:///default snapshot* · 280a2b41
      Eric Blake 提交于
      Had this been in place earlier, I would have avoided the bugs in
      commit 0baf6945 and 55c2ab3e. Writing the test required me to extend
      the power of virsh - creating enough snapshots to cause fanout
      requires enough input in a single session that adding comments and
      markers makes it easier to check that output is correct. It's still a
      bit odd that with test:///default, reverting to a snapshot changes the
      domain from running to paused (possibly a bug in how the test driver
      copied from the qemu driver) - but the important part is that the test
      is reproducible, and any future tweaks we make to snapshot code have
      less chance of breaking successful command sequences.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Acked-by: NMichal Privoznik <mprivozn@redhat.com>
      280a2b41
  3. 15 3月, 2019 1 次提交
  4. 14 3月, 2019 6 次提交
  5. 13 3月, 2019 1 次提交
  6. 12 3月, 2019 3 次提交
  7. 11 3月, 2019 1 次提交
  8. 07 3月, 2019 2 次提交
  9. 12 2月, 2019 2 次提交
  10. 08 2月, 2019 1 次提交
  11. 30 1月, 2019 3 次提交
  12. 08 1月, 2019 2 次提交
  13. 19 12月, 2018 1 次提交
  14. 14 12月, 2018 1 次提交
  15. 13 12月, 2018 1 次提交
  16. 10 10月, 2018 1 次提交
    • M
      virfiletst: Test virFileIsSharedFS · a7b4eb7d
      Michal Privoznik 提交于
      Introduce some basic test cases for virFileIsSharedFS(). More
      will be added later. In order to achieve desired result, mocks
      for setmntent() and statfs() need to be invented because the
      first thing that virFileIsSharedFS() does is calling the latter.
      If it finds a FUSE mount it'll call the former.
      
      The mock might look a bit complicated, but in fact it's quite
      simple. The test sets LIBVIRT_MTAB env variable to hold the
      absolute path to a file containing mount table. Then, statfs()
      returns matching FS it finds, and setmntent() is there just to
      replace /proc/mounts with the file the test wants to load.
      
      Adding this test also exposed a bug we have - because we assume
      the given path points to a file we cut off what we assume is a
      file name to obtain directory path and only then we call
      statfs(). This is buggy because the passed path could be already
      a mount point.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
      a7b4eb7d
  17. 17 9月, 2018 1 次提交
  18. 24 8月, 2018 1 次提交
    • S
      vsh: Added tests · 95785c1c
      Simon Kobyda 提交于
      For now, there are 9 test cases
      - testVshTableNew: Creating table with empty header
      - testVshTableHeader: Printing table with/without header
      - testVshTableRowAppend: Appending row with various number of cells.
        Only row with same number of cells as in header is accepted.
      - testUnicode: Printing table with unicode characters.
        Checking correct alignment.
      - testUnicodeArabic: test opposite (right to left) writing
      - testUnicodeZeroWidthChar
      - testUnicodeCombiningChar
      - testUnicodeNonPrintableChar,
      - testNTables: Create and print varios types of tables - one column,
        one row table, table without content, standart table...
      Signed-off-by: NSimon Kobyda <skobyda@redhat.com>
      95785c1c
  19. 13 8月, 2018 1 次提交
  20. 18 7月, 2018 1 次提交
  21. 10 7月, 2018 1 次提交
  22. 26 6月, 2018 1 次提交
  23. 05 6月, 2018 1 次提交
  24. 23 5月, 2018 1 次提交
  25. 15 5月, 2018 1 次提交
    • M
      tests: Link mocks with libvirt.so · f50ad2ff
      Michal Privoznik 提交于
      In a lot of our mocks (if not all of them) we use our internal
      APIs (e.g. VIR_ALLOC). So far, we're relying on test binary that
      links with the mock to drag in libvirt.so. Well, this works only
      partially. Firstly, whatever binary we execute from tests will
      fail (e.g. as Martin reported on the list ./qemucapsprobe fails
      to execute qemu). Secondly, if there's a program that tries to
      validate linking (like valgrind is doing) it fails because of
      unresolved symbols.
      
      Because of that we have to link our mocks with libvirt.so.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      f50ad2ff
  26. 07 5月, 2018 2 次提交