1. 25 4月, 2018 1 次提交
    • C
      selftests/unit/test_utils_process.py: skip test if sudo is not available · 33517beb
      Cleber Rosa 提交于
      test_run_sudo() actually needs sudo, because it attempts to run it.
      Let's check for the file at the usual location, and skip the test
      unless it exists.
      
         ERROR: test_run_sudo (selftests.unit.test_utils_process.TestProcessRun)
         ----------------------------------------------------------------------
         Traceback (most recent call last):
           File "/home/travis/virtualenv/python2.7_with_system_site_packages/local/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
             return func(*args, **keywargs)
           File "selftests/unit/test_utils_process.py", line 180, in test_run_sudo
             p = process.run(cmd='ls -l', sudo=True, ignore_status=True)
           File "avocado/utils/process.py", line 1272, in run
             cmd_result = sp.run(timeout=timeout)
           File "avocado/utils/process.py", line 781, in run
             self._init_subprocess()
           File "avocado/utils/process.py", line 571, in _init_subprocess
             raise details
         OSError: [Errno 2] No such file or directory (/bin/sudo -n ls -l)
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      33517beb
  2. 21 4月, 2018 4 次提交
  3. 26 3月, 2018 1 次提交
    • C
      avocado.utils.process: attempt first to decode bytes into text · 79d99673
      Cleber Rosa 提交于
      And only if the method is not available, attempt to fallback to
      the stdout itself if it is a string.
      
      Before 30617c1e, the following kind of check was done:
      
         >>> type(bytes('foo')) in string_types
         False
      
      And after it, the check was changed to:
      
         >>> isinstance(bytes('foo'), string_types)
         True
      
      That made the bytes decoding not to be performed at times.  While the
      new check is correct, we should favor the attempt to decode, and
      only if not available, fallback to the original stdout if it looks
      like a string.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      79d99673
  4. 21 3月, 2018 2 次提交
  5. 15 3月, 2018 1 次提交
  6. 26 2月, 2018 1 次提交
    • C
      avocado/utils/process.py: make CmdResult.std{out,err}_text smarter · 72bdab0f
      Cleber Rosa 提交于
      In situations where a user of the CmdResult class manually sets the
      stdout/stderr attributes to a string, instead of the recommended and
      documented content of type "bytes", it won't be possible to "decode"
      the bytes into a string of a given encoding, and we'll end up with
      a crash.
      
      Since the goal of std{out,err}_text is to return a text version
      of stdout, if itself already is of such a type, let's just return
      it.
      
      Additionally, if the data cannot be "decode()d", let's raise an
      explicit TypeError on this location, rather than later in the code
      when its value is attempted to be used.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      72bdab0f
  7. 22 12月, 2017 1 次提交
  8. 29 11月, 2017 1 次提交
    • C
      FDDrainer: flush the file based handlers before filling results · 41dfb4b9
      Cleber Rosa 提交于
      The FDDrainer reads from the PIPEs and writes to both the internal
      StringIO instances and to stream logging handlers.  There are no
      guarantees that the logging handlers will flush the content before the
      FDDrainer finishes.
      
      Let's explicitly close all the handlers (which should really be
      FileHandlers) associated with the stream loggers, which should flush
      and sync the content on the files themselves.
      
      Additionally, the combined drainer was being missed from the flush
      process, and was causing some output in that mode to be unavailable on
      generated output.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      41dfb4b9
  9. 18 11月, 2017 2 次提交
  10. 04 10月, 2017 2 次提交
  11. 08 3月, 2017 1 次提交
  12. 06 2月, 2017 1 次提交
  13. 07 11月, 2016 1 次提交
  14. 15 2月, 2016 1 次提交
  15. 12 2月, 2016 1 次提交
  16. 27 1月, 2016 1 次提交
    • L
      avocado.utils.process: Add 'sudo' parameter to run and system APIs · 7dad50e7
      Lucas Meneghel Rodrigues 提交于
      Some commands do require admin privileges to run, but we
      can't use the 'root' user in some testing scenarios [1].
      
      So let's add a 'sudo' parameter to process.run(), process.system()
      and process.system_output() interfaces, that will append
      a sudo command to the original command string, causing it
      to be executed under sudo. The basic assumption here is
      that the user executing the tests was added to the sudoers
      file in such a way that it can run administrative commands
      without a password.
      
      [1] One specific environment where we can't use the root
      user is when avocado runs on an AWS (Amazon Web Services)
      instance.
      Signed-off-by: NLucas Meneghel Rodrigues <lookkas@gmail.com>
      7dad50e7
  17. 28 11月, 2015 2 次提交
  18. 03 9月, 2015 1 次提交
    • C
      Selftests: move to adhere to unittest discover default pattern · 24d87eb4
      Cleber Rosa 提交于
      To be honest, our test code could still be kept in the same directories and
      have the same names. But I think we can improve two things here:
      
      1) Flatten a little bit the directory structure of selftests. Two path
      components are being dropped here: "all" and "avocado". So that
      "selftests/all/functional/avocado" becomes simply
      "selftests/functional".
      
      2) File names match what is, by default, recognized by unittest (the
      Standard Library module) based discovery of tests. That means that
      doc_build_test.py becomes test_doc_build.py. Not a big deal IMHO.
      Signed-off-by: NCleber Rosa <crosa@redhat.com>
      24d87eb4
  19. 13 6月, 2015 1 次提交
  20. 18 3月, 2015 1 次提交
  21. 29 1月, 2015 1 次提交
  22. 10 9月, 2014 1 次提交