未验证 提交 bba09590 编写于 作者: L Lukáš Doktor

Merging pull request 2509

Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>

* https://github.com/avocado-framework/avocado:
  Test: deprecate srcdir
......@@ -394,6 +394,8 @@ class Test(unittest.TestCase, TestData):
self.__runner_queue = runner_queue
self.__workdir = None
self.__srcdir_internal_access = False
self.__srcdir_warning_logged = False
self.__srcdir = None
if self.filename:
......@@ -529,6 +531,16 @@ class Test(unittest.TestCase, TestData):
@property
def srcdir(self):
"""
This property is deprecated and will be removed in the future.
The :meth:`workdir` function should be used instead.
"""
if not (self.__srcdir_internal_access or self.__srcdir_warning_logged):
LOG_JOB.warn("DEPRECATION NOTICE: the test's \"srcdir\" property "
"is deprecated and is planned to be removed no later "
"than May 11 2018. Please use the \"workdir\" "
"property instead.")
self.__srcdir_warning_logged = True
if self.__srcdir is None:
self.__srcdir = utils_path.init_dir(self.workdir, 'src')
return self.__srcdir
......@@ -941,12 +953,19 @@ class Test(unittest.TestCase, TestData):
if self.datadir is not None:
os.environ['AVOCADO_TEST_DATADIR'] = self.datadir
os.environ['AVOCADO_TEST_WORKDIR'] = self.workdir
os.environ['AVOCADO_TEST_SRCDIR'] = self.srcdir
os.environ['AVOCADO_TEST_LOGDIR'] = self.logdir
os.environ['AVOCADO_TEST_LOGFILE'] = self.logfile
os.environ['AVOCADO_TEST_OUTPUTDIR'] = self.outputdir
if self.__sysinfo_enabled:
os.environ['AVOCADO_TEST_SYSINFODIR'] = self.__sysinfodir
# srcdir is deprecated and will cause a test warning when
# accessed. It seems unfair to return a warning for all
# tests because Avocado itself will access that property.
# this is a hack to be removed when srcdir is also removed
# for good.
self.__srcdir_internal_access = True
os.environ['AVOCADO_TEST_SRCDIR'] = self.srcdir
self.__srcdir_internal_access = False
def run_avocado(self):
"""
......
......@@ -165,7 +165,7 @@ Take a look at ``examples/tests/modify_variable.py`` test::
"""
Execute 'print_variable'.
"""
path = os.path.join(self.srcdir, 'print_variable')
path = os.path.join(self.workdir, 'print_variable')
app = gdb.GDB()
app.set_file(path)
app.set_break(6)
......
......@@ -621,15 +621,15 @@ an example that does that::
# Build the synctest suite
self.cwd = os.getcwd()
tarball_path = self.get_data(sync_tarball)
archive.extract(tarball_path, self.srcdir)
self.srcdir = os.path.join(self.srcdir, 'synctest')
build.make(self.srcdir)
archive.extract(tarball_path, self.workdir)
self.workdir = os.path.join(self.workdir, 'synctest')
build.make(self.workdir)
def test(self):
"""
Execute synctest with the appropriate params.
"""
os.chdir(self.srcdir)
os.chdir(self.workdir)
cmd = ('./synctest %s %s' %
(self.sync_length, self.sync_loop))
process.system(cmd)
......@@ -677,7 +677,7 @@ inside the avocado ``data_dir`` location to put the fetched files in.
def setUp(self):
stress = 'http://people.seas.harvard.edu/~apw/stress/stress-1.0.4.tar.gz'
tarball = self.fetch_asset(stress)
archive.extract(tarball, self.srcdir)
archive.extract(tarball, self.workdir)
...
In this case, ``fetch_asset()`` will download the file from the url provided,
......@@ -690,7 +690,7 @@ inside the avocado ``data_dir`` location to put the fetched files in.
def setUp(self):
stress = 'http://people.seas.harvard.edu/~apw/stress/stress-1.0.4.tar.gz'
tarball = self.fetch_asset(stress)
archive.extract(tarball, self.srcdir)
archive.extract(tarball, self.workdir)
...
In this case, we try to find ``stress-1.0.4.tar.gz`` file in ``/mnt/files``
......@@ -708,7 +708,7 @@ inside the avocado ``data_dir`` location to put the fetched files in.
'ftp://foo.bar/stress-1.0.4.tar.gz']
tarball = self.fetch_asset(st_name, asset_hash=st_hash,
locations=st_loc)
archive.extract(tarball, self.srcdir)
archive.extract(tarball, self.workdir)
...
In this case, we try to download ``stress-1.0.4.tar.gz`` from the provided
......@@ -1669,8 +1669,6 @@ tests:
+-----------------------------+---------------------------------------+-----------------------------------------------------------------------------------------------------+
| AVOCADO_TEST_WORKDIR | Work directory for the test | /var/tmp/avocado_Bjr_rd/my_test.sh |
+-----------------------------+---------------------------------------+-----------------------------------------------------------------------------------------------------+
| AVOCADO_TEST_SRCDIR | Source directory for the test | /var/tmp/avocado_Bjr_rd/my-test.sh/src |
+-----------------------------+---------------------------------------+-----------------------------------------------------------------------------------------------------+
| AVOCADO_TESTS_COMMON_TMPDIR | Temporary directory created by the | /var/tmp/avocado_XhEdo/ |
| | `teststmpdir` plugin. The directory | |
| | is persistent throughout the tests | |
......@@ -1686,6 +1684,11 @@ tests:
+-----------------------------+---------------------------------------+-----------------------------------------------------------------------------------------------------+
| `***` | All variables from --mux-yaml | TIMEOUT=60; IO_WORKERS=10; VM_BYTES=512M; ... |
+-----------------------------+---------------------------------------+-----------------------------------------------------------------------------------------------------+
| AVOCADO_TEST_SRCDIR | Source directory for the test | /var/tmp/avocado_Bjr_rd/my-test.sh/src |
+-----------------------------+---------------------------------------+-----------------------------------------------------------------------------------------------------+
.. warning:: ``AVOCADO_TEST_SRCDIR`` is deprecated and will be removed
soon. Please use ``AVOCADO_TEST_WORKDIR`` instead.
SIMPLE Tests BASH extensions
......
......@@ -26,9 +26,9 @@ class CAbort(Test):
if c_file is None:
self.cancel('Test is missing data file %s' % source)
c_file_name = os.path.basename(c_file)
dest_c_file = os.path.join(self.srcdir, c_file_name)
dest_c_file = os.path.join(self.workdir, c_file_name)
shutil.copy(c_file, dest_c_file)
build.make(self.srcdir,
build.make(self.workdir,
env={'CFLAGS': '-g -O0'},
extra_args='abort')
......@@ -36,7 +36,7 @@ class CAbort(Test):
"""
Execute 'abort'.
"""
cmd = os.path.join(self.srcdir, 'abort')
cmd = os.path.join(self.workdir, 'abort')
cmd_result = process.run(cmd, ignore_status=True)
self.log.info(cmd_result)
expected_result = -6 # SIGABRT = 6
......
......@@ -26,9 +26,9 @@ class DataDirTest(Test):
if c_file is None:
self.cancel('Test is missing data file %s' % source)
c_file_name = os.path.basename(c_file)
dest_c_file = os.path.join(self.srcdir, c_file_name)
dest_c_file = os.path.join(self.workdir, c_file_name)
shutil.copy(c_file, dest_c_file)
build.make(self.srcdir,
build.make(self.workdir,
env={'CFLAGS': '-g -O0'},
extra_args='datadir')
......@@ -36,7 +36,7 @@ class DataDirTest(Test):
"""
Execute 'datadir'.
"""
cmd = os.path.join(self.srcdir, 'datadir')
cmd = os.path.join(self.workdir, 'datadir')
cmd_result = process.run(cmd)
self.log.info(cmd_result)
......
......@@ -29,9 +29,9 @@ class DoubleFreeTest(Test):
if c_file is None:
self.cancel('Test is missing data file %s' % source)
c_file_name = os.path.basename(c_file)
dest_c_file = os.path.join(self.srcdir, c_file_name)
dest_c_file = os.path.join(self.workdir, c_file_name)
shutil.copy(c_file, dest_c_file)
build.make(self.srcdir,
build.make(self.workdir,
env={'CFLAGS': '-g -O0'},
extra_args='doublefree')
......@@ -39,7 +39,7 @@ class DoubleFreeTest(Test):
"""
Execute 'doublefree'.
"""
cmd = os.path.join(self.srcdir, 'doublefree')
cmd = os.path.join(self.workdir, 'doublefree')
cmd_result = process.run(cmd, ignore_status=True,
env={'MALLOC_CHECK_': '1'})
self.log.info(cmd_result)
......
......@@ -29,9 +29,9 @@ class DoubleFreeTest(Test):
c_file = self.get_data(source)
if c_file is None:
self.cancel('Test is missing data file %s' % source)
shutil.copy(c_file, self.srcdir)
shutil.copy(c_file, self.workdir)
self.__binary = source.rsplit('.', 1)[0]
build.make(self.srcdir,
build.make(self.workdir,
env={'CFLAGS': '-g -O0'},
extra_args=self.__binary)
......@@ -39,7 +39,7 @@ class DoubleFreeTest(Test):
"""
Execute 'doublefree'.
"""
cmd = os.path.join(self.srcdir, self.__binary)
cmd = os.path.join(self.workdir, self.__binary)
cmd_result = process.run(cmd)
self.log.info(cmd_result)
......
......@@ -5,6 +5,7 @@ echo "Avocado Version: $AVOCADO_VERSION"
echo "Avocado Test basedir: $AVOCADO_TEST_BASEDIR"
echo "Avocado Test datadir: $AVOCADO_TEST_DATADIR"
echo "Avocado Test workdir: $AVOCADO_TEST_WORKDIR"
# Warning: srcdir is deprecated and will be removed soon
echo "Avocado Test srcdir: $AVOCADO_TEST_SRCDIR"
echo "Avocado Test logdir: $AVOCADO_TEST_LOGDIR"
echo "Avocado Test logfile: $AVOCADO_TEST_LOGFILE"
......
......@@ -26,7 +26,7 @@ class LinuxBuildTest(Test):
self.linux_build = kernel.KernelBuild(kernel_version,
linux_config,
self.srcdir,
self.workdir,
self.cache_dirs)
self.linux_build.download()
self.linux_build.uncompress()
......
......@@ -32,9 +32,9 @@ class PrintVariableTest(Test):
c_file = self.get_data(source)
if c_file is None:
self.cancel('Test is missing data file %s' % source)
shutil.copy(c_file, self.srcdir)
shutil.copy(c_file, self.workdir)
self.__binary = source.rsplit('.', 1)[0]
build.make(self.srcdir,
build.make(self.workdir,
env={'CFLAGS': '-g -O0'},
extra_args=self.__binary)
......@@ -42,7 +42,7 @@ class PrintVariableTest(Test):
"""
Execute 'print_variable'.
"""
path = os.path.join(self.srcdir, self.__binary)
path = os.path.join(self.workdir, self.__binary)
app = gdb.GDB()
app.set_file(path)
app.set_break(6)
......
......@@ -27,9 +27,9 @@ class Raise(Test):
if c_file is None:
self.cancel('Test is missing data file %s' % source)
c_file_name = os.path.basename(c_file)
dest_c_file = os.path.join(self.srcdir, c_file_name)
dest_c_file = os.path.join(self.workdir, c_file_name)
shutil.copy(c_file, dest_c_file)
build.make(self.srcdir,
build.make(self.workdir,
env={'CFLAGS': '-g -O0'},
extra_args='raise')
......@@ -38,7 +38,7 @@ class Raise(Test):
Execute 'raise'.
"""
signum = self.params.get('signal_number', default=15)
cmd = os.path.join(self.srcdir, 'raise %d' % signum)
cmd = os.path.join(self.workdir, 'raise %d' % signum)
cmd_result = process.run(cmd, ignore_status=True)
self.log.info(cmd_result)
if signum == 0:
......
......@@ -29,8 +29,8 @@ class SyncTest(Test):
tarball_path = self.get_data(sync_tarball)
if tarball_path is None:
self.cancel('Test is missing data file %s' % tarball_path)
archive.extract(tarball_path, self.srcdir)
srcdir = os.path.join(self.srcdir, 'synctest')
archive.extract(tarball_path, self.workdir)
srcdir = os.path.join(self.workdir, 'synctest')
os.chdir(srcdir)
if self.params.get('debug_symbols', default=True):
build.make(srcdir,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册