bool TestSuite::testParityBinaryImageWrite() { try { utils::Task::ArgumentVector arguments; utils::Path cfile = utils::Path::getTemporary(".parity.testsuite.link.XXXXXX.c"); utils::Path ofile = utils::Path::getTemporary(".parity.testsuite.link.XXXXXX.exe"); std::ofstream ofs(cfile.get().c_str()); ofs << dataCFile; ofs.close(); utils::Context::getContext().getTemporaryFiles().push_back(cfile); utils::Context::getContext().getTemporaryFiles().push_back(ofile); arguments.push_back(cfile.get()); arguments.push_back("-o"); arguments.push_back(ofile.get()); if(!executeParity(arguments, false)) throw utils::Exception("cannot execute parity for test suite!"); if(!ofile.exists()) throw utils::Exception("missing executable file from compile!"); utils::Log::verbose("doing parsed copy of %s...\n", ofile.get().c_str()); utils::MappedFile mapping(ofile, utils::ModeRead); //utils::MappedFile mapping(utils::Path("test.exe"), utils::ModeRead); binary::Image img(&mapping); utils::Log::verbose("testing original file:\n"); testFileHeader(img.getHeader()); utils::Path temp = utils::Path::getTemporary(".parity.testsuite.image.XXXXXX.exe"); utils::Context::getContext().getTemporaryFiles().push_back(temp); utils::MemoryFile file; img.update(file); file.save(temp); utils::MappedFile check_mapping(temp, utils::ModeRead); binary::Image check_img(&check_mapping); utils::Log::verbose("testing parsed copy of executable:\n"); testFileHeader(check_img.getHeader()); return true; } catch(const utils::Exception& e) { utils::Log::warning("catched: %s\n", e.what()); } return false; }
void init_initrd(void) { if (multiboot_info.mods_count < 1) { panic("No initrd."); } void *disk; char *params; int size = mod_load(0, &disk, ¶ms); dbg_printf(DBG_FS, "Loading initrd '%s' at %p with %d bytes length.\n", params, disk, size); if (!check_img(disk)) { panic("Module 1 is not a kOS initrd (%s)\n", params); } root = parse_dir(disk + sizeof(struct id_header), disk); vfs_register(&initrd); }