Skip to contentSkip to conversation

Framework for non-interactive mesh test

PATCH Superseded Inga Stotland 2 participants 5 messages Feb 6, 2021

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Framework for non-interactive mesh test

This patch set introduces a framework for non-interactive testing of mesh daemon functionality and consists of the three components:

1. A version of src/shared/tester that uses ELL primitives:
everything mesh-related uses ELL.

2. New type of mesh IO used only for testing.

3. The mesh-cfgtest tool that excercises a number of mesh D-Bus API calls. Currently, the tool covers limited number of initial test cases. The extended coverage will be provided after this patch set is accepted.

Brian Gix (1):
mesh: Add unit test IO

Inga Stotland (2):
shared/tester: Create ell-based version of tester code tools/mesh-cfgtest: Non-iteractive test for mesh daemon

 Makefile.am             |    8 +-
 Makefile.mesh           |    2 +
 Makefile.tools          |    6 +
 mesh/main.c             |   51 +-
 mesh/mesh-io-unit.c     |  542 ++++++++++++++++
 mesh/mesh-io-unit.h     |   20 +
 mesh/mesh-io.c          |    9 +-
 mesh/mesh-io.h          |    3 +-
 src/shared/tester-ell.c |  887 ++++++++++++++++++++++++++
 tools/mesh-cfgtest.c    | 1319 +++++++++++++++++++++++++++++++++++++++
 10 files changed, 2826 insertions(+), 21 deletions(-)
 create mode 100644 mesh/mesh-io-unit.c
 create mode 100644 mesh/mesh-io-unit.h
 create mode 100644 src/shared/tester-ell.c
 create mode 100644 tools/mesh-cfgtest.c
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/3 shared/tester: Create ell-based version of tester code

Create a version of tester that uses ell primitives instead of glib:
tester-ell.c. This source is included to generate lishared-ell library. The original tester.c is built as part of libshared-glib library.

---
 Makefile.am             |   8 +-
 src/shared/tester-ell.c | 887 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 892 insertions(+), 3 deletions(-)
 create mode 100644 src/shared/tester-ell.c
Makefile.am +5 -3
index d0f979586..5fa9706c8 100644
@@ -189,7 +189,7 @@ shared_sources = src/shared/io.h src/shared/timeout.h \
 			src/shared/crypto.h src/shared/crypto.c \
 			src/shared/ecc.h src/shared/ecc.c \
 			src/shared/ringbuf.h src/shared/ringbuf.c \
-			src/shared/tester.h src/shared/tester.c \
+			src/shared/tester.h\
 			src/shared/hci.h src/shared/hci.c \
 			src/shared/hci-crypto.h src/shared/hci-crypto.c \
 			src/shared/hfp.h src/shared/hfp.c \
@@ -216,7 +216,8 @@ src_libshared_glib_la_SOURCES = $(shared_sources) \
 				src/shared/timeout-glib.c \
 				src/shared/mainloop-glib.c \
 				src/shared/mainloop-notify.h \
-				src/shared/mainloop-notify.c
+				src/shared/mainloop-notify.c \
+				src/shared/tester.c
 
 src_libshared_mainloop_la_SOURCES = $(shared_sources) \
 				src/shared/io-mainloop.c \
@@ -230,7 +231,8 @@ src_libshared_ell_la_SOURCES = $(shared_sources) \
 				src/shared/io-ell.c \
 				src/shared/timeout-ell.c \
 				src/shared/mainloop.h \
-				src/shared/mainloop-ell.c
+				src/shared/mainloop-ell.c \
+				src/shared/tester-ell.c
 endif
 
 attrib_sources = attrib/att.h attrib/att-database.h attrib/att.c \
src/shared/tester-ell.c new file +887 -0

887 lines not on this page · raw message

Signature · 1 line
2.26.2
#2 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=429145

---Test result---

##############################
Test: CheckPatch - FAIL
Output:
shared/tester: Create ell-based version of tester code WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #166: FILE: src/shared/tester-ell.c:118:
+} __attribute__((packed));

WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #171: FILE: src/shared/tester-ell.c:123:
+} __attribute__((packed));

ERROR:INITIALISED_STATIC: do not initialise statics to false #816: FILE: src/shared/tester-ell.c:768:
+ static bool terminated = false;

- total: 1 errors, 2 warnings, 913 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

"[PATCH] shared/tester: Create ell-based version of tester code" has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

mesh: Add unit test IO
WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #126: FILE: mesh/mesh-io-unit.c:1:
+/*

WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #674: FILE: mesh/mesh-io-unit.h:1:
+/*

- total: 0 errors, 2 warnings, 686 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

"[PATCH] mesh: Add unit test IO" has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS

---
Regards,
Linux Bluetooth

#3 lore raw

PATCH 2/3 mesh: Add unit test IO

In reply to Inga Stotland

From: Brian Gix <[email protected]>

This adds a new type of mesh IO that is used for non-interactive testing. The new io option can be specified on command line as:
--io unit:<socket_name>

When the bluetooth-meshd daemon starts with the "unit" IO type, the daemon opens a socket (fd to open is provided after "unit:" in <socket_name>). The communication with the daemon is done either through the loop-back using mesh DBus-based APIs or the specified named socket.

---
 Makefile.mesh       |   2 +
 mesh/main.c         |  41 +++-
 mesh/mesh-io-unit.c | 542 ++++++++++++++++++++++++++++++++++++++++++++
 mesh/mesh-io-unit.h |  20 ++
 mesh/mesh-io.c      |   9 +-
 mesh/mesh-io.h      |   3 +-
 6 files changed, 600 insertions(+), 17 deletions(-)
 create mode 100644 mesh/mesh-io-unit.c
 create mode 100644 mesh/mesh-io-unit.h
Makefile.mesh +2 -0
index 228dd1b5f..73eaded4a 100644
@@ -17,6 +17,8 @@ mesh_sources = mesh/mesh.h mesh/mesh.c \
 				mesh/error.h mesh/mesh-io-api.h \
 				mesh/mesh-io-generic.h \
 				mesh/mesh-io-generic.c \
+				mesh/mesh-io-unit.h \
+				mesh/mesh-io-unit.c \
 				mesh/net.h mesh/net.c \
 				mesh/crypto.h mesh/crypto.c \
 				mesh/friend.h mesh/friend.c \
mesh/main.c +30 -11

81 lines not on this page · raw message

mesh/mesh-io-unit.c new file +542 -0

542 lines not on this page · raw message

mesh/mesh-io-unit.h new file +20 -0
new file mode 100644
index 000000000..65f02e26a
@@ -0,0 +1,20 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2018  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ */
+
+extern const struct mesh_io_api mesh_io_unit;
mesh/mesh-io.c +4 -5
index 62fc5d12e..96891313a 100644
@@ -22,10 +22,12 @@
 
 /* List of Mesh-IO Type headers */
 #include "mesh/mesh-io-generic.h"
+#include "mesh/mesh-io-unit.h"
 
 /* List of Supported Mesh-IO Types */
 static const struct mesh_io_table table[] = {
-	{MESH_IO_TYPE_GENERIC,	&mesh_io_generic}
+	{MESH_IO_TYPE_GENERIC, &mesh_io_generic},
+	{MESH_IO_TYPE_UNIT_TEST, &mesh_io_unit},
 };
 
 static struct l_queue *io_list;
@@ -64,12 +66,9 @@ struct mesh_io *mesh_io_new(enum mesh_io_type type, void *opts,
 
 	io = l_new(struct mesh_io, 1);
 
-	if (!io)
-		return NULL;
-
 	io->type = type;
-
 	io->api = api;
+
 	if (!api->init(io, opts, cb, user_data))
 		goto fail;
 
mesh/mesh-io.h +2 -1
index b11c6c6e1..80ef3fa3e 100644
@@ -14,7 +14,8 @@ struct mesh_io;
 
 enum mesh_io_type {
 	MESH_IO_TYPE_NONE = 0,
-	MESH_IO_TYPE_GENERIC
+	MESH_IO_TYPE_GENERIC,
+	MESH_IO_TYPE_UNIT_TEST
 };
 
 enum mesh_io_timing_type {
Signature · 1 line
2.26.2
#4 lore raw

PATCH 3/3 tools/mesh-cfgtest: Non-iteractive test for mesh daemon

In reply to Inga Stotland

This adds a non-interactive test to excercise different datapaths in bluetooth-meshd. The test cases utilize D-Bus based mesh APIs, e.g., to create a new network, import a node, import NetKey, import a remote node.

Also, the test incorporates a number of configuration messages and expected responses to verify the daemon's internal implementation of configuration server.

---
 Makefile.tools       |    6 +
 mesh/main.c          |   10 +-
 tools/mesh-cfgtest.c | 1319 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1334 insertions(+), 1 deletion(-)
 create mode 100644 tools/mesh-cfgtest.c
Makefile.tools +6 -0
index d5fdf2d89..3217ca8a6 100644
@@ -335,6 +335,12 @@ tools_mesh_cfgclient_SOURCES = tools/mesh-cfgclient.c \
 
 tools_mesh_cfgclient_LDADD = lib/libbluetooth-internal.la src/libshared-ell.la \
 						$(ell_ldadd) -ljson-c -lreadline
+
+bin_PROGRAMS +=  tools/mesh-cfgtest
+
+tools_mesh_cfgtest_SOURCES = tools/mesh-cfgtest.c
+tools_mesh_cfgtest_LDADD = lib/libbluetooth-internal.la src/libshared-ell.la \
+						$(ell_ldadd)
 endif
 
 EXTRA_DIST += tools/mesh-gatt/local_node.json tools/mesh-gatt/prov_db.json
mesh/main.c +9 -1
index 1b466598b..a13866d7e 100644
@@ -17,7 +17,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <ctype.h>
+#include <signal.h>
 
+#include <sys/prctl.h>
 #include <sys/stat.h>
 #include <ell/ell.h>
 
@@ -262,7 +264,13 @@ int main(int argc, char *argv[])
 	if (!detached)
 		umask(0077);
 
-	dbus = l_dbus_new_default(L_DBUS_SYSTEM_BUS);
+	if (io_type != MESH_IO_TYPE_UNIT_TEST)
+		dbus = l_dbus_new_default(L_DBUS_SYSTEM_BUS);
+	else {
+		dbus = l_dbus_new_default(L_DBUS_SESSION_BUS);
+		prctl(PR_SET_PDEATHSIG, SIGSEGV);
+	}
+
 	if (!dbus) {
 		l_error("unable to connect to D-Bus");
 		status = EXIT_FAILURE;
tools/mesh-cfgtest.c new file +1319 -0

1,319 lines not on this page · raw message

Signature · 1 line
2.26.2