示例#1
0
def test_find_devs_with_netbsd(m_subp):
    side_effect_values = [
        ("ld0 dk0 dk1 cd0", ""),
        (
            (
                "mscdlabel: CDIOREADTOCHEADER: "
                "Inappropriate ioctl for device\n"
                "track (ctl=4) at sector 0\n"
                "disklabel not written\n"
            ),
            "",
        ),
        (
            (
                "mscdlabel: CDIOREADTOCHEADER: "
                "Inappropriate ioctl for device\n"
                "track (ctl=4) at sector 0\n"
                "disklabel not written\n"
            ),
            "",
        ),
        (
            (
                "mscdlabel: CDIOREADTOCHEADER: "
                "Inappropriate ioctl for device\n"
                "track (ctl=4) at sector 0\n"
                "disklabel not written\n"
            ),
            "",
        ),
        (
            (
                "track (ctl=4) at sector 0\n"
                'ISO filesystem, label "config-2", '
                "creation time: 2020/03/31 17:29\n"
                "adding as 'a'\n"
            ),
            "",
        ),
    ]
    m_subp.side_effect = side_effect_values
    devlist = util.find_devs_with_netbsd()
    assert set(devlist) == set(
        ["/dev/ld0", "/dev/dk0", "/dev/dk1", "/dev/cd0"]
    )
    m_subp.side_effect = side_effect_values
    devlist = util.find_devs_with_netbsd(criteria="TYPE=iso9660")
    assert devlist == ["/dev/cd0"]
    m_subp.side_effect = side_effect_values
    devlist = util.find_devs_with_netbsd(criteria="TYPE=vfat")
    assert devlist == ["/dev/ld0", "/dev/dk0", "/dev/dk1"]
示例#2
0
 def test_find_devs_with_netbsd(self, m_subp, criteria, expected_devlist):
     side_effect_values = [
         ("ld0 dk0 dk1 cd0", ""),
         (
             ("mscdlabel: CDIOREADTOCHEADER: "
              "Inappropriate ioctl for device\n"
              "track (ctl=4) at sector 0\n"
              "disklabel not written\n"),
             "",
         ),
         (
             ("mscdlabel: CDIOREADTOCHEADER: "
              "Inappropriate ioctl for device\n"
              "track (ctl=4) at sector 0\n"
              "disklabel not written\n"),
             "",
         ),
         (
             ("mscdlabel: CDIOREADTOCHEADER: "
              "Inappropriate ioctl for device\n"
              "track (ctl=4) at sector 0\n"
              "disklabel not written\n"),
             "",
         ),
         (
             ("track (ctl=4) at sector 0\n"
              'ISO filesystem, label "config-2", '
              "creation time: 2020/03/31 17:29\n"
              "adding as 'a'\n"),
             "",
         ),
     ]
     m_subp.side_effect = side_effect_values
     devlist = util.find_devs_with_netbsd(criteria=criteria)
     assert devlist == expected_devlist