1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +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
test: ## run unit tests
cd src/tests ; ./run_tests.sh
cd tests ; ./run_tests.sh
flash: ## flash firmware using st-flash
st-flash write $(STMHAL_BUILD_DIR)/firmware0.bin 0x8000000

View File

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

View File

@ -1,6 +1,6 @@
#!/bin/bash
find ../../mocks -name '*.py' | sort | while read module; do
module=$(echo $module | sed 's:^\.\./\.\./mocks/::')
find ../mocks -name '*.py' | sort | while read module; do
module=$(echo $module | sed 's:^\.\./mocks/::')
base=$(basename $module)
# skip __init__.py
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
for i in $list; do
echo
if ../../vendor/micropython/unix/micropython $i; then
if ../vendor/micropython/unix/micropython $i; then
results+=("OK $i")
else
results+=("FAIL $i")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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