15684492 pkg verify fails to notice when a file should be faceted out s12b52
authorYiteng Zhang <yiteng.zhang@oracle.com>
Tue, 08 Jul 2014 14:47:30 -0700
changeset 3096 16c8abf429d4
parent 3094 15de2efea709
child 3097 0dffc9373613
15684492 pkg verify fails to notice when a file should be faceted out
src/modules/client/image.py
src/tests/cli/t_change_facet.py
--- a/src/modules/client/image.py	Tue Jul 01 11:28:17 2014 -0700
+++ b/src/modules/client/image.py	Tue Jul 08 14:47:30 2014 -0700
@@ -2253,7 +2253,9 @@
                             med.mediator_impl_matches(med_impl, cfg_med_impl)
 
                 try:
-                        for act in manf.gen_actions(excludes=self.list_excludes()):
+                        excludes = self.list_excludes()
+                        variant_excludes = [self.cfg.variants.allow_action]
+                        for act in manf.gen_actions():
                                 progresstracker.verify_add_progress(fmri)
                                 if (act.name == "link" or
                                     act.name == "hardlink") and \
@@ -2262,8 +2264,22 @@
                                         # mediation, so shouldn't be verified.
                                         continue
 
-                                errors, warnings, info = act.verify(self,
-                                    pfmri=fmri, **kwargs)
+                                if act.include_this(excludes):
+                                        errors, warnings, info = act.verify(
+                                            self, pfmri=fmri, **kwargs)
+                                elif act.include_this(variant_excludes):
+                                        # Verify that file that is faceted out
+                                        # does not exist.
+                                        errors = []
+                                        path = act.attrs.get("path", None)
+                                        if path is not None and os.path.exists(
+                                            os.path.join(self.root, path)):
+                                                errors.append(
+                                                    _("File should not exist"))
+                                else:
+                                        # Action not applicable to image variant.
+                                        continue
+
                                 actname = act.distinguished_name()
                                 if errors:
                                         progresstracker.verify_yield_error(
--- a/src/tests/cli/t_change_facet.py	Tue Jul 01 11:28:17 2014 -0700
+++ b/src/tests/cli/t_change_facet.py	Tue Jul 08 14:47:30 2014 -0700
@@ -156,6 +156,11 @@
                     self.output
                 )
 
+                # notice that a file should not exist according to its facet
+                file(os.path.join(self.get_img_path(), "3"), "w")
+                self.pkg("verify", exit=1)
+                os.remove(os.path.join(self.get_img_path(), "3"))
+
                 # verify that a non-existent facet can be set when other facets
                 # are in effect
                 self.pkg("change-facet -n --parsable=0 wombat=false")