Пример #1
0
    def setUp(self):
        self.skip = 0
        self.testInput = "%s/testInput.xml" % getTempDir()
        if os.path.exists(self.testInput):
            self.dom = xml.dom.minidom.parse(self.testInput)
            self.checkSkip()
        else:
            self.skip = 1

        import libsmbios_c.memory as m
        import libsmbios_c.cmos as c
        import libsmbios_c.smbios as s

        # initialize global singletons
        m.MemoryAccess(m.MEMORY_GET_SINGLETON | m.MEMORY_UNIT_TEST_MODE,
                       "%s/memdump.dat" % getTempDir())
        c.CmosAccess(c.CMOS_GET_SINGLETON | c.CMOS_UNIT_TEST_MODE,
                     "%s/cmos.dat" % getTempDir())
        s.SmbiosTable(s.SMBIOS_GET_SINGLETON | s.SMBIOS_UNIT_TEST_MODE)

        # use private copies for testing
        self.memObj = m.MemoryAccess(
            m.MEMORY_GET_NEW | m.MEMORY_UNIT_TEST_MODE,
            "%s/memdump.dat" % getTempDir())
        self.cmosObj = c.CmosAccess(c.CMOS_GET_NEW | c.CMOS_UNIT_TEST_MODE,
                                    "%s/cmos.dat" % getTempDir())
        self.tableObj = s.SmbiosTable(s.SMBIOS_GET_NEW
                                      | s.SMBIOS_UNIT_TEST_MODE)
Пример #2
0
    def setUp(self):
        # write some values to a test file that we will use for both cmos and mem tests
        self.testfile = "%s/%s-testmem.dat" % (getTempDir(),
                                               self._testMethodName)
        fd = open(self.testfile, "w+")
        for i in range(pagesize * 4 + 1):
            fd.write("j")
        fd.close()
        self.testfile = self.testfile.encode('utf-8')

        import libsmbios_c.memory as m
        self.memObj = m.MemoryAccess(
            m.MEMORY_GET_NEW | m.MEMORY_UNIT_TEST_MODE, self.testfile)

        import libsmbios_c.cmos as c
        self.cmosObj = c.CmosAccess(c.CMOS_GET_NEW | c.CMOS_UNIT_TEST_MODE,
                                    self.testfile)

        # replace first 26 bytes with alphabet
        for i in range(26):
            self.memObj.write(chr(ord("a") + i).encode('utf-8'), i)

        # write pages of '0', '1', and '2'
        for i in range(3):
            self.memObj.write(
                chr(ord("0") + i).encode('utf-8') * pagesize,
                26 + (pagesize * i))

        self.memObj.close_hint(1)
Пример #3
0
 def testForLeaks(self):
     # create/destroy lots of objects to see if we leak
     import libsmbios_c.memory as m
     import libsmbios_c.cmos as c
     for i in xrange(1000):
         mObj = m.MemoryAccess(m.MEMORY_GET_NEW | m.MEMORY_UNIT_TEST_MODE, "/dev/null")
         cObj = c.CmosAccess(c.CMOS_GET_NEW | c.CMOS_UNIT_TEST_MODE, "/dev/null")
         del(mObj)
         del(cObj)
Пример #4
0
def setup_std_options(options):
    if options.memory_dat is not None:
        memory.MemoryAccess(
            memory.MEMORY_GET_SINGLETON | memory.MEMORY_UNIT_TEST_MODE,
            options.memory_dat)

    if options.cmos_dat is not None:
        cmos.CmosAccess(cmos.CMOS_GET_SINGLETON | cmos.CMOS_UNIT_TEST_MODE,
                        options.cmos_dat)

    options.password_scancode = None
    if options.password is not None:
        options.password_scancode = braindead_asc_to_scancode(options.password)
    options.password_ascii = options.password
    if options.raw:
        options.password_scancode = options.password

    if getattr(options, "security_key", None) is not None:
        options.security_key = int(options.security_key, 0)

    setupLogging(options.logconfig, options.verbosity, options.trace)