def testAccruePXML(self): target = ctypes.create_string_buffer(libpnd.PXML_MAXLEN) # Find all PNDs for testing (as per testDiscovery). search = libpnd.disco_search(testfiles, None) n = libpnd.box_get_size(search) node = libpnd.box_get_head(search) pnds = [libpnd.box_get_key(node)] for i in xrange(n-1): node = libpnd.box_get_next(node) pnds.append(libpnd.box_get_key(node)) # Accrue all their PXMLs. for pth in pnds: f = libpnd.libc.fopen(pth,'r') ret = libpnd.pnd_seek_pxml(f) self.assertEqual(ret, 1) ret = libpnd.pnd_accrue_pxml(f, target, libpnd.PXML_MAXLEN) self.assertEqual(ret, 1) self.assertIn(target.value, open(pth,'rb').read()) self.assertEqual(target.value[:5], '<PXML') # Some PNDs seem to have the first 6 bytes of the icon added on to # the end of the accrued PXML. Hopefully won't disrupt parsing. self.assertIn('</PXML>', target.value[-13:])
def testDiscovery(self): search = libpnd.disco_search(testfiles, None) # Note this gives the number of applications, not the number of # packages found. This test has several packages, some of which hold # multiple apps. n = libpnd.box_get_size(search) self.assertEqual(n, 15) node = libpnd.box_get_head(search) pnds = [libpnd.box_get_key(node)] for i in xrange(n-1): node = libpnd.box_get_next(node) pnds.append(libpnd.box_get_key(node)) self.assertSetEqual(set(map(os.path.basename, pnds)), {'BubbMan2.pnd', 'Sparks-0.4.2.pnd', 'The Lonely Tower-2.2.pnd', 'fulltest.pnd', 'Chromium-dev.pxml.pnd', 'Hexen2.pxml.pnd', 'scummvm-op.pxml.pnd', 'java.pxml.pnd','pcsx.pxml.pnd','Chromium-Dev.evildragon.pxml.pnd', 'stella.pxml.pnd'})