Skip to content

Commit 5027704

Browse files
authored
Merge branch 'master' into raven
2 parents 40efb1d + ca62922 commit 5027704

File tree

273 files changed

+70771
-96122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

273 files changed

+70771
-96122
lines changed

.astyleignore

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
BUILD
2-
cmsis
3-
features/cryptocell
4-
features/mbedtls
5-
features/lwipstack/lwip
6-
features/lwipstack/lwip-sys
7-
rtos/TARGET_CORTEX/rtx4
8-
features/storage/filesystem/littlefs/littlefs/
9-
features/storage/filesystem/fat/ChaN
10-
features/storage/FEATURE_STORAGE
11-
features/frameworks
12-
features/FEATURE_BLE
13-
features/unsupported/
14-
features/netsocket/emac-drivers
15-
hal/storage_abstraction
16-
TESTS/mbed_hal/trng/pithy
17-
features/nanostack/coap-service
18-
features/nanostack/sal-stack-nanostack
19-
features/nanostack/targets
20-
rtos/TARGET_CORTEX/rtx5
21-
TESTS/mbed_hal/trng/pithy
22-
targets
23-
components/802.15.4_RF
24-
components/wifi
25-
components/TARGET_PSA/TARGET_TFM
26-
tools
27-
components/TARGET_PSA/TESTS
28-
components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/tfm_impl
29-
components/TARGET_PSA/services/attestation/qcbor
30-
components/TARGET_PSA/services/attestation/attestation.h
1+
^BUILD
2+
^cmsis
3+
^components/802.15.4_RF
4+
^components/TARGET_PSA/services/attestation/attestation.h
5+
^components/TARGET_PSA/services/attestation/COMPONENT_PSA_SRV_IMPL/tfm_impl
6+
^components/TARGET_PSA/services/attestation/qcbor
7+
^components/TARGET_PSA/TARGET_TFM
8+
^components/TARGET_PSA/TESTS
9+
^features/cryptocell
10+
^features/FEATURE_BLE
11+
^features/frameworks
12+
^features/lwipstack/lwip
13+
^features/lwipstack/lwip-sys
14+
^features/mbedtls
15+
^features/nanostack/coap-service
16+
^features/nanostack/sal-stack-nanostack
17+
^features/nanostack/targets
18+
^features/netsocket/emac-drivers
19+
^features/storage/FEATURE_STORAGE
20+
^features/storage/filesystem/fat/ChaN
21+
^features/storage/filesystem/littlefs/littlefs/
22+
^features/unsupported/
23+
^hal/storage_abstraction
24+
^rtos/TARGET_CORTEX/rtx4
25+
^rtos/TARGET_CORTEX/rtx5
26+
^targets
27+
^TESTS/mbed_hal/trng/pithy
28+
^TESTS/mbed_hal/trng/pithy
29+
^tools

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ matrix:
183183
- >-
184184
git diff --name-only --diff-filter=d FETCH_HEAD..HEAD \
185185
| ( grep '.\(c\|cpp\|h\|hpp\)$' || true ) \
186-
| ( fgrep -v -f .astyleignore || true ) \
186+
| ( grep -v -f .astyleignore || true ) \
187187
| while read file; do astyle -n --options=.astylerc "${file}"; done
188188
- git diff --exit-code --diff-filter=d --color
189189

TESTS/host_tests/pyusb_msd.py

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
"""
2+
Copyright (c) 2019, Arm Limited and affiliates.
3+
SPDX-License-Identifier: Apache-2.0
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
"""
17+
18+
from mbed_host_tests import BaseHostTest
19+
import time
20+
import psutil
21+
import tempfile
22+
import uuid
23+
import os
24+
import platform
25+
import subprocess
26+
import sys
27+
system_name = platform.system()
28+
if system_name == "Windows":
29+
import wmi
30+
31+
32+
class PyusbMSDTest(BaseHostTest):
33+
"""Host side test for USB MSD class."""
34+
35+
__result = None
36+
MOUNT_WAIT_TIME = 25 # in [s]
37+
initial_disk_list = None
38+
msd_disk = None
39+
serial_number = None
40+
41+
def _callback_device_ready(self, key, value, timestamp):
42+
"""Send a unique USB SN to the device.
43+
DUT uses this SN every time it connects to host as a USB device.
44+
"""
45+
self.serial_number = uuid.uuid4().hex # 32 hex digit string
46+
self.send_kv("serial_number", self.serial_number)
47+
48+
def _callback_check_file_exist(self, key, value, timestamp):
49+
"""Check if file exist.
50+
51+
"""
52+
folder_name, file_name, file_content = value.split(' ')
53+
msd_disk = MSDUtils.disk_path(self.serial_number)
54+
file_path = os.path.join(msd_disk, folder_name, file_name)
55+
try:
56+
file = open(file_path, 'r')
57+
line = file.readline()
58+
file.close()
59+
time.sleep(2) # wait for msd communication done
60+
if line == file_content:
61+
self.send_kv("exist", "0")
62+
return
63+
self.report_error("file content invalid")
64+
except IOError as err:
65+
self.log('{} !!!'.format(err))
66+
self.send_kv("non-exist", "0")
67+
68+
def _callback_delete_files(self, key, value, timestamp):
69+
"""Delete test file.
70+
71+
"""
72+
dir_name, file_name = value.split(' ')
73+
msd_disk = MSDUtils.disk_path(self.serial_number)
74+
try:
75+
os.remove(os.path.join(msd_disk, dir_name, file_name))
76+
except:
77+
self.report_error("delete files")
78+
return
79+
time.sleep(2) # wait for msd communication done
80+
self.report_success()
81+
82+
def _callback_check_if_mounted(self, key, value, timestamp):
83+
"""Check if disk was mounted.
84+
85+
"""
86+
wait_time = self.MOUNT_WAIT_TIME
87+
while wait_time != 0:
88+
msd_disk = MSDUtils.disk_path(self.serial_number)
89+
if msd_disk is not None:
90+
# MSD disk found
91+
time.sleep(2) # wait for msd communication done
92+
self.report_success()
93+
return
94+
wait_time -= 1
95+
time.sleep(1) # wait 1s and try again
96+
self.report_error("mount check")
97+
98+
def _callback_check_if_not_mounted(self, key, value, timestamp):
99+
"""Check if disk was unmouted.
100+
101+
"""
102+
wait_time = self.MOUNT_WAIT_TIME
103+
while wait_time != 0:
104+
msd_disk = MSDUtils.disk_path(self.serial_number)
105+
if msd_disk is None:
106+
#self.msd_disk = None
107+
time.sleep(2) # wait for msd communication done
108+
self.report_success()
109+
return
110+
wait_time -= 1
111+
time.sleep(1) # wait 1s and try again
112+
self.report_error("unmount check")
113+
114+
def _callback_get_mounted_fs_size(self, key, value, timestamp):
115+
"""Record visible filesystem size.
116+
117+
"""
118+
stats = psutil.disk_usage(MSDUtils.disk_path(self.serial_number))
119+
self.send_kv("{}".format(stats.total), "0")
120+
121+
def _callback_unmount(self, key, value, timestamp):
122+
"""Disk unmount.
123+
124+
"""
125+
if MSDUtils.unmount(serial=self.serial_number):
126+
self.report_success()
127+
else:
128+
self.report_error("unmount")
129+
130+
def setup(self):
131+
self.register_callback("get_serial_number", self._callback_device_ready)
132+
self.register_callback('check_if_mounted', self._callback_check_if_mounted)
133+
self.register_callback('check_if_not_mounted', self._callback_check_if_not_mounted)
134+
self.register_callback('get_mounted_fs_size', self._callback_get_mounted_fs_size)
135+
self.register_callback('check_file_exist', self._callback_check_file_exist)
136+
self.register_callback('delete_files', self._callback_delete_files)
137+
self.register_callback('unmount', self._callback_unmount)
138+
139+
def report_success(self):
140+
self.send_kv("passed", "0")
141+
142+
def report_error(self, msg):
143+
self.log('{} failed !!!'.format(msg))
144+
self.send_kv("failed", "0")
145+
146+
def result(self):
147+
return self.__result
148+
149+
def teardown(self):
150+
pass
151+
152+
153+
class MSDUtils(object):
154+
155+
@staticmethod
156+
def disk_path(serial):
157+
system_name = platform.system()
158+
if system_name == "Windows":
159+
return MSDUtils._disk_path_windows(serial)
160+
elif system_name == "Linux":
161+
return MSDUtils._disk_path_linux(serial)
162+
elif system_name == "Darwin":
163+
return MSDUtils._disk_path_mac(serial)
164+
return None
165+
166+
@staticmethod
167+
def unmount(serial):
168+
system_name = platform.system()
169+
if system_name == "Windows":
170+
return MSDUtils._unmount_windows(serial)
171+
elif system_name == "Linux":
172+
return MSDUtils._unmount_linux(serial)
173+
elif system_name == "Darwin":
174+
return MSDUtils._unmount_mac(serial)
175+
return False
176+
177+
@staticmethod
178+
def _disk_path_windows(serial):
179+
serial_decoded = serial.encode("ascii")
180+
c = wmi.WMI()
181+
for physical_disk in c.Win32_DiskDrive():
182+
if serial_decoded == physical_disk.SerialNumber:
183+
for partition in physical_disk.associators("Win32_DiskDriveToDiskPartition"):
184+
for logical_disk in partition.associators("Win32_LogicalDiskToPartition"):
185+
return logical_disk.Caption
186+
return None
187+
188+
@staticmethod
189+
def _disk_path_linux(serial):
190+
output = subprocess.check_output(['lsblk', '-dnoserial,mountpoint']).split('\n')
191+
for line in output:
192+
serial_and_mount_point = line.split()
193+
if len(serial_and_mount_point) == 2:
194+
if serial_and_mount_point[0] == str(serial):
195+
return serial_and_mount_point[1]
196+
return None
197+
198+
@staticmethod
199+
def _disk_path_mac(serial):
200+
# TODO:
201+
# add implementation
202+
return None
203+
204+
@staticmethod
205+
def _unmount_windows(serial):
206+
disk_path = MSDUtils._disk_path_windows(serial)
207+
tmp_file = tempfile.NamedTemporaryFile(suffix='.ps1', delete=False)
208+
try:
209+
# create unmount script
210+
tmp_file.write('$disk_leter=$args[0]\n')
211+
tmp_file.write('$driveEject = New-Object -comObject Shell.Application\n')
212+
tmp_file.write('$driveEject.Namespace(17).ParseName($disk_leter).InvokeVerb("Eject")\n')
213+
# close to allow open by other process
214+
tmp_file.close()
215+
216+
try_count = 10
217+
while try_count:
218+
p = subprocess.Popen(["powershell.exe", tmp_file.name + " " + disk_path], stdout=sys.stdout)
219+
p.communicate()
220+
try_count -= 1
221+
if MSDUtils._disk_path_windows(serial) is None:
222+
return True
223+
time.sleep(1)
224+
finally:
225+
os.remove(tmp_file.name)
226+
227+
return False
228+
229+
@staticmethod
230+
def _unmount_linux(serial):
231+
disk_path = MSDUtils._disk_path_linux(serial)
232+
os.system("umount " + disk_path)
233+
return MSDUtils._disk_path_linux(serial) is None
234+
235+
@staticmethod
236+
def _unmount_mac(serial):
237+
disk_path = MSDUtils._disk_path_mac(serial)
238+
os.system("diskutil unmount " + disk_path)
239+
disks = set(MSDUtils._disks_mac())
240+
return MSDUtils._disk_path_mac(serial) is None

TESTS/mbed-crypto/sanity/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,7 @@ utest::v1::status_t case_teardown_handler(const Case *const source, const size_t
438438

439439
utest::v1::status_t test_setup(const size_t number_of_cases)
440440
{
441-
#ifndef NO_GREENTEA
442441
GREENTEA_SETUP(120, "default_auto");
443-
#endif
444442
return verbose_test_setup_handler(number_of_cases);
445443
}
446444

TESTS/mbed_hal/spm/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ Case cases[] = {
150150

151151
utest::v1::status_t greentea_test_setup(const size_t number_of_cases)
152152
{
153-
#ifndef NO_GREENTEA
154153
GREENTEA_SETUP(20, "default_auto");
155-
#endif
156154
return greentea_test_setup_handler(number_of_cases);
157155
}
158156

TESTS/mbed_hal/stack_size_unification/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* mbed Microcontroller Library
22
* Copyright (c) 2019-2019 ARM Limited
3-
*
3+
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");

TESTS/mbed_hal/stack_size_unification/stack_size_unification.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* mbed Microcontroller Library
22
* Copyright (c) 2019-2019 ARM Limited
3-
*
3+
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");

TESTS/netsocket/dns/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "unity.h"
2727
#include "utest.h"
2828
#include "nsapi_dns.h"
29-
#include "EventQueue.h"
29+
#include "events/EventQueue.h"
3030
#include "dns_tests.h"
3131

3232
using namespace utest::v1;

0 commit comments

Comments
 (0)