grr/core/grr_response_core/lib/parsers/linux_cmd_parser_test.py
def testRpmCmdParser(self):
    """Ensure we can extract packages from rpm output."""
    parser = linux_cmd_parser.RpmCmdParser()
    content = """
      glib2-2.12.3-4.el5_3.1
      elfutils-libelf-0.137-3.el5
      libgpg-error-1.4-2
      keyutils-libs-1.2-1.el5
      less-436-9.el5
      libstdc++-devel-4.1.2-55.el5
      gcc-c++-4.1.2-55.el5
      -not-valid.123.el5
    """
    stderr = "error: rpmdbNextIterator: skipping h#"
    out = list(parser.Parse("/bin/rpm", ["-qa"], content, stderr, 0, 5, None))
    software = {
        o.name: o.version
        for o in out
        if isinstance(o, rdf_client.SoftwarePackage)
    }
    anomaly = [o for o in out if isinstance(o, rdf_anomaly.Anomaly)]
    self.assertLen(software, 7)
    self.assertLen(anomaly, 1)
    expected = {
        "glib2": "2.12.3-4.el5_3.1",
        "elfutils-libelf": "0.137-3.el5",
        "libgpg-error": "1.4-2",
        "keyutils-libs": "1.2-1.el5",
        "less": "436-9.el5",
        "libstdc++-devel": "4.1.2-55.el5",
        "gcc-c++": "4.1.2-55.el5"
    }
    self.assertCountEqual(expected, software)
    self.assertEqual("Broken rpm database.", anomaly[0].symptom)
Ensure we can extract packages from rpm output.
Ensure we can extract packages from rpm output.
Ensure we can extract packages from rpm output .
def testRpmCmdParser(self):
    parser = linux_cmd_parser.RpmCmdParser()
    content = """
      glib2-2.12.3-4.el5_3.1
      elfutils-libelf-0.137-3.el5
      libgpg-error-1.4-2
      keyutils-libs-1.2-1.el5
      less-436-9.el5
      libstdc++-devel-4.1.2-55.el5
      gcc-c++-4.1.2-55.el5
      -not-valid.123.el5
    """
    stderr = "error: rpmdbNextIterator: skipping h#"
    out = list(parser.Parse("/bin/rpm", ["-qa"], content, stderr, 0, 5, None))
    software = {
        o.name: o.version
        for o in out
        if isinstance(o, rdf_client.SoftwarePackage)
    }
    anomaly = [o for o in out if isinstance(o, rdf_anomaly.Anomaly)]
    self.assertLen(software, 7)
    self.assertLen(anomaly, 1)
    expected = {
        "glib2": "2.12.3-4.el5_3.1",
        "elfutils-libelf": "0.137-3.el5",
        "libgpg-error": "1.4-2",
        "keyutils-libs": "1.2-1.el5",
        "less": "436-9.el5",
        "libstdc++-devel": "4.1.2-55.el5",
        "gcc-c++": "4.1.2-55.el5"
    }
    self.assertCountEqual(expected, software)
    self.assertEqual("Broken rpm database.", anomaly[0].symptom)
def testRpmCmdParser ( self ) : parser = linux_cmd_parser . RpmCmdParser ( ) content = """
      glib2-2.12.3-4.el5_3.1
      elfutils-libelf-0.137-3.el5
      libgpg-error-1.4-2
      keyutils-libs-1.2-1.el5
      less-436-9.el5
      libstdc++-devel-4.1.2-55.el5
      gcc-c++-4.1.2-55.el5
      -not-valid.123.el5
    """ stderr = "error: rpmdbNextIterator: skipping h#" out = list ( parser . Parse ( "/bin/rpm" , [ "-qa" ] , content , stderr , 0 , 5 , None ) ) software = { o . name : o . version for o in out if isinstance ( o , rdf_client . SoftwarePackage ) } anomaly = [ o for o in out if isinstance ( o , rdf_anomaly . Anomaly ) ] self . assertLen ( software , 7 ) self . assertLen ( anomaly , 1 ) expected = { "glib2" : "2.12.3-4.el5_3.1" , "elfutils-libelf" : "0.137-3.el5" , "libgpg-error" : "1.4-2" , "keyutils-libs" : "1.2-1.el5" , "less" : "436-9.el5" , "libstdc++-devel" : "4.1.2-55.el5" , "gcc-c++" : "4.1.2-55.el5" } self . assertCountEqual ( expected , software ) self . assertEqual ( "Broken rpm database." , anomaly [ 0 ] . symptom )
Ensure we can extract packages from rpm output.
Ensure we can extract packages from rpm output .
"""Ensure we can extract packages from rpm output."""
self