kopia lustrzana https://github.com/micropython/micropython
unix: Add special function to improve coverage.
The function and corresponding command-line option are only enabled for the coverage build. They are used to exercise uPy features that can't be properly tested by Python scripts.pull/1241/merge
rodzic
0589c19d52
commit
d3b32caea4
|
@ -35,6 +35,8 @@ script:
|
||||||
- make -C unix CC=gcc-4.7 coverage
|
- make -C unix CC=gcc-4.7 coverage
|
||||||
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests)
|
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests)
|
||||||
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --emit native)
|
- (cd tests && MICROPY_CPYTHON3=python3.4 MICROPY_MICROPYTHON=../unix/micropython_coverage ./run-tests --emit native)
|
||||||
|
# TODO the output of this extra coverage test is not checked
|
||||||
|
- unix/micropython_coverage --coverage
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- (cd unix && coveralls --root .. --build-root . --gcov $(which gcov-4.7) --gcov-options '\-o build-coverage/' --include py --include extmod)
|
- (cd unix && coveralls --root .. --build-root . --gcov $(which gcov-4.7) --gcov-options '\-o build-coverage/' --include py --include extmod)
|
||||||
|
|
|
@ -94,6 +94,7 @@ SRC_C = \
|
||||||
file.c \
|
file.c \
|
||||||
modos.c \
|
modos.c \
|
||||||
alloc.c \
|
alloc.c \
|
||||||
|
coverage.c \
|
||||||
$(SRC_MOD)
|
$(SRC_MOD)
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,9 +134,11 @@ minimal:
|
||||||
|
|
||||||
# build an interpreter for coverage testing and do the testing
|
# build an interpreter for coverage testing and do the testing
|
||||||
coverage:
|
coverage:
|
||||||
$(MAKE) COPT="-O0" CFLAGS_EXTRA='-fprofile-arcs -ftest-coverage -Wdouble-promotion -Wformat -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wpointer-arith -Wshadow -Wsign-compare -Wuninitialized -Wunused-parameter' LDFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' BUILD=build-coverage PROG=micropython_coverage
|
$(MAKE) COPT="-O0" CFLAGS_EXTRA='-fprofile-arcs -ftest-coverage -Wdouble-promotion -Wformat -Wmissing-declarations -Wmissing-prototypes -Wold-style-definition -Wpointer-arith -Wshadow -Wsign-compare -Wuninitialized -Wunused-parameter -DMICROPY_UNIX_COVERAGE' LDFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' BUILD=build-coverage PROG=micropython_coverage
|
||||||
|
|
||||||
coverage_test: coverage
|
coverage_test: coverage
|
||||||
$(eval DIRNAME=$(notdir $(CURDIR)))
|
$(eval DIRNAME=$(notdir $(CURDIR)))
|
||||||
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests
|
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests
|
||||||
|
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --emit native
|
||||||
gcov -o build-coverage/py ../py/*.c
|
gcov -o build-coverage/py ../py/*.c
|
||||||
|
gcov -o build-coverage/extmod ../extmod/*.c
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "py/obj.h"
|
||||||
|
#include "py/runtime.h"
|
||||||
|
#include "py/repl.h"
|
||||||
|
|
||||||
|
#if defined(MICROPY_UNIX_COVERAGE)
|
||||||
|
|
||||||
|
// function to run extra tests for things that can't be checked by scripts
|
||||||
|
void run_extra_coverage_tests(void);
|
||||||
|
|
||||||
|
void run_extra_coverage_tests(void) {
|
||||||
|
// repl autocomplete
|
||||||
|
{
|
||||||
|
const char *str;
|
||||||
|
mp_uint_t len = mp_repl_autocomplete("__", 2, &mp_plat_print, &str);
|
||||||
|
printf("%.*s\n", (int)len, str);
|
||||||
|
|
||||||
|
mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0)));
|
||||||
|
mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str);
|
||||||
|
len = mp_repl_autocomplete("sys.impl", 8, &mp_plat_print, &str);
|
||||||
|
printf("%.*s\n", (int)len, str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -434,6 +434,12 @@ int main(int argc, char **argv) {
|
||||||
MP_STATE_VM(mp_optimise_value) = 0;
|
MP_STATE_VM(mp_optimise_value) = 0;
|
||||||
for (char *p = argv[a] + 1; *p && *p == 'O'; p++, MP_STATE_VM(mp_optimise_value)++);
|
for (char *p = argv[a] + 1; *p && *p == 'O'; p++, MP_STATE_VM(mp_optimise_value)++);
|
||||||
}
|
}
|
||||||
|
#if defined(MICROPY_UNIX_COVERAGE)
|
||||||
|
} else if (strcmp(argv[a], "--coverage") == 0) {
|
||||||
|
void run_extra_coverage_tests(void);
|
||||||
|
run_extra_coverage_tests();
|
||||||
|
ret = 0;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
return usage(argv);
|
return usage(argv);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue