Merge branch 'master' of github.com:mbedmicro/mbed

pull/448/head
Bogdan Marinescu 2014-08-15 16:20:11 +01:00
commit 601712595f
7 changed files with 56 additions and 33 deletions

View File

@ -16,16 +16,17 @@ DigitalOut led(LED1);
volatile int change_counter = 0; volatile int change_counter = 0;
volatile bool changing_counter = false; volatile bool changing_counter = false;
volatile bool mutex_defect = false;
bool manipulate_protected_zone(const int thread_delay) { bool manipulate_protected_zone(const int thread_delay) {
bool result = true; bool result = true;
stdio_mutex.lock(); // LOCK stdio_mutex.lock(); // LOCK
if (changing_counter == true) { if (changing_counter == true) {
print_char('e'); // if changing_counter is true access is not exclusively // 'e' stands for error. If changing_counter is true access is not exclusively
print_char('e');
result = false; result = false;
notify_completion(false); mutex_defect = true;
exit(1);
} }
changing_counter = true; changing_counter = true;
@ -53,17 +54,19 @@ int main() {
const int t3_delay = THREAD_DELAY * 3; const int t3_delay = THREAD_DELAY * 3;
Thread t2(test_thread, (void *)t2_delay); Thread t2(test_thread, (void *)t2_delay);
Thread t3(test_thread, (void *)t3_delay); Thread t3(test_thread, (void *)t3_delay);
bool result = true;
while (true) { while (true) {
// Thread 1 action // Thread 1 action
Thread::wait(t1_delay); Thread::wait(t1_delay);
manipulate_protected_zone(t1_delay); manipulate_protected_zone(t1_delay);
if (change_counter >= SIGNALS_TO_EMIT) { if (change_counter >= SIGNALS_TO_EMIT or mutex_defect == true) {
t2.terminate();
t3.terminate();
break; break;
} }
} }
notify_completion(result); fflush(stdout);
notify_completion(!mutex_defect);
return 0; return 0;
} }

View File

@ -2,7 +2,7 @@
#include "test_env.h" #include "test_env.h"
#include "rtos.h" #include "rtos.h"
#define THREAD_DELAY 100 #define THREAD_DELAY 75
#define SEMAPHORE_SLOTS 2 #define SEMAPHORE_SLOTS 2
#define SEM_CHANGES 100 #define SEM_CHANGES 100
@ -16,6 +16,7 @@ Semaphore two_slots(SEMAPHORE_SLOTS);
volatile int change_counter = 0; volatile int change_counter = 0;
volatile int sem_counter = 0; volatile int sem_counter = 0;
volatile bool sem_defect = false;
void test_thread(void const *delay) { void test_thread(void const *delay) {
const int thread_delay = int(delay); const int thread_delay = int(delay);
@ -26,8 +27,7 @@ void test_thread(void const *delay) {
const char msg = sem_lock_failed ? 'e' : sem_counter + '0'; const char msg = sem_lock_failed ? 'e' : sem_counter + '0';
print_char(msg); print_char(msg);
if (sem_lock_failed) { if (sem_lock_failed) {
notify_completion(false); sem_defect = true;
exit(1);
} }
Thread::wait(thread_delay); Thread::wait(thread_delay);
print_char('.'); print_char('.');
@ -46,10 +46,15 @@ int main (void) {
Thread t3(test_thread, (void *)t3_delay); Thread t3(test_thread, (void *)t3_delay);
while (true) { while (true) {
if (change_counter >= SEM_CHANGES) { if (change_counter >= SEM_CHANGES or sem_defect == true) {
notify_completion(true); t1.terminate();
t2.terminate();
t3.terminate();
break; break;
} }
} }
fflush(stdout);
notify_completion(!sem_defect);
return 0; return 0;
} }

View File

@ -15,17 +15,18 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
""" """
import tempfile
import re import re
from os.path import join, exists, basename import tempfile
from shutil import rmtree
from types import ListType from types import ListType
from shutil import rmtree
from os.path import join, exists, basename
from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext
from workspace_tools.toolchains import TOOLCHAIN_CLASSES
from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON
from workspace_tools.libraries import Library
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
from workspace_tools.libraries import Library
from workspace_tools.toolchains import TOOLCHAIN_CLASSES
def build_project(src_path, build_path, target, toolchain_name, def build_project(src_path, build_path, target, toolchain_name,

View File

@ -22,12 +22,27 @@ class HelloTest(DefaultTest):
HELLO_WORLD = "Hello World\n" HELLO_WORLD = "Hello World\n"
def run(self): def run(self):
c = self.mbed.serial_read(len(self.HELLO_WORLD)) c = self.mbed.serial_read(1)
if c is None:
self.print_result("ioerr_serial")
return
data_to_read = len(self.HELLO_WORLD)
read_buffer = ''
if c == '$': # target will printout TargetID e.g.: $$$$1040e649d5c09a09a3f6bc568adef61375c6
#Read additional 39 bytes of TargetID
if self.mbed.serial_read(39) is None:
self.print_result("ioerr_serial")
return
else:
data_to_read -= 1
read_buffer += c
c = self.mbed.serial_read(data_to_read)
read_buffer += c
if c is None: if c is None:
self.print_result("ioerr_serial") self.print_result("ioerr_serial")
return return
stdout.write(c) stdout.write(read_buffer)
if c == self.HELLO_WORLD: # Hello World received if read_buffer == self.HELLO_WORLD: # Hello World received
self.print_result('success') self.print_result('success')
else: else:
self.print_result('failure') self.print_result('failure')

View File

@ -22,7 +22,7 @@ from time import time
from sys import stdout from sys import stdout
class StdioTest(DefaultTest): class StdioTest(DefaultTest):
PATTERN_INT_VALUE = "^Your value was: (-?\d+)" PATTERN_INT_VALUE = "Your value was: (-?\d+)"
re_detect_int_value = re.compile(PATTERN_INT_VALUE) re_detect_int_value = re.compile(PATTERN_INT_VALUE)
def run(self): def run(self):

View File

@ -32,7 +32,7 @@ class WaitusTest(DefaultTest):
return return
if c == '$': # target will printout TargetID e.g.: $$$$1040e649d5c09a09a3f6bc568adef61375c6 if c == '$': # target will printout TargetID e.g.: $$$$1040e649d5c09a09a3f6bc568adef61375c6
#Read additional 39 bytes of TargetID #Read additional 39 bytes of TargetID
if not self.mbed.serial_read(39): if self.mbed.serial_read(39) is None:
self.print_result("ioerr_serial") self.print_result("ioerr_serial")
return return
c = self.mbed.serial_read(1) # Re-read first 'tick' c = self.mbed.serial_read(1) # Re-read first 'tick'

View File

@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
""" """
from os import stat, walk, remove from os import stat, walk
from os.path import join, splitext, exists, relpath, dirname, basename, split from os.path import join, splitext, exists, relpath, dirname, basename, split
from shutil import copyfile from shutil import copyfile
from copy import copy from copy import copy
@ -23,12 +23,10 @@ from inspect import getmro
from time import time from time import time
from workspace_tools.utils import run_cmd, mkdir, rel_path, ToolException, split_path from workspace_tools.utils import run_cmd, mkdir, rel_path, ToolException, split_path
from workspace_tools.patch import patch
from workspace_tools.settings import BUILD_OPTIONS, MBED_ORG_USER from workspace_tools.settings import BUILD_OPTIONS, MBED_ORG_USER
from multiprocessing import Pool, Manager, cpu_count from multiprocessing import Pool, cpu_count
from time import sleep from time import sleep
from pprint import pprint
import workspace_tools.hooks as hooks import workspace_tools.hooks as hooks
import re import re
@ -58,7 +56,7 @@ def print_notify_verbose(event):
elif event['type'] == 'cc': elif event['type'] == 'cc':
event['severity'] = event['severity'].title() event['severity'] = event['severity'].title()
event['file'] = basename(event['file']) event['file'] = basename(event['file'])
event['mcu_name'] = "None" event['mcu_name'] = "None"
event['toolchain'] = "None" event['toolchain'] = "None"
event['target_name'] = event['target_name'].upper() if event['target_name'] else "Unknown" event['target_name'] = event['target_name'].upper() if event['target_name'] else "Unknown"
event['toolchain_name'] = event['toolchain_name'].upper() if event['toolchain_name'] else "Unknown" event['toolchain_name'] = event['toolchain_name'].upper() if event['toolchain_name'] else "Unknown"
@ -153,7 +151,7 @@ class Resources:
self.linker_script = self.linker_script.replace('\\', '/') self.linker_script = self.linker_script.replace('\\', '/')
def __str__(self): def __str__(self):
s = [] s = []
for (label, resources) in ( for (label, resources) in (
('Include Directories', self.inc_dirs), ('Include Directories', self.inc_dirs),
@ -242,7 +240,7 @@ class mbedToolchain:
self.mp_pool = None self.mp_pool = None
def __exit__(): def __exit__(self):
if self.mp_pool is not None: if self.mp_pool is not None:
self.mp_pool.terminate() self.mp_pool.terminate()
@ -366,7 +364,7 @@ class mbedToolchain:
elif ext == '.o': elif ext == '.o':
resources.objects.append(file_path) resources.objects.append(file_path)
elif ext == self.LIBRARY_EXT: elif ext == self.LIBRARY_EXT:
resources.libraries.append(file_path) resources.libraries.append(file_path)
resources.lib_dirs.add(root) resources.lib_dirs.add(root)
@ -443,9 +441,9 @@ class mbedToolchain:
if inc_dirs is not None: if inc_dirs is not None:
inc_paths.extend(inc_dirs) inc_paths.extend(inc_dirs)
objects=[] objects = []
queue=[] queue = []
prev_dir=None prev_dir = None
# The dependency checking for C/C++ is delegated to the compiler # The dependency checking for C/C++ is delegated to the compiler
base_path = resources.base_path base_path = resources.base_path
@ -692,7 +690,8 @@ class mbedToolchain:
from workspace_tools.toolchains.arm import ARM_STD, ARM_MICRO from workspace_tools.toolchains.arm import ARM_STD, ARM_MICRO
from workspace_tools.toolchains.gcc import GCC_ARM, GCC_CS, GCC_CR, GCC_CW_EWL, GCC_CW_NEWLIB from workspace_tools.toolchains.gcc import GCC_ARM, GCC_CS, GCC_CR
from workspace_tools.toolchains.gcc import GCC_CW_EWL, GCC_CW_NEWLIB
from workspace_tools.toolchains.iar import IAR from workspace_tools.toolchains.iar import IAR
TOOLCHAIN_CLASSES = { TOOLCHAIN_CLASSES = {