--- a/usr/src/lib/install_target/discovery.py Fri Jun 29 00:42:35 2012 -0600
+++ b/usr/src/lib/install_target/discovery.py Fri Jun 29 20:45:21 2012 -0600
@@ -76,6 +76,9 @@
DISK_SEARCH_NAME = "disk"
ZPOOL_SEARCH_NAME = "zpool"
+# path for CLI engine log
+CLI_DEFAULT_LOG = "/system/volatile/discovery.log"
+
# regex for matching c#t#d# OR c#d# strings. Use \w rather than \d for the
# "t" to allow matching of WWNs
DISK_RE = "c\d+(?:t\w+)?d\d+"
@@ -1209,7 +1212,7 @@
sys.exit()
# set up Target Discovery and execute it, finding the entire system
- InstallEngine()
+ InstallEngine(default_log=CLI_DEFAULT_LOG)
TD = TargetDiscovery("Test TD")
# set dry_run to True so we don't label any drives on SPARC
@@ -1227,3 +1230,4 @@
print_zpool(TD.doc)
if options.xml:
print TD.doc.get_xml_tree_str()
+ print "Additional debug information can be found in %s" % CLI_DEFAULT_LOG
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr/src/lib/install_target/test/test_target_discovery.py Fri Jun 29 20:45:21 2012 -0600
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+#
+
+""" test_target_discovery.py - collection of unittests for testing target
+discovery.
+"""
+
+import os
+import unittest
+
+from nose.plugins.skip import SkipTest
+
+from solaris_install import Popen
+from solaris_install.target.discovery import CLI_DEFAULT_LOG
+
+PYTHON = "/usr/bin/python"
+
+
+class TestCLI(unittest.TestCase):
+ """ test case to test the target discovery CLI
+ """
+
+ def setUp(self):
+ if not "SRC" in os.environ:
+ raise SkipTest("test requires a gate building environment")
+
+ self.logpath = CLI_DEFAULT_LOG
+ self.discovery_path = os.path.join(os.getenv("SRC"),
+ "lib/install_target/discovery.py")
+
+ def tearDown(self):
+ os.remove(self.logpath)
+
+ def test_simple_execution(self):
+ # simply find all the disks on the system to verify the basic execution
+ # of discovery.py
+ cmd = [PYTHON, self.discovery_path, "-d"]
+ p = Popen.check_call(cmd, stdout=Popen.STORE, stderr=Popen.STORE)
+ self.assertTrue(os.path.exists(self.logpath))
+ self.assertEqual(p.returncode, 0)
+ self.assertTrue(p.stdout)