Skip to content

Commit 6017125

Browse files
author
Bogdan Marinescu
committed
Merge branch 'master' of github.com:mbedmicro/mbed
2 parents 3082f90 + ab2433c commit 6017125

File tree

7 files changed

+56
-33
lines changed

7 files changed

+56
-33
lines changed

libraries/tests/rtos/mbed/mutex/main.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ DigitalOut led(LED1);
1616

1717
volatile int change_counter = 0;
1818
volatile bool changing_counter = false;
19+
volatile bool mutex_defect = false;
1920

2021
bool manipulate_protected_zone(const int thread_delay) {
2122
bool result = true;
2223

2324
stdio_mutex.lock(); // LOCK
2425
if (changing_counter == true) {
25-
print_char('e'); // if changing_counter is true access is not exclusively
26+
// 'e' stands for error. If changing_counter is true access is not exclusively
27+
print_char('e');
2628
result = false;
27-
notify_completion(false);
28-
exit(1);
29+
mutex_defect = true;
2930
}
3031
changing_counter = true;
3132

@@ -53,17 +54,19 @@ int main() {
5354
const int t3_delay = THREAD_DELAY * 3;
5455
Thread t2(test_thread, (void *)t2_delay);
5556
Thread t3(test_thread, (void *)t3_delay);
56-
bool result = true;
5757

5858
while (true) {
5959
// Thread 1 action
6060
Thread::wait(t1_delay);
6161
manipulate_protected_zone(t1_delay);
62-
if (change_counter >= SIGNALS_TO_EMIT) {
62+
if (change_counter >= SIGNALS_TO_EMIT or mutex_defect == true) {
63+
t2.terminate();
64+
t3.terminate();
6365
break;
6466
}
6567
}
6668

67-
notify_completion(result);
69+
fflush(stdout);
70+
notify_completion(!mutex_defect);
6871
return 0;
6972
}

libraries/tests/rtos/mbed/semaphore/main.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "test_env.h"
33
#include "rtos.h"
44

5-
#define THREAD_DELAY 100
5+
#define THREAD_DELAY 75
66
#define SEMAPHORE_SLOTS 2
77
#define SEM_CHANGES 100
88

@@ -16,6 +16,7 @@ Semaphore two_slots(SEMAPHORE_SLOTS);
1616

1717
volatile int change_counter = 0;
1818
volatile int sem_counter = 0;
19+
volatile bool sem_defect = false;
1920

2021
void test_thread(void const *delay) {
2122
const int thread_delay = int(delay);
@@ -26,8 +27,7 @@ void test_thread(void const *delay) {
2627
const char msg = sem_lock_failed ? 'e' : sem_counter + '0';
2728
print_char(msg);
2829
if (sem_lock_failed) {
29-
notify_completion(false);
30-
exit(1);
30+
sem_defect = true;
3131
}
3232
Thread::wait(thread_delay);
3333
print_char('.');
@@ -46,10 +46,15 @@ int main (void) {
4646
Thread t3(test_thread, (void *)t3_delay);
4747

4848
while (true) {
49-
if (change_counter >= SEM_CHANGES) {
50-
notify_completion(true);
49+
if (change_counter >= SEM_CHANGES or sem_defect == true) {
50+
t1.terminate();
51+
t2.terminate();
52+
t3.terminate();
5153
break;
5254
}
5355
}
56+
57+
fflush(stdout);
58+
notify_completion(!sem_defect);
5459
return 0;
5560
}

workspace_tools/build_api.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@
1515
limitations under the License.
1616
"""
1717

18-
import tempfile
1918
import re
20-
from os.path import join, exists, basename
21-
from shutil import rmtree
19+
import tempfile
20+
2221
from types import ListType
22+
from shutil import rmtree
23+
from os.path import join, exists, basename
2324

2425
from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext
25-
from workspace_tools.toolchains import TOOLCHAIN_CLASSES
2626
from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON
27-
from workspace_tools.libraries import Library
2827
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
28+
from workspace_tools.libraries import Library
29+
from workspace_tools.toolchains import TOOLCHAIN_CLASSES
2930

3031

3132
def build_project(src_path, build_path, target, toolchain_name,

workspace_tools/host_tests/hello_auto.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,27 @@ class HelloTest(DefaultTest):
2222
HELLO_WORLD = "Hello World\n"
2323

2424
def run(self):
25-
c = self.mbed.serial_read(len(self.HELLO_WORLD))
25+
c = self.mbed.serial_read(1)
26+
if c is None:
27+
self.print_result("ioerr_serial")
28+
return
29+
data_to_read = len(self.HELLO_WORLD)
30+
read_buffer = ''
31+
if c == '$': # target will printout TargetID e.g.: $$$$1040e649d5c09a09a3f6bc568adef61375c6
32+
#Read additional 39 bytes of TargetID
33+
if self.mbed.serial_read(39) is None:
34+
self.print_result("ioerr_serial")
35+
return
36+
else:
37+
data_to_read -= 1
38+
read_buffer += c
39+
c = self.mbed.serial_read(data_to_read)
40+
read_buffer += c
2641
if c is None:
2742
self.print_result("ioerr_serial")
2843
return
29-
stdout.write(c)
30-
if c == self.HELLO_WORLD: # Hello World received
44+
stdout.write(read_buffer)
45+
if read_buffer == self.HELLO_WORLD: # Hello World received
3146
self.print_result('success')
3247
else:
3348
self.print_result('failure')

workspace_tools/host_tests/stdio_auto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from sys import stdout
2323

2424
class StdioTest(DefaultTest):
25-
PATTERN_INT_VALUE = "^Your value was: (-?\d+)"
25+
PATTERN_INT_VALUE = "Your value was: (-?\d+)"
2626
re_detect_int_value = re.compile(PATTERN_INT_VALUE)
2727

2828
def run(self):

workspace_tools/host_tests/wait_us_auto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def run(self):
3232
return
3333
if c == '$': # target will printout TargetID e.g.: $$$$1040e649d5c09a09a3f6bc568adef61375c6
3434
#Read additional 39 bytes of TargetID
35-
if not self.mbed.serial_read(39):
35+
if self.mbed.serial_read(39) is None:
3636
self.print_result("ioerr_serial")
3737
return
3838
c = self.mbed.serial_read(1) # Re-read first 'tick'

workspace_tools/toolchains/__init__.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17-
from os import stat, walk, remove
17+
from os import stat, walk
1818
from os.path import join, splitext, exists, relpath, dirname, basename, split
1919
from shutil import copyfile
2020
from copy import copy
@@ -23,12 +23,10 @@
2323
from time import time
2424

2525
from workspace_tools.utils import run_cmd, mkdir, rel_path, ToolException, split_path
26-
from workspace_tools.patch import patch
2726
from workspace_tools.settings import BUILD_OPTIONS, MBED_ORG_USER
2827

29-
from multiprocessing import Pool, Manager, cpu_count
28+
from multiprocessing import Pool, cpu_count
3029
from time import sleep
31-
from pprint import pprint
3230

3331
import workspace_tools.hooks as hooks
3432
import re
@@ -58,7 +56,7 @@ def print_notify_verbose(event):
5856
elif event['type'] == 'cc':
5957
event['severity'] = event['severity'].title()
6058
event['file'] = basename(event['file'])
61-
event['mcu_name'] = "None"
59+
event['mcu_name'] = "None"
6260
event['toolchain'] = "None"
6361
event['target_name'] = event['target_name'].upper() if event['target_name'] else "Unknown"
6462
event['toolchain_name'] = event['toolchain_name'].upper() if event['toolchain_name'] else "Unknown"
@@ -153,7 +151,7 @@ def win_to_unix(self):
153151
self.linker_script = self.linker_script.replace('\\', '/')
154152

155153
def __str__(self):
156-
s = []
154+
s = []
157155

158156
for (label, resources) in (
159157
('Include Directories', self.inc_dirs),
@@ -242,7 +240,7 @@ def __init__(self, target, options=None, notify=None, macros=None):
242240

243241
self.mp_pool = None
244242

245-
def __exit__():
243+
def __exit__(self):
246244
if self.mp_pool is not None:
247245
self.mp_pool.terminate()
248246

@@ -366,7 +364,7 @@ def scan_resources(self, path):
366364
elif ext == '.o':
367365
resources.objects.append(file_path)
368366

369-
elif ext == self.LIBRARY_EXT:
367+
elif ext == self.LIBRARY_EXT:
370368
resources.libraries.append(file_path)
371369
resources.lib_dirs.add(root)
372370

@@ -443,9 +441,9 @@ def compile_sources(self, resources, build_path, inc_dirs=None):
443441
if inc_dirs is not None:
444442
inc_paths.extend(inc_dirs)
445443

446-
objects=[]
447-
queue=[]
448-
prev_dir=None
444+
objects = []
445+
queue = []
446+
prev_dir = None
449447

450448
# The dependency checking for C/C++ is delegated to the compiler
451449
base_path = resources.base_path
@@ -692,7 +690,8 @@ def var(self, key, value):
692690

693691

694692
from workspace_tools.toolchains.arm import ARM_STD, ARM_MICRO
695-
from workspace_tools.toolchains.gcc import GCC_ARM, GCC_CS, GCC_CR, GCC_CW_EWL, GCC_CW_NEWLIB
693+
from workspace_tools.toolchains.gcc import GCC_ARM, GCC_CS, GCC_CR
694+
from workspace_tools.toolchains.gcc import GCC_CW_EWL, GCC_CW_NEWLIB
696695
from workspace_tools.toolchains.iar import IAR
697696

698697
TOOLCHAIN_CLASSES = {

0 commit comments

Comments
 (0)