1. 18 3月, 2014 2 次提交
  2. 04 3月, 2014 1 次提交
    • E
      util: make it easier to grab only regular process exit · c72e76c3
      Eric Blake 提交于
      Right now, a caller waiting for a child process either requires
      the child to have status 0, or must use WIFEXITED() and friends
      itself.  But in many cases, we want the middle ground of treating
      fatal signals as an error, and directly accessing the normal exit
      value without having to use WEXITSTATUS(), in order to easily
      detect an expected non-zero exit status.  This adds the middle
      ground to the low-level virProcessWait; the next patch will add
      it to virCommand.
      
      * src/util/virprocess.h (virProcessWait): Alter signature.
      * src/util/virprocess.c (virProcessWait): Add parameter.
      (virProcessRunInMountNamespace): Adjust caller.
      * src/util/vircommand.c (virCommandWait): Likewise.
      * src/util/virfile.c (virFileAccessibleAs): Likewise.
      * src/lxc/lxc_container.c (lxcContainerHasReboot)
      (lxcContainerAvailable): Likewise.
      * daemon/libvirtd.c (daemonForkIntoBackground): Likewise.
      * tools/virt-login-shell.c (main): Likewise.
      * tools/virsh-domain.c (cmdLxcEnterNamespace): Likewise.
      * tests/testutils.c (virtTestCaptureProgramOutput): Likewise.
      * tests/commandtest.c (test23): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c72e76c3
  3. 20 2月, 2014 2 次提交
    • D
      Rename virDomainGetRootFilesystem to virDomainGetFilesystemForTarget · 432a3fee
      Daniel P. Berrange 提交于
      The virDomainGetRootFilesystem method can be generalized to allow
      any filesystem path to be obtained.
      
      While doing this, start a new test case for purpose of testing various
      helper methods in the domain_conf.{c,h} files, such as this one.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      432a3fee
    • D
      Introduce new OOM testing support · 590029f6
      Daniel P. Berrange 提交于
      The previous OOM testing support would re-run the entire "main"
      method each iteration, failing a different malloc each time.
      When a test suite has 'n' allocations, the number of repeats
      requires is  (n * (n + 1) ) / 2.  This gets very large, very
      quickly.
      
      This new OOM testing support instead integrates at the
      virtTestRun level, so each individual test case gets repeated,
      instead of the entire test suite. This means the values of
      'n' are orders of magnitude smaller.
      
      The simple usage is
      
         $ VIR_TEST_OOM=1 ./qemuxml2argvtest
         ...
         29) QEMU XML-2-ARGV clock-utc                                         ... OK
             Test OOM for nalloc=36 .................................... OK
         30) QEMU XML-2-ARGV clock-localtime                                   ... OK
             Test OOM for nalloc=36 .................................... OK
         31) QEMU XML-2-ARGV clock-france                                      ... OK
             Test OOM for nalloc=38 ...................................... OK
         ...
      
      the second lines reports how many mallocs have to be failed, and thus
      how many repeats of the test will be run.
      
      If it crashes, then running under valgrind will often show the problem
      
        $ VIR_TEST_OOM=1 ../run valgrind ./qemuxml2argvtest
      
      When debugging problems it is also helpful to select an individual
      test case
      
        $ VIR_TEST_RANGE=30 VIR_TEST_OOM=1 ../run valgrind ./qemuxml2argvtest
      
      When things get really tricky, it is possible to request that just
      specific allocs are failed. eg to fail allocs 5 -> 12, use
      
        $ VIR_TEST_RANGE=30 VIR_TEST_OOM=1:5-12 ../run valgrind ./qemuxml2argvtest
      
      In the worse case, you might want to know the stack trace of the
      alloc which was failed then VIR_TEST_OOM_TRACE can be set. If it
      is set to 1 then it will only print if it thinks a mistake happened.
      This is often not reliable, so setting it to 2 will make it print
      the stack trace for every alloc that is failed.
      
        $ VIR_TEST_OOM_TRACE=2 VIR_TEST_RANGE=30 VIR_TEST_OOM=1:5-5 ../run valgrind ./qemuxml2argvtest
        30) QEMU XML-2-ARGV clock-localtime                                   ... OK
            Test OOM for nalloc=36 !virAllocN
        /home/berrange/src/virt/libvirt/src/util/viralloc.c:180
        virHashCreateFull
        /home/berrange/src/virt/libvirt/src/util/virhash.c:144
        virDomainDefParseXML
        /home/berrange/src/virt/libvirt/src/conf/domain_conf.c:11745
        virDomainDefParseNode
        /home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12646
        virDomainDefParse
        /home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12590
        testCompareXMLToArgvFiles
        /home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:106
        virtTestRun
        /home/berrange/src/virt/libvirt/tests/testutils.c:250
        mymain
        /home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:418 (discriminator 2)
        virtTestMain
        /home/berrange/src/virt/libvirt/tests/testutils.c:750
        ??
        ??:0
        _start
        ??:?
         FAILED
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      590029f6
  4. 28 11月, 2013 1 次提交
    • E
      tests: guarantee abs_srcdir in all C tests · 0aa873d7
      Eric Blake 提交于
      While trying to debug a failure of virpcitest during 'make distcheck',
      I noticed that with a VPATH build, 'cd tests; ./virpcitest' fails for
      an entirely different reason.  To reproduce the distcheck failure, I
      had to run 'cd tests; abs_srcdir=/path/to/src ./virpcitest'.  But we
      document in HACKING that all of our tests are supposed to be runnable
      without requiring extra environment variables.
      
      The solution: hardcode the location of srcdir into the just-built
      binaries, rather than requiring make to prepopulate environment
      variables.  With this, './virpcitest' passes even in a VPATH build
      (provided that $(srcdir) is writable; a followup patch will fix the
      conditions required by 'make distcheck').  [Note: the makefile must
      still pass on directory variables to the test environment of shell
      scripts, since those aren't compiled.  So while this solves the case
      of a compiled test, it still requires environment variables to pass
      a VPATH build of any shell script test case that relies on srcdir.]
      
      * tests/Makefile.am (AM_CFLAGS): Define abs_srcdir in all compiled
      tests.
      * tests/testutils.h (abs_srcdir): Quit declaring.
      * tests/testutils.c (virtTestMain): Rely on define rather than
      environment variable.
      * tests/virpcimock.c (pci_device_new_from_stub): Rely on define.
      * tests/cputest.c (mymain): Adjust abs_top_srcdir default.
      * tests/qemuxml2argvtest.c (mymain): Likewise.
      * tests/qemuxmlnstest.c (mymain): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      0aa873d7
  5. 08 10月, 2013 2 次提交
  6. 24 9月, 2013 1 次提交
  7. 17 9月, 2013 1 次提交
    • P
      test: Refactor setting of dummy error handlers · 43f68a4f
      Peter Krempa 提交于
      Multiple tests need to register a function to quiesce errors from
      libvirt when using a connection and doing negative tests. Each of those
      tests had a static function to do so. This can be replaced by a utility
      function that enables the errors when debug is enabled.
      
      This patch adds virtTestQuiesceLibvirtErrors() and refactors test that
      use private handlers.
      43f68a4f
  8. 13 8月, 2013 1 次提交
    • E
      tests: add helper to determine when to skip expensive tests · 38d4bf49
      Eric Blake 提交于
      The logic set up in previous patch for exposing VIR_TEST_EXPENSIVE
      to individual tests is as follows:
      
      make check VIR_TEST_EXPENSIVE=0   => getenv("VIR_TEST_EXPENSIVE") sees "0"
      make check VIR_TEST_EXPENSIVE=1   => getenv("VIR_TEST_EXPENSIVE") sees "1"
      make check                        => getenv("VIR_TEST_EXPENSIVE") sees
      either "0" or "1", based on configure options
      cd tests; ./FOOtest               => getenv("VIR_TEST_EXPENSIVE") sees
      whatever is in your environment (usually NULL, but possibly garbage)
      
      Merely checking if VIR_TEST_EXPENSIVE is set in the environment
      does the wrong thing; likewise, it is unsafe to assume the
      variable will always contain a valid number.
      
      As such, it helps to have helper functions, instead of making each
      expensive test repeat the probe of the environment.
      
      * tests/testutils.h (virTestGetExpensive): New prototype.
      * tests/testutils.c (virTestGetExpensive): Implement it.
      * tests/test-lib.sh (very_expensive_): Rename...
      (test_expensive): ...and tweak to use VIR_TEST_EXPENSIVE.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      38d4bf49
  9. 19 7月, 2013 2 次提交
    • D
      Change s/i/iv/ in test code to avoid syntax-check · a81eb0b4
      Daniel P. Berrange 提交于
      The code parsing VIR_TEST_RANGE mistakenly used 'unsigned int i'
      which violated syntax-check rules
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      a81eb0b4
    • D
      Allow test cases to be run selectively · ab92ae33
      Daniel P. Berrange 提交于
      When debugging a failing test with many test cases, it is useful
      to be able to skip most tests. Introducing a new environment
      variable VIR_TEST_RANGE=N-M enables execution of only the test
      cases numbered N-M inclusive, starting from 1.
      
      For example, to skip all the cgroup tests except 2
      
      $ VIR_TEST_RANGE=2-3 VIR_TEST_DEBUG=1 ./vircgrouptest
      TEST: vircgrouptest
       2) New cgroup for driver                                             ... Unexpected found LXC cgroup: 1
      libvirt: Cgroup error : Failed to create controller cpu for group: No such file or directory
      FAILED
       3) New cgroup for domain driver                                      ... Cannot find LXC cgroup: 1
      libvirt: Cgroup error : Failed to create controller cpu for group: No such file or directory
      FAILED
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      ab92ae33
  10. 12 7月, 2013 1 次提交
    • J
      testutils: Resolve Coverity issues · 8283ef9e
      John Ferlan 提交于
      Recent changes uncovered a NEGATIVE_RETURNS in the return from sysconf()
      when processing a for loop in virtTestCaptureProgramExecChild() in
      testutils.c
      
      Code review uncovered 3 other code paths with the same condition that
      weren't found by Covirity, so fixed those as well.
      8283ef9e
  11. 11 7月, 2013 1 次提交
  12. 10 7月, 2013 1 次提交
  13. 21 5月, 2013 1 次提交
  14. 10 5月, 2013 1 次提交
  15. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88
  16. 22 3月, 2013 1 次提交
    • M
      viralloc: Export virAllocTest* · 70bc623b
      Michal Privoznik 提交于
      If users build with --enable-test-oom configure option,
      they get this error saying, virAllocTest* functions are
      not defined within tests/testutils.c.
      70bc623b
  17. 26 2月, 2013 1 次提交
    • E
      tests: uniformly report test failures · dce95297
      Eric Blake 提交于
      testutils.c likes to print summaries after a test completes,
      including if it failed.  But if the test outright exit()s,
      this summary is skipped.  Enforce that we return instead of exit.
      
      * cfg.mk (sc_prohibit_exit_in_tests): New syntax check.
      * tests/commandhelper.c (main): Fix offenders.
      * tests/qemumonitorjsontest.c (mymain): Likewise.
      * tests/seclabeltest.c (main): Likewise.
      * tests/securityselinuxlabeltest.c (mymain): Likewise.
      * tests/securityselinuxtest.c (mymain): Likewise.
      * tests/testutils.h (VIRT_TEST_MAIN_PRELOAD): Likewise.
      * tests/testutils.c (virtTestMain): Likewise.
      (virtTestCaptureProgramOutput): Use symbolic name.
      dce95297
  18. 16 2月, 2013 1 次提交
    • E
      regex: gnulib guarantees that we have regex support · ec8a2d03
      Eric Blake 提交于
      No need to use HAVE_REGEX_H - our use of gnulib guarantees that
      the header exists and works, regardless of platform.  Similarly,
      we can unconditionally assume a compiling <sys/wait.h> (although
      the mingw version of this header is not full-featured).
      
      * src/storage/storage_backend.c: Drop useless conditional.
      * tests/testutils.c: Likewise.
      ec8a2d03
  19. 21 12月, 2012 7 次提交
  20. 15 11月, 2012 1 次提交
  21. 02 11月, 2012 1 次提交
  22. 28 9月, 2012 5 次提交
  23. 27 9月, 2012 1 次提交
  24. 26 9月, 2012 2 次提交
  25. 22 9月, 2012 1 次提交
    • M
      Drop unused return value of virLogOutputFunc · fca338a0
      Miloslav Trmač 提交于
      Nothing uses the return value, and creating it requries otherwise
      unnecessary strlen () calls.
      
      This cleanup is conceptually independent from the rest of the series
      (although the later patches won't apply without it).  This just seems
      a good opportunity to clean this up, instead of entrenching the unnecessary
      return value in the virLogOutputFunc instance that will be added in this
      series.
      Signed-off-by: NMiloslav Trmač <mitr@redhat.com>
      fca338a0