...
 
Commits (5)
......@@ -626,6 +626,8 @@ pass spacebel_tickets/SPB_1604
pass spacebel_tickets/SPB_1651
pass spacebel_tickets/SPB_1689
pass spacebel_tickets/SPB_1781
pass spacebel_tickets/SPB_1852
pass spacebel_tickets/SPB_2000
pass spacebel_tickets/SPB_542
pass spacebel_tickets/SPB_543
pass spacebel_tickets/SPB_544
......@@ -663,10 +665,45 @@ FAIL spacebel_tickets/SPB_997
pass spacebel_tickets/SPB_998
pass spacebel_tickets/SPB_999
pass spacebel_tickets/SPB_extra
48 tests performed (201 individual testcases)
47 tests passed
50 tests performed (210 individual testcases)
49 tests passed
1 tests failed - SPB_997
pass cpydiff/builtin_next_arg2
pass cpydiff/core_class_delnotimpl
pass cpydiff/core_class_mro
pass cpydiff/core_class_supermultiple
pass cpydiff/core_class_superproperty
pass cpydiff/core_function_argcount
pass cpydiff/core_function_userattr
pass cpydiff/core_generator_noexit
pass cpydiff/core_locals
pass cpydiff/modules_array_containment
pass cpydiff/modules_array_deletion
pass cpydiff/modules_array_subscrstep
pass cpydiff/types_bytearray_sliceassign
pass cpydiff/types_bytes_keywords
pass cpydiff/types_bytes_subscrstep
pass cpydiff/types_exception_chaining
pass cpydiff/types_exception_instancevar
pass cpydiff/types_exception_loops
pass cpydiff/types_exception_subclassinit
pass cpydiff/types_float_rounding
pass cpydiff/types_int_subclassconv
pass cpydiff/types_list_delete_subscrstep
pass cpydiff/types_list_store_noniter
pass cpydiff/types_list_store_subscrstep
pass cpydiff/types_str_endswith
pass cpydiff/types_str_formatsubscr
pass cpydiff/types_str_keywords
pass cpydiff/types_str_ljust_rjust
pass cpydiff/types_str_rsplitnone
pass cpydiff/types_str_subclassequality
pass cpydiff/types_str_subscrstep
pass cpydiff/types_tuple_subscrstep
32 tests performed (113 individual testcases)
32 tests passed
pass leon_t1/DATAPOOL_01
pass leon_t1/DATAPOOL_02
pass leon_t1/DATAPOOL_03
......@@ -686,7 +723,7 @@ pass leon_t1/ROB_INPUT_04
pass leon_t1/ROB_STACK_01
pass leon_t1/ROB_STACK_02
pass leon_t1/ROB_STACK_03
FAIL leon_t1/ROB_STACK_04
pass leon_t1/ROB_STACK_04
pass leon_t1/RTEMS_01
pass leon_t1/RTEMS_CONST_01
pass leon_t1/RTEMS_QUEUE_01
......@@ -694,8 +731,7 @@ pass leon_t1/RTEMS_SEM_01
pass leon_t1/RTEMS_SEM_02
pass leon_t1/RTEMS_TASK_01
26 tests performed (396 individual testcases)
25 tests passed
1 tests failed - ROB_STACK_04
26 tests passed
pass leon_t2/DATAPOOL_05
pass leon_t2/ROB_TASK_01
......@@ -737,5 +773,11 @@ leon_perf/PERF_RAM_01:
1104 376
1104 456
pass mpy_cross/SPB_2021a
pass mpy_cross/SPB_2021b
pass mpy_cross/SPB_2021c
3 tests performed (9 individual testcases)
3 tests passed
Running test: VM_MANAGER
test passed
......@@ -13,3 +13,4 @@
./run-tests.sh -t 2 leon_t2/*.exp
./run-tests.sh -t 10 leon_t10/*.exp
./run-tests.sh -o leon_perf/*.py
./run-tests-mpy-cross.sh mpy_cross/*.py
......@@ -30,11 +30,11 @@ ValueError(0, 14)
14 None
ValueError(0, 15)
15 None
RuntimeError('maximum recursion depth exceeded',)
RuntimeError('pystack exhausted',)
16 None
RuntimeError('maximum recursion depth exceeded',)
RuntimeError('pystack exhausted',)
17 None
RuntimeError('maximum recursion depth exceeded',)
RuntimeError('pystack exhausted',)
18 None
RuntimeError('maximum recursion depth exceeded',)
RuntimeError('pystack exhausted',)
19 None
Traceback (most recent call last):
File "mpy_cross/SPB_2021a.py", line 7, in <module>
SyntaxError: 'break' within finally
# compiler should reject this
while 1:
try:
pass
finally:
break
Traceback (most recent call last):
File "mpy_cross/SPB_2021b.py", line 7, in <module>
SyntaxError: 'continue' within finally
# compiler should reject this
while 1:
try:
pass
finally:
continue
Traceback (most recent call last):
File "mpy_cross/SPB_2021c.py", line 11, in foo
SyntaxError: 'return' within nested finally
# compiler should reject this
def foo():
while 1:
try:
pass
finally:
try:
pass
finally:
return
#!/bin/sh
#
# This file is part of the MicroPython port to LEON platforms
# Copyright (c) 2015-2018 George Robotics Limited
######## settings
RM="rm -f"
MPC="../mpy-cross/mpy-cross"
######## parse arguments
tests="$@"
if [ -z "$tests" ]; then
echo "no tests specified"
exit 1
fi
######## run tests
numtests=0
numtestcases=0
numpassed=0
numskipped=0
numfailed=0
nameskipped=
namefailed=
for testfile in $tests
do
# strip of .exp or .py to allow either to be passed in
basename=$(basename $testfile .exp)
basename=$(basename $basename .py)
infile_no_ext=$(dirname $testfile)/$basename
expfile=${infile_no_ext}.exp
outfile=${basename}.out
$MPC ${infile_no_ext}.py > $outfile 2>&1
numtestcases=$(expr $numtestcases + $(cat $expfile | wc -l))
diff --brief $expfile $outfile > /dev/null
if [ $? -eq 0 ]
then
echo "pass $infile_no_ext"
$RM $outfile
numpassed=$(expr $numpassed + 1)
else
echo "FAIL $infile_no_ext"
numfailed=$(expr $numfailed + 1)
namefailed="$namefailed $basename"
fi
numtests=$(expr $numtests + 1)
done
echo "$numtests tests performed ($numtestcases individual testcases)"
echo "$numpassed tests passed"
if [ $numskipped != 0 ]
then
echo "$numskipped tests skipped -$nameskipped"
fi
if [ $numfailed != 0 ]
then
echo "$numfailed tests failed -$namefailed"
exit 1
else
exit 0
fi
......@@ -21,6 +21,7 @@ make -C leon-for-tests || exit $?
(cd leon-tests && ./run-tests.sh -t 2 leon_t2/*.exp)
(cd leon-tests && ./run-tests.sh -t 10 leon_t10/*.exp)
(cd leon-tests && ./run-tests.sh -o leon_perf/*.exp)
(cd leon-tests && ./run-tests-mpy-cross.sh mpy_cross/*.py)
(cd leon-ex-manager && ./run-test.sh)
# The OBCP example is not supported with Edisoft RTEMS 4.8
......
......@@ -145,6 +145,10 @@ typedef struct _compiler_t {
emit_inline_asm_t *emit_inline_asm; // current emitter for inline asm
const emit_inline_asm_method_table_t *emit_inline_asm_method_table; // current emit method table for inline asm
#endif
// Keep track of current depth within the finally handler of a try-finally,
// to prevent break/continue/return within finally that can crash the VM.
unsigned int within_finally_depth;
} compiler_t;
STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
......@@ -946,6 +950,9 @@ STATIC void compile_del_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
}
STATIC void compile_break_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
if (comp->within_finally_depth > 0) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "'break' within finally");
}
if (comp->break_label == INVALID_LABEL) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "'break' outside loop");
}
......@@ -954,6 +961,9 @@ STATIC void compile_break_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
}
STATIC void compile_continue_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
if (comp->within_finally_depth > 0) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "'continue' within finally");
}
if (comp->continue_label == INVALID_LABEL) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "'continue' outside loop");
}
......@@ -962,6 +972,9 @@ STATIC void compile_continue_stmt(compiler_t *comp, mp_parse_node_struct_t *pns)
}
STATIC void compile_return_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
if (comp->within_finally_depth > 1) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "'return' within nested finally");
}
if (comp->scope_cur->kind != SCOPE_FUNCTION) {
compile_syntax_error(comp, (mp_parse_node_t)pns, "'return' outside function");
return;
......@@ -1620,7 +1633,9 @@ STATIC void compile_try_finally(compiler_t *comp, mp_parse_node_t pn_body, int n
EMIT(pop_block);
EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
EMIT_ARG(label_assign, l_finally_block);
++comp->within_finally_depth;
compile_node(comp, pn_finally);
--comp->within_finally_depth;
compile_decrease_except_level(comp);
EMIT(end_finally);
......
......@@ -169,12 +169,12 @@ static inline bool MP_OBJ_IS_OBJ(mp_const_obj_t o)
#elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
static inline bool MP_OBJ_IS_SMALL_INT(mp_const_obj_t o)
{ return ((((mp_int_t)(o)) & 0xffff000000000000ULL) == 0x0001000000000000ULL); }
{ return ((((uint64_t)(o)) & 0xffff000000000000ULL) == 0x0001000000000000ULL); }
#define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)((o) << 16)) >> 17)
#define MP_OBJ_NEW_SMALL_INT(small_int) (((((uint64_t)(small_int)) & 0x7fffffffffff) << 1) | 0x0001000000000001)
static inline bool MP_OBJ_IS_QSTR(mp_const_obj_t o)
{ return ((((mp_int_t)(o)) & 0xffff000000000000ULL) == 0x0002000000000000ULL); }
{ return ((((uint64_t)(o)) & 0xffff000000000000ULL) == 0x0002000000000000ULL); }
#define MP_OBJ_QSTR_VALUE(o) ((((uint32_t)(o)) >> 1) & 0xffffffff)
#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 1) | 0x0002000000000001))
......