Merge branch 'next'

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
This commit is contained in:
Peter Korsgaard
2018-12-02 08:15:26 +01:00
440 changed files with 4151 additions and 4881 deletions

View File

@@ -0,0 +1,7 @@
#!/bin/sh
set -e
shift
for file in "$@"; do
cp -f "${file}" "${TARGET_DIR}/root/"
done

View File

@@ -0,0 +1,10 @@
import argh
@argh.arg("foo", help="help for foo")
@argh.arg("--bar", help="help for bar")
def main(foo, bar=False):
print("{}, {}".format(foo, bar))
argh.dispatch_command(main)

View File

@@ -0,0 +1,15 @@
import attr
@attr.s
class Obj(object):
x = attr.ib()
y = attr.ib(default=1)
obj1 = Obj(2)
assert(obj1.x == 2)
assert(obj1.y == 1)
obj2 = Obj(3, 4)
assert(obj2.x == 3)
assert(obj2.y == 4)

View File

@@ -0,0 +1 @@
import autobahn.wamp # noqa

View File

@@ -0,0 +1,27 @@
from automat import MethodicalMachine
class Led(object):
_machine = MethodicalMachine()
@_machine.state()
def led_on(self):
"led is on"
@_machine.state(initial=True)
def led_off(self):
"led is off"
@_machine.input()
def turn_on(self):
"turn the led on"
@_machine.output()
def _light(self):
print("light")
led_off.upon(turn_on, enter=led_on, outputs=[_light])
led = Led()
led.turn_on()

View File

@@ -0,0 +1,6 @@
import bitstring
value = bitstring.BitArray("uint:12=42")
assert(value.hex == "02a")
assert(value.bin == "000000101010")
assert(value.uint == 42)

View File

@@ -0,0 +1,10 @@
import cbor
with open("/tmp/data.cbor", "rb") as f:
serialized = f.read()
data = cbor.loads(serialized)
print(data)
assert(data["name"] == "python-cbor")
assert(data["versions"] == ["1", "2"])
assert(data["group"]["is_a_package"] is True)
assert(data["group"]["value"] == 42)

View File

@@ -0,0 +1,14 @@
import cbor
data = {
"name": "python-cbor",
"versions": ["1", "2"],
"group": {
"is_a_package": True,
"value": 42
}
}
serialized = cbor.dumps(data)
print(serialized)
with open("/tmp/data.cbor", "wb") as f:
f.write(serialized)

View File

@@ -0,0 +1,12 @@
import click
@click.command()
@click.argument("foo")
@click.option("--bar", is_flag=True, help="help for bar")
def main(foo, bar):
click.echo("{}, {}".format(foo, bar))
if __name__ == '__main__':
main()

View File

@@ -0,0 +1,19 @@
from constantly import ValueConstant, Values
class RESULT(Values):
OK = ValueConstant(0)
FAIL = ValueConstant(-1)
@classmethod
def get(cls, rc):
if rc == 0:
return cls.OK
else:
return cls.FAIL
print(list(RESULT.iterconstants()))
assert(RESULT.OK < RESULT.FAIL)
assert(RESULT.OK.value > RESULT.FAIL.value)
assert(RESULT.get(-5) == RESULT.FAIL)

View File

@@ -0,0 +1,3 @@
import crossbar
crossbar.run(["version"])

View File

@@ -0,0 +1,3 @@
from cryptography.fernet import Fernet
key = Fernet.generate_key()
f = Fernet(key)

View File

@@ -0,0 +1,3 @@
import incremental
v = incremental.Version("package", 1, 2, 3, release_candidate=4)
assert(str(v) == "[package, version 1.2.3rc4]")

View File

@@ -0,0 +1,5 @@
from passlib.hash import pbkdf2_sha256
hash = pbkdf2_sha256.hash("password")
assert(pbkdf2_sha256.verify("passWord", hash) is False)
assert(pbkdf2_sha256.verify("password", hash) is True)

View File

@@ -0,0 +1,8 @@
import pexpect
p = pexpect.spawn(["login"])
p.expect("login:")
p.sendline("wrong")
p.expect("Password:")
p.sendline("wrong")
p.expect("Login incorrect")

View File

@@ -0,0 +1,3 @@
import nacl.utils
nonce = nacl.utils.random(16)

View File

@@ -0,0 +1,10 @@
import yaml
with open("/tmp/data.yml", "rb") as f:
serialized = f.read()
data = yaml.load(serialized)
print(data)
assert(data["name"] == "python-pyyaml")
assert(data["versions"] == ["1", "2"])
assert(data["group"]["is_a_package"] is True)
assert(data["group"]["value"] == 42)

View File

@@ -0,0 +1,14 @@
import yaml
data = {
"name": "python-pyyaml",
"versions": ["1", "2"],
"group": {
"is_a_package": True,
"value": 42
}
}
serialized = yaml.dump(data, default_flow_style=False)
print(serialized)
with open("/tmp/data.yml", "w") as f:
f.write(serialized)

View File

@@ -0,0 +1,2 @@
from service_identity import VerificationError # noqa
from service_identity.pyopenssl import verify_hostname # noqa

View File

@@ -0,0 +1,6 @@
import subprocess32
output = subprocess32.check_output(["ls", "-l", "/dev/null"])
print(output)
assert("/dev/null" in output)
assert("No such" not in output)

View File

@@ -0,0 +1,16 @@
from twisted.internet import reactor
import treq
def done(response):
print(response.code)
reactor.stop()
def err(fail):
print(fail.value)
reactor.stop()
treq.get("https://localhost").addCallback(done).addErrback(err)
reactor.run()

View File

@@ -0,0 +1,9 @@
from twisted.internet import protocol, reactor, endpoints
class F(protocol.Factory):
pass
endpoints.serverFromString(reactor, "tcp:1234").listen(F())
reactor.run()

View File

@@ -0,0 +1,3 @@
import txaio
txaio.use_asyncio()
f0 = txaio.create_future()

View File

@@ -0,0 +1,3 @@
import txaio
txaio.use_twisted()
f0 = txaio.create_future()

View File

@@ -0,0 +1 @@
import txtorcon # noqa

View File

@@ -0,0 +1,10 @@
import ubjson
with open("/tmp/data.json", "rb") as f:
serialized = f.read()
data = ubjson.loadb(serialized)
print(data)
assert(data["name"] == "python-ubjson")
assert(data["versions"] == ["1", "2"])
assert(data["group"]["is_a_package"] is True)
assert(data["group"]["value"] == 42)

View File

@@ -0,0 +1,14 @@
import ubjson
data = {
"name": "python-ubjson",
"versions": ["1", "2"],
"group": {
"is_a_package": True,
"value": 42
}
}
serialized = ubjson.dumpb(data)
print(serialized)
with open("/tmp/data.json", "wb") as f:
f.write(serialized)

View File

@@ -68,3 +68,59 @@ class TestPython3(TestPythonBase):
self.math_floor_test()
self.libc_time_test()
self.zlib_test()
class TestPythonPackageBase(TestPythonBase):
"""Common class to test a python package.
Build an image containing the scripts listed in sample_scripts, start the
emulator, login to it and for each sample script in the image run the python
interpreter passing the name of the script and check the status code is 0.
Each test case that inherits from this class must have:
__test__ = True - to let nose2 know that it is a test case
config - defconfig fragment with the packages to run the test
It also can have:
sample_scripts - list of scripts to add to the image and run on the target
timeout - timeout to the script to run when the default from the
test infra is not enough
When custom commands need be issued on the target the method
run_sample_scripts can be overridden.
"""
__test__ = False
config_sample_scripts = \
"""
BR2_ROOTFS_POST_BUILD_SCRIPT="{}"
BR2_ROOTFS_POST_SCRIPT_ARGS="{}"
""".format(infra.filepath("tests/package/copy-sample-script-to-target.sh"),
"{sample_scripts}")
sample_scripts = None
timeout = -1
def __init__(self, names):
"""Add the scripts to the target in build time."""
super(TestPythonPackageBase, self).__init__(names)
if self.sample_scripts:
scripts = [infra.filepath(s) for s in self.sample_scripts]
self.config += self.config_sample_scripts.format(sample_scripts=" ".join(scripts))
def check_sample_scripts_exist(self):
"""Check the scripts were really added to the image."""
scripts = [os.path.basename(s) for s in self.sample_scripts]
cmd = "md5sum " + " ".join(scripts)
_, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 0)
def run_sample_scripts(self):
"""Run each script previously added to the image."""
for script in self.sample_scripts:
cmd = self.interpreter + " " + os.path.basename(script)
_, exit_code = self.emulator.run(cmd, timeout=self.timeout)
self.assertEqual(exit_code, 0)
def test_run(self):
"""Test a python package."""
self.login()
self.check_sample_scripts_exist()
self.run_sample_scripts()

View File

@@ -0,0 +1,45 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonArgh(TestPythonPackageBase):
config = TestPythonPackageBase.config
sample_scripts = ["tests/package/sample_python_argh.py"]
def run_sample_scripts(self):
cmd = self.interpreter + " sample_python_argh.py -h"
output, exit_code = self.emulator.run(cmd)
self.assertIn("usage:", output[0])
self.assertEqual(exit_code, 0)
cmd = self.interpreter + " sample_python_argh.py 123"
output, exit_code = self.emulator.run(cmd)
self.assertEqual(output[0], "123, False")
self.assertEqual(exit_code, 0)
cmd = self.interpreter + " sample_python_argh.py --bar 456"
output, exit_code = self.emulator.run(cmd)
self.assertEqual(output[0], "456, True")
self.assertEqual(exit_code, 0)
cmd = self.interpreter + " sample_python_argh.py"
output, exit_code = self.emulator.run(cmd)
self.assertIn("usage:", output[0])
self.assertEqual(exit_code, 2)
class TestPythonPy2Argh(TestPythonArgh):
__test__ = True
config = TestPythonArgh.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_ARGH=y
"""
class TestPythonPy3Argh(TestPythonArgh):
__test__ = True
config = TestPythonArgh.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_ARGH=y
"""

View File

@@ -0,0 +1,21 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Attrs(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_ATTRS=y
"""
sample_scripts = ["tests/package/sample_python_attrs.py"]
class TestPythonPy3Attrs(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_ATTRS=y
"""
sample_scripts = ["tests/package/sample_python_attrs.py"]

View File

@@ -1,32 +1,21 @@
from tests.package.test_python import TestPythonBase
from tests.package.test_python import TestPythonPackageBase
class TestPythonAutobahn(TestPythonBase):
def import_test(self):
cmd = self.interpreter + " -c 'import autobahn.wamp'"
_, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 0)
class TestPythonPy2Autobahn(TestPythonAutobahn):
config = TestPythonBase.config + \
class TestPythonPy2Autobahn(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_AUTOBAHN=y
"""
def test_run(self):
self.login()
self.import_test()
sample_scripts = ["tests/package/sample_python_autobahn.py"]
class TestPythonPy3Autobahn(TestPythonAutobahn):
config = TestPythonBase.config + \
class TestPythonPy3Autobahn(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_AUTOBAHN=y
"""
def test_run(self):
self.login()
self.import_test()
sample_scripts = ["tests/package/sample_python_autobahn.py"]

View File

@@ -0,0 +1,23 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Automat(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_AUTOMAT=y
"""
sample_scripts = ["tests/package/sample_python_automat.py"]
timeout = 30
class TestPythonPy3Automat(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_AUTOMAT=y
"""
sample_scripts = ["tests/package/sample_python_automat.py"]
timeout = 30

View File

@@ -0,0 +1,21 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Bitstring(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_BITSTRING=y
"""
sample_scripts = ["tests/package/sample_python_bitstring.py"]
class TestPythonPy3Bitstring(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_BITSTRING=y
"""
sample_scripts = ["tests/package/sample_python_bitstring.py"]

View File

@@ -0,0 +1,23 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Cbor(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_CBOR=y
"""
sample_scripts = ["tests/package/sample_python_cbor_enc.py",
"tests/package/sample_python_cbor_dec.py"]
class TestPythonPy3Cbor(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_CBOR=y
"""
sample_scripts = ["tests/package/sample_python_cbor_enc.py",
"tests/package/sample_python_cbor_dec.py"]

View File

@@ -0,0 +1,44 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonClick(TestPythonPackageBase):
sample_scripts = ["tests/package/sample_python_click.py"]
def run_sample_scripts(self):
cmd = self.interpreter + " sample_python_click.py --help"
output, exit_code = self.emulator.run(cmd)
self.assertIn("Usage:", output[0])
self.assertEqual(exit_code, 0)
cmd = self.interpreter + " sample_python_click.py 123"
output, exit_code = self.emulator.run(cmd)
self.assertEqual(output[0], "123, False")
self.assertEqual(exit_code, 0)
cmd = self.interpreter + " sample_python_click.py --bar 456"
output, exit_code = self.emulator.run(cmd)
self.assertEqual(output[0], "456, True")
self.assertEqual(exit_code, 0)
cmd = self.interpreter + " sample_python_click.py"
output, exit_code = self.emulator.run(cmd)
self.assertIn("Usage:", output[0])
self.assertEqual(exit_code, 2)
class TestPythonPy2Click(TestPythonClick):
__test__ = True
config = TestPythonClick.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_CLICK=y
"""
class TestPythonPy3Click(TestPythonClick):
__test__ = True
config = TestPythonClick.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_CLICK=y
"""

View File

@@ -0,0 +1,21 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Constantly(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_CONSTANTLY=y
"""
sample_scripts = ["tests/package/sample_python_constantly.py"]
class TestPythonPy3Constantly(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_CONSTANTLY=y
"""
sample_scripts = ["tests/package/sample_python_constantly.py"]

View File

@@ -0,0 +1,14 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy3Crossbar(TestPythonPackageBase):
__test__ = True
# use haveged to generate enough entropy so crossbar -> pynacl -> libsodium don't hang waiting for /dev/random
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_CROSSBAR=y
BR2_PACKAGE_HAVEGED=y
"""
sample_scripts = ["tests/package/sample_python_crossbar.py"]
timeout = 60

View File

@@ -1,34 +1,23 @@
from tests.package.test_python import TestPythonBase
from tests.package.test_python import TestPythonPackageBase
class TestPythonCryptography(TestPythonBase):
def fernet_test(self, timeout=-1):
cmd = self.interpreter + " -c 'from cryptography.fernet import Fernet;"
cmd += "key = Fernet.generate_key();"
cmd += "f = Fernet(key)'"
_, exit_code = self.emulator.run(cmd, timeout)
self.assertEqual(exit_code, 0)
class TestPythonPy2Cryptography(TestPythonCryptography):
config = TestPythonBase.config + \
class TestPythonPy2Cryptography(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
"""
def test_run(self):
self.login()
self.fernet_test(40)
sample_scripts = ["tests/package/sample_python_cryptography.py"]
timeout = 40
class TestPythonPy3Cryptography(TestPythonCryptography):
config = TestPythonBase.config + \
class TestPythonPy3Cryptography(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
"""
def test_run(self):
self.login()
self.fernet_test(40)
sample_scripts = ["tests/package/sample_python_cryptography.py"]
timeout = 40

View File

@@ -1,34 +1,23 @@
from tests.package.test_python import TestPythonBase
from tests.package.test_python import TestPythonPackageBase
class TestPythonIncremental(TestPythonBase):
def str_test(self):
cmd = self.interpreter + " -c 'import incremental;"
cmd += "v = incremental.Version(\"package\", 1, 2, 3, release_candidate=4);"
cmd += "assert(str(v) == \"[package, version 1.2.3rc4]\")'"
_, exit_code = self.emulator.run(cmd, timeout=30)
self.assertEqual(exit_code, 0)
class TestPythonPy2Incremental(TestPythonIncremental):
config = TestPythonBase.config + \
class TestPythonPy2Incremental(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_INCREMENTAL=y
"""
def test_run(self):
self.login()
self.str_test()
sample_scripts = ["tests/package/sample_python_incremental.py"]
timeout = 30
class TestPythonPy3Incremental(TestPythonIncremental):
config = TestPythonBase.config + \
class TestPythonPy3Incremental(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_INCREMENTAL=y
"""
def test_run(self):
self.login()
self.str_test()
sample_scripts = ["tests/package/sample_python_incremental.py"]
timeout = 30

View File

@@ -0,0 +1,23 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Passlib(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_PASSLIB=y
"""
sample_scripts = ["tests/package/sample_python_passlib.py"]
timeout = 30
class TestPythonPy3Passlib(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_PASSLIB=y
"""
sample_scripts = ["tests/package/sample_python_passlib.py"]
timeout = 30

View File

@@ -0,0 +1,21 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Pexpect(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_PEXPECT=y
"""
sample_scripts = ["tests/package/sample_python_pexpect.py"]
class TestPythonPy3Pexpect(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_PEXPECT=y
"""
sample_scripts = ["tests/package/sample_python_pexpect.py"]

View File

@@ -0,0 +1,27 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Pynacl(TestPythonPackageBase):
__test__ = True
# use haveged to generate enough entropy so pynacl -> libsodium don't hang waiting for /dev/random
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_PYNACL=y
BR2_PACKAGE_HAVEGED=y
"""
sample_scripts = ["tests/package/sample_python_pynacl.py"]
timeout = 10
class TestPythonPy3Pynacl(TestPythonPackageBase):
__test__ = True
# use haveged to generate enough entropy so pynacl -> libsodium don't hang waiting for /dev/random
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_PYNACL=y
BR2_PACKAGE_HAVEGED=y
"""
sample_scripts = ["tests/package/sample_python_pynacl.py"]
timeout = 10

View File

@@ -0,0 +1,23 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Pyyaml(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_PYYAML=y
"""
sample_scripts = ["tests/package/sample_python_pyyaml_enc.py",
"tests/package/sample_python_pyyaml_dec.py"]
class TestPythonPy3Pyyaml(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_PYYAML=y
"""
sample_scripts = ["tests/package/sample_python_pyyaml_enc.py",
"tests/package/sample_python_pyyaml_dec.py"]

View File

@@ -0,0 +1,23 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2ServiceIdentity(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_SERVICE_IDENTITY=y
"""
sample_scripts = ["tests/package/sample_python_service_identity.py"]
timeout = 30
class TestPythonPy3ServiceIdentity(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_SERVICE_IDENTITY=y
"""
sample_scripts = ["tests/package/sample_python_service_identity.py"]
timeout = 30

View File

@@ -0,0 +1,11 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Subprocess32(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_SUBPROCESS32=y
"""
sample_scripts = ["tests/package/sample_python_subprocess32.py"]

View File

@@ -0,0 +1,29 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonTreq(TestPythonPackageBase):
sample_scripts = ["tests/package/sample_python_treq.py"]
def run_sample_scripts(self):
cmd = self.interpreter + " sample_python_treq.py"
output, exit_code = self.emulator.run(cmd, timeout=20)
self.assertIn("Connection refused", output[0])
self.assertEqual(exit_code, 0)
class TestPythonPy2Treq(TestPythonTreq):
__test__ = True
config = TestPythonTreq.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_TREQ=y
"""
class TestPythonPy3Treq(TestPythonTreq):
__test__ = True
config = TestPythonTreq.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_TREQ=y
"""

View File

@@ -1,25 +1,16 @@
from tests.package.test_python import TestPythonBase
TEST_SCRIPT = """
from twisted.internet import protocol, reactor, endpoints
class F(protocol.Factory):
pass
endpoints.serverFromString(reactor, "tcp:1234").listen(F())
reactor.run()
"""
from tests.package.test_python import TestPythonPackageBase
class TestPythonTwisted(TestPythonBase):
def import_test(self):
cmd = "printf '{}' > test.py".format(TEST_SCRIPT)
_, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 0)
class TestPythonTwisted(TestPythonPackageBase):
config = TestPythonPackageBase.config
sample_scripts = ["tests/package/sample_python_twisted.py"]
def run_sample_scripts(self):
cmd = "netstat -ltn 2>/dev/null | grep 0.0.0.0:1234"
_, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 1)
cmd = self.interpreter + " test.py &"
cmd = self.interpreter + " sample_python_twisted.py &"
# give some time to setup the server
cmd += "sleep 30"
_, exit_code = self.emulator.run(cmd, timeout=35)
@@ -31,24 +22,18 @@ class TestPythonTwisted(TestPythonBase):
class TestPythonPy2Twisted(TestPythonTwisted):
config = TestPythonBase.config + \
__test__ = True
config = TestPythonTwisted.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_TWISTED=y
"""
def test_run(self):
self.login()
self.import_test()
class TestPythonPy3Twisted(TestPythonTwisted):
config = TestPythonBase.config + \
__test__ = True
config = TestPythonTwisted.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_TWISTED=y
"""
def test_run(self):
self.login()
self.import_test()

View File

@@ -1,34 +1,22 @@
from tests.package.test_python import TestPythonBase
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Txaio(TestPythonBase):
config = TestPythonBase.config + \
class TestPythonPy2Txaio(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_TXAIO=y
BR2_PACKAGE_PYTHON_TWISTED=y
"""
def test_run(self):
self.login()
cmd = self.interpreter + " -c 'import txaio;"
cmd += "txaio.use_twisted();"
cmd += "f0 = txaio.create_future()'"
_, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 0)
sample_scripts = ["tests/package/sample_python_txaio_twisted.py"]
class TestPythonPy3Txaio(TestPythonBase):
config = TestPythonBase.config + \
class TestPythonPy3Txaio(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_TXAIO=y
"""
def test_run(self):
self.login()
cmd = self.interpreter + " -c 'import txaio;"
cmd += "txaio.use_asyncio();"
cmd += "f0 = txaio.create_future()'"
_, exit_code = self.emulator.run(cmd)
self.assertEqual(exit_code, 0)
sample_scripts = ["tests/package/sample_python_txaio_asyncio.py"]

View File

@@ -1,32 +1,23 @@
from tests.package.test_python import TestPythonBase
from tests.package.test_python import TestPythonPackageBase
class TestPythonTxtorcon(TestPythonBase):
def import_test(self):
cmd = self.interpreter + " -c 'import txtorcon'"
_, exit_code = self.emulator.run(cmd, timeout=30)
self.assertEqual(exit_code, 0)
class TestPythonPy2Txtorcon(TestPythonTxtorcon):
config = TestPythonBase.config + \
class TestPythonPy2Txtorcon(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_TXTORCON=y
"""
def test_run(self):
self.login()
self.import_test()
sample_scripts = ["tests/package/sample_python_txtorcon.py"]
timeout = 30
class TestPythonPy3Txtorcon(TestPythonTxtorcon):
config = TestPythonBase.config + \
class TestPythonPy3Txtorcon(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_TXTORCON=y
"""
def test_run(self):
self.login()
self.import_test()
sample_scripts = ["tests/package/sample_python_txtorcon.py"]
timeout = 30

View File

@@ -0,0 +1,23 @@
from tests.package.test_python import TestPythonPackageBase
class TestPythonPy2Ubjson(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON=y
BR2_PACKAGE_PYTHON_UBJSON=y
"""
sample_scripts = ["tests/package/sample_python_ubjson_enc.py",
"tests/package/sample_python_ubjson_dec.py"]
class TestPythonPy3Ubjson(TestPythonPackageBase):
__test__ = True
config = TestPythonPackageBase.config + \
"""
BR2_PACKAGE_PYTHON3=y
BR2_PACKAGE_PYTHON_UBJSON=y
"""
sample_scripts = ["tests/package/sample_python_ubjson_enc.py",
"tests/package/sample_python_ubjson_dec.py"]

View File

@@ -57,25 +57,25 @@ class TestRustBase(infra.basetest.BRTest):
class TestRustBin(TestRustBase):
config = \
"""
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
BR2_SYSTEM_DHCP="eth0"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.3"
BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_CARGO=y
BR2_PACKAGE_HOST_RUSTC=y
"""
"""
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
BR2_SYSTEM_DHCP="eth0"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.3"
BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_CARGO=y
BR2_PACKAGE_HOST_RUSTC=y
"""
def test_run(self):
self.build_test_prog()
@@ -86,26 +86,26 @@ class TestRustBin(TestRustBase):
class TestRust(TestRustBase):
config = \
"""
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
BR2_SYSTEM_DHCP="eth0"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.3"
BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_CARGO=y
BR2_PACKAGE_HOST_RUSTC=y
BR2_PACKAGE_HOST_RUST=y
"""
"""
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
BR2_SYSTEM_DHCP="eth0"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.11.3"
BR2_LINUX_KERNEL_DEFCONFIG="vexpress"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9"
BR2_TARGET_ROOTFS_CPIO=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_PACKAGE_HOST_CARGO=y
BR2_PACKAGE_HOST_RUSTC=y
BR2_PACKAGE_HOST_RUST=y
"""
def test_run(self):
self.build_test_prog()