xref: /OK3568_Linux_fs/buildroot/support/testing/tests/package/test_python_twisted.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1from tests.package.test_python import TestPythonPackageBase
2
3
4class TestPythonTwisted(TestPythonPackageBase):
5    config = TestPythonPackageBase.config
6    sample_scripts = ["tests/package/sample_python_twisted.py"]
7
8    def run_sample_scripts(self):
9        cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:1234"
10        _, exit_code = self.emulator.run(cmd)
11        self.assertEqual(exit_code, 1)
12
13        cmd = self.interpreter + " sample_python_twisted.py &"
14        # give some time to setup the server
15        cmd += "sleep 30"
16        _, exit_code = self.emulator.run(cmd, timeout=35)
17        self.assertEqual(exit_code, 0)
18
19        cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:1234"
20        _, exit_code = self.emulator.run(cmd)
21        self.assertEqual(exit_code, 0)
22
23
24class TestPythonPy3Twisted(TestPythonTwisted):
25    __test__ = True
26    config = TestPythonTwisted.config + \
27        """
28        BR2_PACKAGE_PYTHON3=y
29        BR2_PACKAGE_PYTHON_TWISTED=y
30        """
31