autotest中 具体是在哪里调用 test case中的python文件的。

本文详细介绍了在kvmautotest中如何调用测试用例,并通过runtest函数执行测试过程,包括预处理、运行测试函数以及清理操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



diff --git a/client/common_lib/test.py b/client/common_lib/test.py

index 02f5dfb..e9ab456 100644
--- a/client/common_lib/test.py
+++ b/client/common_lib/test.py
@@ -629,6 +629,7 @@ def runtest(job, url, tag, args, dargs,
             local_namespace={}, global_namespace={},
             before_test_hook=None, after_test_hook=None,
             before_iteration_hook=None, after_iteration_hook=None):
+    print "common.test.runtest"
     local_namespace = local_namespace.copy()
     global_namespace = global_namespace.copy()
 
@@ -681,6 +682,7 @@ def runtest(job, url, tag, args, dargs,
     local_namespace['outputdir'] = outputdir
 
     sys.path.insert(0, importdir)
+    print "mytest = %s(job, bindir, outputdir)" % classname
     try:
         exec ('import %s' % modulename, local_namespace, global_namespace)
         exec ("mytest = %s(job, bindir, outputdir)" % classname,
@@ -693,6 +695,7 @@ def runtest(job, url, tag, args, dargs,
 
     try:
         mytest = global_namespace['mytest']
+       print mytest
         if before_test_hook:
             before_test_hook(mytest)
 
@@ -702,7 +705,9 @@ def runtest(job, url, tag, args, dargs,
             mytest.register_before_iteration_hook(before_iteration_hook)
         if after_iteration_hook:
             mytest.register_after_iteration_hook(after_iteration_hook)
+       print "before exec, %s, %s" %(args, dargs)
         mytest._exec(args, dargs)
+       print "after exec"
     finally:
         os.chdir(pwd)
         if after_test_hook:




kvm autotest中调用到测试用例的地方


richard@richard:~/git/autotest/client$ git diff tests/kvm/kvm.py
diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index 5f9632f..292b48f 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -86,10 +86,12 @@ class kvm(test.test):
 
                     # Preprocess
                     try:
-                        virt_env_process.preprocess(self, params, env)
+                       print "Preprocess"
+                        virt_env_process.preprocess(self, params, env) # here create a vm if necessary
                     finally:
                         env.save()
-                    # Run the test function
+                    # Run the test function, this is the function in test python script
+                   # such as run_boot in the boot test case
                     run_func = getattr(test_module, "run_%s" % t_type)
                     try:
                         run_func(self, params, env)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值