18784 smf flavor does not cope with symlinks to proto areas
authorTim Foster <tim.s.foster@oracle.com>
Wed, 10 Aug 2011 10:43:09 +1200
changeset 2501 b5669f6ba871
parent 2500 a63fead21404
child 2502 aaeebfbd0446
18784 smf flavor does not cope with symlinks to proto areas
src/modules/flavor/smf_manifest.py
src/tests/api/t_dependencies.py
--- a/src/modules/flavor/smf_manifest.py	Tue Aug 09 11:27:12 2011 -0700
+++ b/src/modules/flavor/smf_manifest.py	Wed Aug 10 10:43:09 2011 +1200
@@ -55,6 +55,17 @@
                 base.PublishingDependency.__init__(self, action,
                     base_names, paths, pkg_vars, proto_dir, "smf_manifest")
 
+        def __repr__(self):
+                return "SMFDep(%s, %s, %s, %s)" % (self.action,
+                    self.base_names[0], self.run_paths, self.pkg_vars)
+
+        @staticmethod
+        def _clear_cache():
+                """Clear our manifest caches.  This is primarily provided for
+                test code."""
+                SMFManifestDependency.instance_mf = None
+                SMFManifestDependency.instance_deps = None
+
         @staticmethod
         def populate_cache(proto_dirs, force_update=False):
                 """Build our instance_mf and instance_deps dictionaries
@@ -364,7 +375,7 @@
         manifest_path = None
 
         if isinstance(smf_file, str):
-                manifest_path = os.path.realpath(smf_file)
+                manifest_path = smf_file
 
         svcs = smf_doc.getElementsByTagName("service")
         for service in svcs:
--- a/src/tests/api/t_dependencies.py	Tue Aug 09 11:27:12 2011 -0700
+++ b/src/tests/api/t_dependencies.py	Wed Aug 10 10:43:09 2011 +1200
@@ -2414,6 +2414,41 @@
                     "generating dependencies with non-matching bypass entries "
                     "changed the returned dependencies")
 
+        def test_symlinked_proto(self):
+                """Ensure that the behavior when using a symlink to a proto dir
+                is identical to the behavior when using that proto dir for all
+                flavors."""
+
+                multi_flavor_manf = (self.ext_hardlink_manf +
+                     self.ext_script_manf + self.ext_elf_manf +
+                     self.ext_python_manf + self.ext_smf_manf +
+                     self.relative_int_manf)
+                t_path = self.make_manifest(multi_flavor_manf)
+
+                linked_proto = os.path.join(self.test_root, "linked_proto")
+                os.symlink(self.proto_dir, linked_proto)
+
+                self.make_proto_text_file(self.paths["script_path"],
+                    self.script_text)
+                self.make_smf_test_files()
+                self.make_python_test_files(2.6)
+                self.make_elf(self.paths["curses_path"])
+
+                ds, es, ms, pkg_attrs = dependencies.list_implicit_deps(t_path,
+                    [self.proto_dir], {}, [], remove_internal_deps=False,
+                    convert=False)
+
+                smf.SMFManifestDependency._clear_cache()
+
+                # now run the same function, this time using our symlinked dir
+                dsl, esl, msl, pkg_attrsl = dependencies.list_implicit_deps(
+                    t_path, [linked_proto], {}, [],
+                    remove_internal_deps=False, convert=False)
+
+                for a, b in [(ds, dsl), (pkg_attrs, pkg_attrsl)]:
+                            self.assert_(a == b, "Differences found comparing "
+                                "proto_dir with symlinked proto_dir: %s vs. %s"
+                                % (a, b))
 
 if __name__ == "__main__":
         unittest.main()