Skip to content

Commit 71db9c2

Browse files
committed
testing/nuts: NuttX Unit Test Selection (NUTS) application.
Introduces a collection of unit tests for NuttX, built on top of the cmocka framework. Tests are organized into suites/groups which can be individually included/excluded from the build using Kconfig. Output is easily legible and separated with headers including the test group name. Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
1 parent c4da1b5 commit 71db9c2

16 files changed

Lines changed: 2560 additions & 0 deletions

File tree

‎testing/nuts/CMakeLists.txt‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# ##############################################################################
2+
# apps/testing/nuts/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_TESTING_NUTS)
24+
25+
set(SRCS)
26+
27+
if(CONFIG_TESTING_NUTS_DSTRUCTS)
28+
file(GLOB DSTRUCTS dstructs/*.c)
29+
list(APPEND SRCS ${DSTRUCTS})
30+
endif() # CONFIG_TESTING_NUTS_DSTRUCTS
31+
32+
if(CONFIG_TESTING_NUTS_DEVICES)
33+
file(GLOB DEVICES devices/*.c)
34+
list(APPEND SRCS ${DEVICES})
35+
endif() # CONFIG_TESTING_NUTS_DEVICES
36+
37+
set(NUTS_SRCS nuts_main.c ${SRCS})
38+
nuttx_add_application(NAME ${CONFIG_TESTING_NUTS_PROGNAME} SRCS ${NUTS_SRCS})
39+
40+
endif()

‎testing/nuts/Kconfig‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config TESTING_NUTS
7+
tristate "NuttX Unit Test Selection (NUTS)"
8+
depends on TESTING_CMOCKA
9+
default n
10+
---help---
11+
Enable the NuttX unit test selection, based on the cmocka test framework.
12+
13+
if TESTING_NUTS
14+
15+
comment "Program options"
16+
17+
config TESTING_NUTS_PROGNAME
18+
string "Program name"
19+
default "nuts"
20+
---help---
21+
The name of the program.
22+
23+
config TESTING_NUTS_STACKSIZE
24+
int "Stack size"
25+
default 1024
26+
---help---
27+
Size of the stack used to create the task.
28+
29+
comment "Test Suites"
30+
31+
comment "Data structures"
32+
33+
config TESTING_NUTS_DSTRUCTS
34+
bool "Collections tests"
35+
default n
36+
---help---
37+
Enable test suites for collections.
38+
39+
if TESTING_NUTS_DSTRUCTS
40+
41+
config TESTING_NUTS_DSTRUCTS_LIST
42+
bool "List testing"
43+
default y
44+
---help---
45+
Enable list test cases.
46+
47+
config TESTING_NUTS_DSTRUCTS_CBUF
48+
bool "Circular buffer testing"
49+
default y
50+
---help---
51+
Enable circular buffer test cases.
52+
53+
endif # TESTING_NUTS_DSTRUCTS
54+
55+
comment "Devices"
56+
57+
config TESTING_NUTS_DEVICES
58+
bool "Device tests"
59+
default n
60+
---help---
61+
Enable test suites for devices.
62+
63+
if TESTING_NUTS_DEVICES
64+
65+
config TESTING_NUTS_DEVICES_DEVNULL
66+
bool "/dev/null test"
67+
depends on DEV_NULL
68+
default y
69+
---help---
70+
Enable test cases for /dev/null device.
71+
72+
config TESTING_NUTS_DEVICES_DEVZERO
73+
bool "/dev/zero test"
74+
depends on DEV_ZERO
75+
default y
76+
---help---
77+
Enable test cases for /dev/zero device.
78+
79+
config TESTING_NUTS_DEVICES_DEVASCII
80+
bool "/dev/ascii test"
81+
depends on DEV_ASCII
82+
default y
83+
---help---
84+
Enable test cases for /dev/ascii device.
85+
86+
config TESTING_NUTS_DEVICES_DEVCONSOLE
87+
bool "/dev/console test"
88+
depends on DEV_CONSOLE
89+
default y
90+
---help---
91+
Enable test cases for /dev/console device.
92+
93+
config TESTING_NUTS_DEVICES_DEVURANDOM
94+
bool "/dev/urandom test"
95+
depends on DEV_URANDOM
96+
default y
97+
---help---
98+
Enable test cases for /dev/urandom device.
99+
100+
endif # TESTING_NUTS_DEVICES
101+
102+
endif # TESTING_NUTS

‎testing/nuts/Make.defs‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/testing/nuts/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_TESTING_NUTS),)
24+
CONFIGURED_APPS += $(APPDIR)/testing/nuts
25+
endif

‎testing/nuts/Makefile‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
############################################################################
2+
# apps/testing/nuts/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
# Application info
26+
27+
PROGNAME = $(CONFIG_TESTING_NUTS_PROGNAME)
28+
PRIORITY = SCHED_PRIORITY_DEFAULT
29+
STACKSIZE = $(CONFIG_TESTING_NUTS_STACKSIZE)
30+
MODULE = $(CONFIG_TESTING_OSTEST)
31+
32+
# Source inclusion
33+
34+
MAINSRC = nuts_main.c
35+
CSRCS =
36+
37+
ifeq ($(CONFIG_TESTING_NUTS_DSTRUCTS),y)
38+
CSRCS += $(wildcard $(CURDIR)/dstructs/*.c)
39+
endif # CONFIG_TESTING_NUTS_DSTRUCTS
40+
41+
ifeq ($(CONFIG_TESTING_NUTS_DEVICES),y)
42+
CSRCS += $(wildcard $(CURDIR)/devices/*.c)
43+
endif # CONFIG_TESTING_NUTS_DEVICES
44+
45+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)