1. 18 3月, 2016 2 次提交
    • M
      tests: Set PATH in each test · 363b401f
      Michal Privoznik 提交于
      Currently we spawn couple of binaries in our test suite.
      Moreover, we provide some spoofed versions of system binaries
      hoping that those will be executed instead of the system ones.
      For instance, for testing SSH socket we have written our own ssh
      binary for producing predictable results. We certainly don't want
      to execute the system ssh binary.
      However, in order to prefer our binaries over system ones, we
      need to set PATH environment variable. But this is done only at
      the Makefile level. So if anybody runs a test by hand that
      expects our spoofed binary, the test ends up executing real
      system binaries. This is not good. In fact, it's terribly wrong.
      The fix lies in a small trick - putting our build directory at
      the beginning of the PATH environment variable in each test.
      Hopefully, since every test has this VIRT_TEST_MAIN* wrapper, we
      can fix this at a single place.
      Moreover, while this removes setting PATH for our tests written
      in bash, it's safe as we are not calling anything ours that would
      require PATH change there.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      363b401f
    • M
      Drop paths.h include · 865764de
      Michal Privoznik 提交于
      We include the file in plenty of places. This is mostly due to
      historical reasons. The only place that needs something from the
      header file is storage_backend_fs which opens _PATH_MOUNTED. But
      it gets the file included indirectly via mntent.h. At no other
      place in our code we need _PATH_.*. Drop the include and
      configure check then.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      865764de
  2. 26 2月, 2016 1 次提交
  3. 18 2月, 2016 1 次提交
  4. 10 2月, 2016 1 次提交
  5. 06 2月, 2016 1 次提交
  6. 04 2月, 2016 1 次提交
  7. 13 1月, 2016 1 次提交
  8. 09 1月, 2016 2 次提交
  9. 08 1月, 2016 3 次提交
  10. 06 10月, 2015 2 次提交
    • C
      testutils: Drop virtTestResult · bb5fc5c7
      Cole Robinson 提交于
      virtTestResult is suboptimal for a few reasons:
      
      - It poorly duplicates virtTestRun pass/fail reporting logic
      - It doesn't have virtTestRun's alloc testing support
      - It only reports the test name _after_ the test has run.
      - It doesn't follow the standard virtTestRun pattern that most other
        tests use.
      
      There's no users left, so drop it. If any other async tests like eventtest
      spring up that don't cleanly fit the virtTestRun pattern, I suggest they
      just open code the support for it around virtTestRun
      bb5fc5c7
    • C
      testutils: Add coloring to verbose PASS/FAILED output · 3de074ef
      Cole Robinson 提交于
      Helps to visually track down test failures if debugging the test suite.
      
      The colors match what 'make check' does for pass/fail/skip
      3de074ef
  11. 04 5月, 2015 1 次提交
  12. 28 4月, 2015 1 次提交
    • L
      test: Fix actual vs. expected in virtTestCompareFiles · dcbedfa6
      Laine Stump 提交于
      Commit ca329299 added a utility function virtTestCompareFiles() to
      eliminate repetitive code in several test programs. It unfortunately
      calls virtTestDifference() with the arguments in the wrong order -
      strcontent is the "actual" output gathered by the test rig, while
      filecontent is the "expected", and virtTestDifference() wants expected
      (filecontent) followed by actual (strcontent), but
      virtTestCompareFiles() does the opposite, which can make the output a
      bit confusing when there is a failure.
      dcbedfa6
  13. 24 4月, 2015 3 次提交
  14. 21 4月, 2015 2 次提交
  15. 02 4月, 2015 1 次提交
    • J
      Remove unused macros · a0482396
      Ján Tomko 提交于
      In the order of appearance:
      
      * MAX_LISTEN - never used
        added by 23ad665c (qemud) and addec57 (lock daemon)
      
      * NEXT_FREE_CLASS_ID - never used, added by 07d1b6b5
      
      * virLockError - never used, added by eb8268a4
      
      * OPENVZ_MAX_ARG, CMDBUF_LEN, CMDOP_LEN
        unused since the removal of ADD_ARG_LIT in d8b31306
      
      * QEMU_NB_PER_CPU_STAT_PARAM - unused since 897808e7
      
      * QEMU_CMD_PROMPT, QEMU_PASSWD_PROMPT - unused since 1dc10a7b
      
      * TEST_MODEL_WORDSIZE - unused since c25c18f7
      
      * TEMPDIR - never used, added by 714bef5b
      
      * NSIG - workaround around old headers
        added by commit 60ed1d2a
        unused since virExec was moved by commit 02e86910
      
      * DO_TEST_PARSE - never used, added by 9afa0060
      
      * DIFF_MSEC, GETTIMEOFDAY - unused since eee6eb66
      a0482396
  16. 31 1月, 2015 1 次提交
    • P
      test: utils: Add helpers for automatic numbering of test cases · d793aeed
      Peter Krempa 提交于
      Adding or reordering test cases is usually a pain due to static test
      case names that are then passed to virtTestRun(). To ease the numbering
      of test cases, this patch adds two simple helpers that generate the test
      names according to the order they are run. The test name can be
      configured via the reset function.
      
      This will allow us to freely add test cases in middle of test groups
      without the need to re-number the rest of test cases.
      d793aeed
  17. 21 11月, 2014 1 次提交
    • P
      test: xml2xml: Print full filenames if xml2xml test fails · c5942a9f
      Peter Krempa 提交于
      To simplify looking for a problem instrument the XML comparator function
      with possibility to print the filename of the failed/expected XML
      output.
      
      This is necessary as the VIR_TEST_DIFFERENT macro possibly tests two XML
      files for the inactive/active state and the resulting error may not be
      obvious.
      c5942a9f
  18. 29 10月, 2014 1 次提交
    • E
      maint: avoid static zero init in tests · a396c11e
      Eric Blake 提交于
      C guarantees that static variables are zero-initialized.  Some older
      compilers (and also gcc -fno-zero-initialized-in-bss) create larger
      binaries if you explicitly zero-initialize a static variable.
      
      * tests/eventtest.c: Fix initialization.
      * tests/testutils.c: Likewise.
      * tests/virhostdevtest.c: Likewise.
      * tests/virportallocatortest.c: Likewise.
      * tests/virscsitest.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a396c11e
  19. 05 9月, 2014 1 次提交
    • E
      maint: use consistent if-else braces in remaining spots · d194d6e7
      Eric Blake 提交于
      I'm about to add a syntax check that enforces our documented
      HACKING style of always using matching {} on if-else statements.
      
      This patch focuses on all remaining problems, where there weren't
      enough issues to warrant splitting it further.
      
      * src/remote/remote_driver.c (doRemoteOpen): Correct use of {}.
      * src/security/virt-aa-helper.c (vah_add_path, valid_path, main):
      Likewise.
      * src/rpc/virnetsocket.c (virNetSocketNewConnectLibSSH2):
      Likewise.
      * src/esx/esx_vi_types.c (esxVI_Type_FromString): Likewise.
      * src/uml/uml_driver.c (umlDomainDetachDevice): Likewise.
      * src/util/viralloc.c (virShrinkN): Likewise.
      * src/util/virbuffer.c (virBufferURIEncodeString): Likewise.
      * src/util/virdbus.c (virDBusCall): Likewise.
      * src/util/virnetdev.c (virNetDevValidateConfig): Likewise.
      * src/util/virnetdevvportprofile.c
      (virNetDevVPortProfileGetNthParent): Likewise.
      * src/util/virpci.c (virPCIDeviceIterDevices)
      (virPCIDeviceWaitForCleanup)
      (virPCIDeviceIsBehindSwitchLackingACS): Likewise.
      * src/util/virsocketaddr.c (virSocketAddrGetNumNetmaskBits):
      Likewise.
      * src/util/viruri.c (virURIParseParams): Likewise.
      * daemon/stream.c (daemonStreamHandleAbort): Likewise.
      * tests/testutils.c (virtTestResult): Likewise.
      * tests/cputest.c (cpuTestBaseline): Likewise.
      * tools/virsh-domain.c (cmdDomPMSuspend): Likewise.
      * tools/virsh-host.c (cmdNodeSuspend): Likewise.
      * src/esx/esx_vi_generator.py (Type.generate_typefromstring):
      Tweak generated code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d194d6e7
  20. 14 7月, 2014 1 次提交
    • E
      capabilities: use bool instead of int · 58156f39
      Eric Blake 提交于
      While preparing to add a capability for active commit, I noticed
      that the existing code was abusing int for boolean values.
      
      * src/conf/capabilities.h (_virCapsGuestFeature, _virCapsHost)
      (virCapabilitiesNew, virCapabilitiesAddGuestFeature): Improve
      types.
      * src/conf/capabilities.c (virCapabilitiesNew)
      (virCapabilitiesAddGuestFeature): Adjust signature.
      * src/bhyve/bhyve_capabilities.c (virBhyveCapsBuild): Update
      clients.
      * src/esx/esx_driver.c (esxCapsInit): Likewise.
      * src/libxl/libxl_conf.c (libxlMakeCapabilities): Likewise.
      * src/lxc/lxc_conf.c (virLXCDriverCapsInit): Likewise.
      * src/openvz/openvz_conf.c (openvzCapsInit): Likewise.
      * src/parallels/parallels_driver.c (parallelsBuildCapabilities):
      Likewise.
      * src/phyp/phyp_driver.c (phypCapsInit): Likewise.
      * src/qemu/qemu_capabilities.c (virQEMUCapsInit)
      (virQEMUCapsInitGuestFromBinary): Likewise.
      * src/security/virt-aa-helper.c (get_definition): Likewise.
      * src/test/test_driver.c (testBuildCapabilities): Likewise.
      * src/uml/uml_conf.c (umlCapsInit): Likewise.
      * src/vbox/vbox_tmpl.c (vboxCapsInit): Likewise.
      * src/vmware/vmware_conf.c (vmwareCapsInit): Likewise.
      * src/xen/xen_hypervisor.c (xenHypervisorBuildCapabilities):
      Likewise.
      * src/xenapi/xenapi_driver.c (getCapsObject): Likewise.
      * tests/qemucaps2xmltest.c (testGetCaps): Likewise.
      * tests/testutils.c (virTestGenericCapsInit): Likewise.
      * tests/testutilslxc.c (testLXCCapsInit): Likewise.
      * tests/testutilsqemu.c (testQemuCapsInit): Likewise.
      * tests/testutilsxen.c (testXenCapsInit): Likewise.
      * tests/vircaps2xmltest.c (buildVirCapabilities): Likewise.
      * tests/vircapstest.c (buildNUMATopology): Likewise.
      * tests/vmx2xmltest.c (testCapsInit): Likewise.
      * tests/xml2vmxtest.c (testCapsInit): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      58156f39
  21. 25 4月, 2014 3 次提交
  22. 25 3月, 2014 1 次提交
  23. 21 3月, 2014 1 次提交
  24. 18 3月, 2014 2 次提交
  25. 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
  26. 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
  27. 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
  28. 08 10月, 2013 1 次提交