@@ -262,6 +262,17 @@ index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
class QMPTestCase(unittest.TestCase):
'''Abstract base class for QMP test cases'''
+ def __init__(self, *args):
+ super(QMPTestCase, self).__init__(*args)
+ self.workdir = os.path.join(test_dir, self.__class__.__name__,
+ self._testMethodName)
+ try:
+ os.makedirs(self.workdir)
+ except OSError, error:
+ if error.errno != errno.EEXIST:
+ raise
+ os.chdir(self.workdir)
+
def dictpath(self, d, path):
'''Traverse a path in a nested dict'''
for component in path.split('/'):
This adds the framework to iotests.py to run python iotests in a subdirectory structure, structured like so: scratch/ ├── TestNumber │ ├── TestClassName │ │ ├── test_method_name Prior to this patch, tests were run in a test subdirectory from previous patches in the series, like this: scratch/ ├── TestNumber However, given the nature of python's unittest framework, additional subdirectories are needed, if we want to insure that we can save intermediate files in case of test failures (as we will do in a subsequent patch) without running the risk of tainting other test methods from the test file. In python tests using iiotests.QMPTestCase, any reference to 'iotests.test_dir' should be replaced by 'self.workdir'. This may also require changing the scope of path name variables. Suggested-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jeff Cody <jcody@redhat.com> --- tests/qemu-iotests/iotests.py | 11 +++++++++++ 1 file changed, 11 insertions(+)