test_jffs2.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import os
  2. import subprocess
  3. import infra.basetest
  4. def jffs2dump_find_file(files_list, fname):
  5. for file_name in files_list:
  6. file_name = file_name.strip()
  7. if file_name.startswith("Dirent") and file_name.endswith(fname):
  8. return True
  9. return False
  10. class TestJffs2(infra.basetest.BRTest):
  11. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  12. """
  13. BR2_TARGET_ROOTFS_JFFS2=y
  14. BR2_TARGET_ROOTFS_JFFS2_CUSTOM=y
  15. BR2_TARGET_ROOTFS_JFFS2_CUSTOM_EBSIZE=0x80000
  16. BR2_TARGET_ROOTFS_JFFS2_NOCLEANMARKER=y
  17. BR2_TARGET_ROOTFS_JFFS2_PAD=y
  18. BR2_TARGET_ROOTFS_JFFS2_PADSIZE=0x4000000
  19. # BR2_TARGET_ROOTFS_TAR is not set
  20. """
  21. # TODO: there are some scary JFFS2 messages when one starts to
  22. # write files in the rootfs: "jffs2: Newly-erased block contained
  23. # word 0x0 at offset 0x046c0000". To be investigated.
  24. def test_run(self):
  25. img = os.path.join(self.builddir, "images", "rootfs.jffs2")
  26. out = subprocess.check_output(["host/usr/sbin/jffs2dump", "-c", img],
  27. cwd=self.builddir,
  28. env={"LANG": "C"})
  29. out = out.splitlines()
  30. self.assertTrue(jffs2dump_find_file(out, "busybox"))
  31. self.emulator.boot(arch="armv7",
  32. kernel="builtin",
  33. kernel_cmdline=["root=/dev/mtdblock0",
  34. "rootfstype=jffs2"],
  35. options=["-drive", "file={},if=pflash".format(img)])
  36. self.emulator.login()
  37. cmd = "mount | grep '/dev/root on / type jffs2'"
  38. _, exit_code = self.emulator.run(cmd)
  39. self.assertEqual(exit_code, 0)