diff --git a/test/security_manager_sc/Makefile b/test/security_manager_sc/Makefile index a03a748c6..ac264d3c9 100644 --- a/test/security_manager_sc/Makefile +++ b/test/security_manager_sc/Makefile @@ -79,7 +79,7 @@ VPATH += ${BTSTACK_ROOT}/chipset/zephyr CFLAGS += $(shell pkg-config libusb-1.0 --cflags) LDFLAGS += $(shell pkg-config libusb-1.0 --libs) -CFLAGS += -fprofile-arcs -ftest-coverage -fsanitize=address,undefined +CFLAGS += -fprofile-arcs -ftest-coverage -fsanitize=address,undefined -DCOVERAGE CORE_OBJ = $(CORE:.c=.o) COMMON_OBJ = $(COMMON:.c=.o) diff --git a/test/security_manager_sc/sm_test.c b/test/security_manager_sc/sm_test.c index f451c9484..f2d0e5388 100644 --- a/test/security_manager_sc/sm_test.c +++ b/test/security_manager_sc/sm_test.c @@ -62,7 +62,12 @@ #include "hci_dump.h" #include "l2cap.h" #include "btstack_stdin.h" - + +#ifdef COVERAGE +// guesswork: +void __gcov_flush(void); +#endif + #define HEARTBEAT_PERIOD_MS 1000 const uint8_t adv_data[] = { @@ -343,6 +348,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t * } static void stdin_process(char c){ + log_info("stdin: %c (%02x)", c, c); // passkey input if (ui_digits_for_passkey && c >= '0' && c <= '9'){ printf("%c", c); @@ -422,7 +428,11 @@ static void stdin_process(char c){ sm_request_pairing(connection_handle); break; case 'x': - printf("Exit\n"); +#ifdef COVERAGE + log_info("Flush gcov"); + __gcov_flush(); +#endif + printf("EXIT\n"); exit(0); break; default: diff --git a/test/security_manager_sc/sm_test.py b/test/security_manager_sc/sm_test.py index 285099b3e..fadb6ea42 100755 --- a/test/security_manager_sc/sm_test.py +++ b/test/security_manager_sc/sm_test.py @@ -49,7 +49,7 @@ failures = [ debug = False regenerate = False # usb_paths = ['4', '6'] -usb_paths = ['3', '5'] +usb_paths = ['1', '2'] class Node: @@ -117,7 +117,7 @@ class Node: args.append('-o') args.append(self.oob_data) print('%s - "%s"' % (self.name, ' '.join(args))) - self.p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + self.p = subprocess.Popen(args, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) (self.stdin, self.stdout) = (self.p.stdin, self.p.stdout) self.linebuffer = '' @@ -137,10 +137,13 @@ class Node: self.peer_addr = addr def write(self, string): - self.stdin.write(string) + self.stdin.write(string.encode('utf-8')) def terminate(self): self.write('x') + # wait for 'EXIT' message indicating coverage data was written + while not self.got_line(): + self.read_stdout() self.p.terminate() def run(test_descriptor, nodes):