test_crudini.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import os
  2. from tests.package.test_python import TestPythonPackageBase
  3. INI_FILE_CONTENT = """
  4. [section]
  5. param = this-is-the-magic-value
  6. other = dont care
  7. """
  8. class TestCrudiniBase(TestPythonPackageBase):
  9. config = TestPythonPackageBase.config + \
  10. """
  11. BR2_PACKAGE_CRUDINI=y
  12. """
  13. def test_run(self):
  14. img = os.path.join(self.builddir, "images", "rootfs.cpio")
  15. self.emulator.boot(arch="armv5", kernel="builtin",
  16. options=["-initrd", img])
  17. self.emulator.login()
  18. # 1. Create some sample .ini file
  19. cmd = "echo -e '%s' > config.ini" % INI_FILE_CONTENT
  20. _, ret = self.emulator.run(cmd)
  21. self.assertEqual(ret, 0)
  22. # 2. Attempt to get the value
  23. out, ret = self.emulator.run("crudini --get config.ini section param")
  24. self.assertEqual(ret, 0)
  25. self.assertEqual(out, ['this-is-the-magic-value'])
  26. class TestCrudiniPy3(TestCrudiniBase):
  27. __test__ = True
  28. config = TestCrudiniBase.config + \
  29. """
  30. BR2_PACKAGE_PYTHON3=y
  31. """