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