1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 23:48:12 +00:00

tests: move to /tests to avoid freezing

This commit is contained in:
Pavol Rusnak 2016-11-06 17:04:25 +01:00
parent c95ed063db
commit 33b5436dcc
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
28 changed files with 59 additions and 125 deletions

View File

@ -59,7 +59,7 @@ clean_cross: ## clean mpy-cross build
$(MAKE) -C vendor/micropython/mpy-cross clean $(MAKE) -C vendor/micropython/mpy-cross clean
test: ## run unit tests test: ## run unit tests
cd src/tests ; ./run_tests.sh cd tests ; ./run_tests.sh
flash: ## flash firmware using st-flash flash: ## flash firmware using st-flash
st-flash write $(STMHAL_BUILD_DIR)/firmware0.bin 0x8000000 st-flash write $(STMHAL_BUILD_DIR)/firmware0.bin 0x8000000

View File

@ -12,6 +12,7 @@ else:
def _load(): def _load():
global _mock
try: try:
with open(_file, 'rb') as f: with open(_file, 'rb') as f:
while True: while True:
@ -26,6 +27,7 @@ def _load():
def _save(): def _save():
global _mock
with open(_file, 'wb') as f: with open(_file, 'wb') as f:
for k, v in _mock.items(): for k, v in _mock.items():
f.write(ustruct.pack('<HH', k, len(v))) f.write(ustruct.pack('<HH', k, len(v)))
@ -35,13 +37,16 @@ _load()
def get(app_id, key, default=None): def get(app_id, key, default=None):
global _mock
return _mock.get((app_id << 8) | key, default) return _mock.get((app_id << 8) | key, default)
def set(app_id, key, value): def set(app_id, key, value):
global _mock
_mock[(app_id << 8) | key] = value _mock[(app_id << 8) | key] = value
_save() _save()
def wipe(): def wipe():
global _mock
_mock = {} _mock = {}
_save() _save()

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
find ../../mocks -name '*.py' | sort | while read module; do find ../mocks -name '*.py' | sort | while read module; do
module=$(echo $module | sed 's:^\.\./\.\./mocks/::') module=$(echo $module | sed 's:^\.\./mocks/::')
base=$(basename $module) base=$(basename $module)
# skip __init__.py # skip __init__.py
if [[ $base == "__init__.py" ]]; then if [[ $base == "__init__.py" ]]; then

8
tests/common.py Normal file
View File

@ -0,0 +1,8 @@
import sys
sys.path.append('../src')
sys.path.append('../src/lib')
import unittest
from ubinascii import hexlify, unhexlify

View File

@ -8,7 +8,7 @@ else
fi fi
for i in $list; do for i in $list; do
echo echo
if ../../vendor/micropython/unix/micropython $i; then if ../vendor/micropython/unix/micropython $i; then
results+=("OK $i") results+=("OK $i")
else else
results+=("FAIL $i") results+=("FAIL $i")

View File

@ -1,10 +1,8 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib') from trezor.crypto import random
import unittest
from trezor import config from trezor import config
from trezor.crypto import random
class TestConfig(unittest.TestCase): class TestConfig(unittest.TestCase):

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto.aes import * from trezor.crypto.aes import *

View File

@ -1,11 +1,8 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib') from trezor.crypto.hashlib import ripemd160
import unittest
from ubinascii import unhexlify
from trezor.crypto import base58 from trezor.crypto import base58
from trezor.crypto.hashlib import ripemd160
digestfunc_graphene = lambda x: ripemd160(x).digest()[:4] digestfunc_graphene = lambda x: ripemd160(x).digest()[:4]

View File

@ -1,14 +1,9 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import bip32 from trezor.crypto import bip32
SECP256K1_NAME = 'secp256k1' SECP256K1_NAME = 'secp256k1'
class TestCryptoBip32(unittest.TestCase): class TestCryptoBip32(unittest.TestCase):
def test_from_seed_invalid(self): def test_from_seed_invalid(self):

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import bip39 from trezor.crypto import bip39

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto.curve import curve25519 from trezor.crypto.curve import curve25519

View File

@ -1,11 +1,8 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib') from trezor.crypto import random
import unittest
from ubinascii import unhexlify
from trezor.crypto.curve import ed25519 from trezor.crypto.curve import ed25519
from trezor.crypto import random
class TestCryptoEd25519(unittest.TestCase): class TestCryptoEd25519(unittest.TestCase):

View File

@ -1,11 +1,8 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib') from trezor.crypto import random
import unittest
from ubinascii import hexlify, unhexlify
from trezor.crypto.curve import nist256p1 from trezor.crypto.curve import nist256p1
from trezor.crypto import random
class TestCryptoNist256p1(unittest.TestCase): class TestCryptoNist256p1(unittest.TestCase):

View File

@ -1,11 +1,8 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib') from trezor.crypto import random
import unittest
from ubinascii import hexlify, unhexlify
from trezor.crypto.curve import secp256k1 from trezor.crypto.curve import secp256k1
from trezor.crypto import random
class TestCryptoSecp256k1(unittest.TestCase): class TestCryptoSecp256k1(unittest.TestCase):

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import hashlib from trezor.crypto import hashlib

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import hashlib from trezor.crypto import hashlib

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import hashlib from trezor.crypto import hashlib

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import hashlib from trezor.crypto import hashlib

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import hashlib from trezor.crypto import hashlib

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import hashlib from trezor.crypto import hashlib

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import hashlib from trezor.crypto import hashlib

View File

@ -1,10 +1,7 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import hashlib from trezor.crypto import hashlib
from trezor.crypto import hmac from trezor.crypto import hmac
class TestCryptoHmac(unittest.TestCase): class TestCryptoHmac(unittest.TestCase):

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import unhexlify
from trezor.crypto import pbkdf2 from trezor.crypto import pbkdf2

View File

@ -1,8 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from ubinascii import hexlify
from trezor.crypto import random from trezor.crypto import random

View File

@ -1,7 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from trezor import debug from trezor import debug

View File

@ -1,7 +1,4 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
from trezor import utils from trezor import utils

View File

@ -1,14 +1,12 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
import ustruct import ustruct
import ubinascii import ubinascii
from trezor.wire import wire_codec
from trezor.utils import chunks
from trezor.crypto import random from trezor.crypto import random
from trezor.utils import chunks
from trezor.wire import wire_codec
class TestWireCodec(unittest.TestCase): class TestWireCodec(unittest.TestCase):
# pylint: disable=C0301 # pylint: disable=C0301

View File

@ -1,13 +1,12 @@
import sys from common import *
sys.path.append('..')
sys.path.append('../lib')
import unittest
import ustruct import ustruct
import ubinascii
from trezor.crypto import random
from trezor.utils import chunks
from trezor.wire import wire_codec_v1 from trezor.wire import wire_codec_v1
from trezor.utils import chunks
from trezor.crypto import random
class TestWireCodecV1(unittest.TestCase): class TestWireCodecV1(unittest.TestCase):
# pylint: disable=C0301 # pylint: disable=C0301