<div dir="ltr">Reviewed-by: Daniel Barboza &lt;<a href="mailto:dhbarboza82@gmail.com">dhbarboza82@gmail.com</a>&gt;</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 16, 2015 at 5:14 PM, Aline Manera <span dir="ltr">&lt;<a href="mailto:alinefm@linux.vnet.ibm.com" target="_blank">alinefm@linux.vnet.ibm.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The user may have the Kimchi source code in any directory and using it<br>
as a base to do the tests may cause permission errors while open ISO<br>
files or creating guest disks.<br>
To avoid those errors use a temp directory under /var which already has<br>
the right permissions to all users.<br>
<br>
Signed-off-by: Aline Manera &lt;<a href="mailto:alinefm@linux.vnet.ibm.com">alinefm@linux.vnet.ibm.com</a>&gt;<br>
---<br>
 tests/test_model.py | 40 ++++++++++++++++++++--------------------<br>
 1 file changed, 20 insertions(+), 20 deletions(-)<br>
<br>
diff --git a/tests/test_model.py b/tests/test_model.py<br>
index 602ca6e..3828342 100644<br>
--- a/tests/test_model.py<br>
+++ b/tests/test_model.py<br>
@@ -48,13 +48,13 @@ invalid_repository_urls = [&#39;<a href="http://www.fedora.org" rel="noreferrer" target="_blank">www.fedora.org</a>&#39;,       # missing protocol<br>
                            &#39;<a href="http://www.fedora" rel="noreferrer" target="_blank">http://www.fedora</a>&#39;,    # invalid domain name<br>
                            &#39;file:///home/foobar&#39;]  # invalid path<br>
<br>
-ISO_PATH = &#39;/tmp/kimchi-model-iso/&#39;<br>
-UBUNTU_ISO = ISO_PATH + &#39;ubuntu14.04.iso&#39;<br>
+TMP_DIR = &#39;/var/lib/kimchi/tests/&#39;<br>
+UBUNTU_ISO = TMP_DIR + &#39;ubuntu14.04.iso&#39;<br>
<br>
<br>
 def setUpModule():<br>
-    if not os.path.exists(ISO_PATH):<br>
-        os.makedirs(ISO_PATH)<br>
+    if not os.path.exists(TMP_DIR):<br>
+        os.makedirs(TMP_DIR)<br>
<br>
     iso_gen.construct_fake_iso(UBUNTU_ISO, True, &#39;14.04&#39;, &#39;ubuntu&#39;)<br>
<br>
@@ -68,7 +68,7 @@ def setUpModule():<br>
<br>
<br>
 def tearDownModule():<br>
-    shutil.rmtree(ISO_PATH)<br>
+    shutil.rmtree(TMP_DIR)<br>
<br>
<br>
 class ModelTests(unittest.TestCase):<br>
@@ -382,7 +382,7 @@ class ModelTests(unittest.TestCase):<br>
<br>
     @unittest.skipUnless(utils.running_as_root(), &#39;Must be run as root&#39;)<br>
     def test_vm_disk(self):<br>
-        disk_path = &#39;/tmp/existent2.iso&#39;<br>
+        disk_path = os.path.join(TMP_DIR, &#39;existent2.iso&#39;)<br>
         open(disk_path, &#39;w&#39;).close()<br>
         modern_disk_bus = get_template_default(&#39;modern&#39;, &#39;disk_bus&#39;)<br>
<br>
@@ -403,7 +403,7 @@ class ModelTests(unittest.TestCase):<br>
<br>
         inst = model.Model(objstore_loc=self.tmp_store)<br>
         with RollbackContext() as rollback:<br>
-            path = os.path.join(os.getcwd(), &#39;kimchi-images&#39;)<br>
+            path = os.path.join(TMP_DIR, &#39;kimchi-images&#39;)<br>
             pool = &#39;test-pool&#39;<br>
             vol = &#39;test-volume.img&#39;<br>
             vol_path = &quot;%s/%s&quot; % (path, vol)<br>
@@ -468,7 +468,7 @@ class ModelTests(unittest.TestCase):<br>
             self.assertRaises(<br>
                 InvalidParameter, inst.vmstorages_create, vm_name, disk_args)<br>
<br>
-            old_distro_iso = ISO_PATH + &#39;rhel4_8.iso&#39;<br>
+            old_distro_iso = TMP_DIR + &#39;rhel4_8.iso&#39;<br>
             iso_gen.construct_fake_iso(old_distro_iso, True, &#39;4.8&#39;, &#39;rhel&#39;)<br>
<br>
             vm_name = &#39;kimchi-ide-bus-vm&#39;<br>
@@ -508,8 +508,8 @@ class ModelTests(unittest.TestCase):<br>
             self.assertEquals(1, prev_count)<br>
<br>
             # dummy .iso files<br>
-            iso_path = &#39;/tmp/existent.iso&#39;<br>
-            iso_path2 = &#39;/tmp/existent2.iso&#39;<br>
+            iso_path = os.path.join(TMP_DIR, &#39;existent.iso&#39;)<br>
+            iso_path2 = os.path.join(TMP_DIR, &#39;existent2.iso&#39;)<br>
             open(iso_path, &#39;w&#39;).close()<br>
             rollback.prependDefer(os.remove, iso_path)<br>
             open(iso_path2, &#39;w&#39;).close()<br>
@@ -996,20 +996,20 @@ class ModelTests(unittest.TestCase):<br>
         inst = model.Model(None,<br>
                            objstore_loc=self.tmp_store)<br>
         with RollbackContext() as rollback:<br>
-            path = &#39;/tmp/kimchi-images/tmpdir&#39;<br>
-            if not os.path.exists(path):<br>
-                os.makedirs(path)<br>
-            iso_gen.construct_fake_iso(&#39;/tmp/kimchi-images/tmpdir/&#39;<br>
-                                       &#39;ubuntu12.04.iso&#39;, True,<br>
-                                       &#39;12.04&#39;, &#39;ubuntu&#39;)<br>
-            iso_gen.construct_fake_iso(&#39;/tmp/kimchi-images/sles10.iso&#39;,<br>
-                                       True, &#39;10&#39;, &#39;sles&#39;)<br>
+            deep_path = os.path.join(TMP_DIR, &#39;deep-scan&#39;)<br>
+            subdir_path = os.path.join(deep_path, &#39;isos&#39;)<br>
+            if not os.path.exists(subdir_path):<br>
+                os.makedirs(subdir_path)<br>
+            ubuntu_iso = os.path.join(deep_path, &#39;ubuntu12.04.iso&#39;)<br>
+            sles_iso = os.path.join(subdir_path, &#39;sles10.iso&#39;)<br>
+            iso_gen.construct_fake_iso(ubuntu_iso, True, &#39;12.04&#39;, &#39;ubuntu&#39;)<br>
+            iso_gen.construct_fake_iso(sles_iso, True, &#39;10&#39;, &#39;sles&#39;)<br>
<br>
             args = {&#39;name&#39;: &#39;kimchi-scanning-pool&#39;,<br>
-                    &#39;path&#39;: &#39;/tmp/kimchi-images&#39;,<br>
+                    &#39;path&#39;: deep_path,<br>
                     &#39;type&#39;: &#39;kimchi-iso&#39;}<br>
             inst.storagepools_create(args)<br>
-            rollback.prependDefer(shutil.rmtree, &#39;/tmp/kimchi-images&#39;)<br>
+            rollback.prependDefer(shutil.rmtree, deep_path)<br>
             rollback.prependDefer(shutil.rmtree, args[&#39;path&#39;])<br>
             rollback.prependDefer(inst.storagepool_deactivate, args[&#39;name&#39;])<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.1.0<br>
<br>
_______________________________________________<br>
Kimchi-devel mailing list<br>
<a href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Daniel Henrique Barboza<div>Senior Software Engineer - IBM Linux Technology Center </div></div></div>
</div>