[KVM-AUTOTEST PATCH 3/6] KVM test: add a function that translates user specified paths to real ones

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a user specified path is an absolute one, it is returned as is.
If it's relative, it's appended to a certain base path.

This function is meant to allow framework and test code to treat all user
specified paths equally.

Signed-off-by: Michael Goldish <mgoldish@xxxxxxxxxx>
---
 client/tests/kvm/kvm_utils.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_utils.py b/client/tests/kvm/kvm_utils.py
index 4c4753b..5e9e90d 100644
--- a/client/tests/kvm/kvm_utils.py
+++ b/client/tests/kvm/kvm_utils.py
@@ -677,6 +677,21 @@ def find_free_ports(start_port, end_port, count):
 
 # The following are miscellaneous utility functions.
 
+def get_path(base_path, user_path):
+    """
+    Translate a user specified path to a real path.
+    If user_path is relative, append it to base_path.
+    If user_path is absolute, return it as is.
+
+    @param base_path: The base path of relative user specified paths.
+    @param user_path: The user specified path.
+    """
+    if os.path.isabs(user_path):
+        return user_path
+    else:
+        return os.path.join(base_path, user_path)
+
+
 def generate_random_string(length):
     """
     Return a random string using alphanumeric characters.
-- 
1.5.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux