From patchwork Tue Dec 8 02:59:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 65615 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 nB82xZId007224 for ; Tue, 8 Dec 2009 02:59:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965447AbZLHC70 (ORCPT ); Mon, 7 Dec 2009 21:59:26 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S965421AbZLHC70 (ORCPT ); Mon, 7 Dec 2009 21:59:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5780 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965416AbZLHC7X (ORCPT ); Mon, 7 Dec 2009 21:59:23 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB82xT8j004859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Dec 2009 21:59:29 -0500 Received: from localhost.localdomain (vpn-11-165.rdu.redhat.com [10.11.11.165]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nB82xBso014907; Mon, 7 Dec 2009 21:59:27 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, mgoldish@redhat.com, Lucas Meneghel Rodrigues Subject: [PATCH 3/5] KVM test: Verify paths to cdrom and qemu on kvm_preprocessing Date: Tue, 8 Dec 2009 00:59:03 -0200 Message-Id: <1260241145-19029-3-git-send-email-lmr@redhat.com> In-Reply-To: <1260241145-19029-2-git-send-email-lmr@redhat.com> References: <1260241145-19029-1-git-send-email-lmr@redhat.com> <1260241145-19029-2-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 5bae2bd..85a2d9c 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -187,6 +187,29 @@ def preprocess(test, params, env): @param params: A dict containing all VM and image parameters. @param env: The environment (a dict-like object). """ + # Verify if the: + # * CD locations + # * qemu and qemu-img binaries + # are valid paths + needed_paths = [[params.get("cdrom", ""), + os.path.join(test.bindir, 'isos')], + [params.get("qemu_binary", ""), test.bindir], + [params.get("qemu_img_binary", ""), test.bindir]] + + missing_paths = [] + for needed_path, root_dir in needed_paths: + # If the test doesn't set one of the parameters, + # just don't check for it. + if needed_path: + needed_path = kvm_utils.get_path(root_dir, needed_path) + if not _is_path_present(needed_path): + missing_paths.append(needed_path) + + if missing_paths: + raise error.TestError("The following needed paths are missing " + "or are broken symbolic links: %s" % + missing_paths) + # Start tcpdump if it isn't already running if not env.has_key("address_cache"): env["address_cache"] = {} @@ -343,3 +366,28 @@ def _update_address_cache(address_cache, line): mac_address, address_cache.get("last_seen")) address_cache[mac_address] = address_cache.get("last_seen") del address_cache["last_seen"] + + +def _is_path_present(path): + """ + Verify whether a given path to a file is present (follows symlinks). + + @param path: Path to the file. + @return: True when the file is present, False when it's not. + """ + exists = True + + if os.path.islink(path): + source = os.path.abspath(os.readlink(path)) + if not os.path.isfile(source): + logging.warning("File %s, needed for this test, " + "is a broken symbolic link. Please fix your " + "test configuration." % path) + exists = False + elif not os.path.isfile(path): + logging.warning("File %s, needed for this test, does not exist. " + "Please fix your test configuration." % path) + exists = False + + return exists +