From patchwork Sun Aug 9 16:33:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 40269 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n79GVcwl000549 for ; Sun, 9 Aug 2009 16:31:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751983AbZHIQbd (ORCPT ); Sun, 9 Aug 2009 12:31:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751969AbZHIQbc (ORCPT ); Sun, 9 Aug 2009 12:31:32 -0400 Received: from mx2.redhat.com ([66.187.237.31]:35275 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751926AbZHIQbX (ORCPT ); Sun, 9 Aug 2009 12:31:23 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n79GVOYM021925; Sun, 9 Aug 2009 12:31:24 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n79GVNGS030023; Sun, 9 Aug 2009 12:31:23 -0400 Received: from localhost.localdomain (dhcp-1-31.tlv.redhat.com [10.35.1.31]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n79GVGYF020666; Sun, 9 Aug 2009 12:31:22 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 3/6] KVM test: add a function that translates user specified paths to real ones Date: Sun, 9 Aug 2009 19:33:55 +0300 Message-Id: <1872f2f7ac12ca9fa788f5f14ae2f8afc9f26db7.1249835043.git.mgoldish@redhat.com> In-Reply-To: <836c405266cd58509071052cc25072d52e84f9a7.1249835043.git.mgoldish@redhat.com> References: <1249835638-18153-1-git-send-email-mgoldish@redhat.com> <836c405266cd58509071052cc25072d52e84f9a7.1249835043.git.mgoldish@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- 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.