Skip to content

Commit c855d9c

Browse files
committed
Simplify Test Build Flags
1. Modify all the test executable `CPPFLAGS` to only have `-DNO_MAIN_LOOP` and `AM_CPPFLAGS`. This removes a lot of duplicate setup of flags for each of the tests. 2. Delete the echoserver's `CFLAGS`. It is just setting the `CFLAGS` for its compile to `AM_CFLAGS` and `AM_CPPFLAGS` which are included by default. 3. Add the macro WS_MAYBE_UNUSED that may be the unused attribute. 4. If INLINE isn't set to some form of inline, set it to WS_MAYBE_UNUSED. 5. Remove redundant ThreadStartNoJoin() macros from the testing header.
1 parent 0b451e5 commit c855d9c

4 files changed

Lines changed: 16 additions & 154 deletions

File tree

examples/echoserver/include.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ examples_echoserver_echoserver_SOURCES = examples/echoserver/echoserver.c \
77
examples/echoserver/echoserver.h
88
examples_echoserver_echoserver_LDADD = src/libwolfssh.la
99
examples_echoserver_echoserver_DEPENDENCIES = src/libwolfssh.la
10-
examples_echoserver_echoserver_CFLAGS = $(AM_CFLAGS) ${AM_CPPFLAGS}
1110
endif

tests/include.am

Lines changed: 5 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -6,67 +6,13 @@ check_PROGRAMS += tests/unit.test tests/api.test \
66
tests/testsuite.test tests/kex.test
77

88
tests_unit_test_SOURCES = tests/unit.c tests/unit.h
9-
tests_unit_test_CPPFLAGS = -DNO_MAIN_DRIVER
10-
if BUILD_KEYGEN
11-
tests_unit_test_CPPFLAGS += -DWOLFSSH_KEYGEN
12-
endif
13-
if BUILD_SCP
14-
tests_unit_test_CPPFLAGS += -DWOLFSSH_SCP
15-
endif
16-
if BUILD_SFTP
17-
tests_unit_test_CPPFLAGS += -DWOLFSSH_SFTP
18-
endif
19-
if BUILD_TERM
20-
tests_unit_test_CPPFLAGS += -DWOLFSSH_TERM
21-
endif
22-
if BUILD_SHELL
23-
tests_unit_test_CPPFLAGS += -DWOLFSSH_SHELL
24-
endif
25-
if BUILD_AGENT
26-
tests_unit_test_CPPFLAGS += -DWOLFSSH_AGENT
27-
endif
28-
if BUILD_FWD
29-
tests_unit_test_CPPFLAGS += -DWOLFSSH_FWD
30-
endif
31-
if BUILD_CERTS
32-
tests_unit_test_CPPFLAGS += -DWOLFSSH_CERTS
33-
endif
34-
if BUILD_KEYBOARD_INTERACTIVE
35-
tests_unit_test_CPPFLAGS += -DWOLFSSH_KEYBOARD_INTERACTIVE
36-
endif
9+
tests_unit_test_CPPFLAGS = -DNO_MAIN_DRIVER $(AM_CPPFLAGS)
3710
tests_unit_test_LDADD = src/libwolfssh.la
3811
tests_unit_test_DEPENDENCIES = src/libwolfssh.la
3912

4013
tests_api_test_SOURCES = tests/api.c tests/api.h \
4114
examples/echoserver/echoserver.c
42-
tests_api_test_CPPFLAGS = -DNO_MAIN_DRIVER
43-
if BUILD_KEYGEN
44-
tests_api_test_CPPFLAGS += -DWOLFSSH_KEYGEN
45-
endif
46-
if BUILD_SCP
47-
tests_api_test_CPPFLAGS += -DWOLFSSH_SCP
48-
endif
49-
if BUILD_SFTP
50-
tests_api_test_CPPFLAGS += -DWOLFSSH_SFTP
51-
endif
52-
if BUILD_TERM
53-
tests_api_test_CPPFLAGS += -DWOLFSSH_TERM
54-
endif
55-
if BUILD_SHELL
56-
tests_api_test_CPPFLAGS += -DWOLFSSH_SHELL
57-
endif
58-
if BUILD_AGENT
59-
tests_api_test_CPPFLAGS += -DWOLFSSH_AGENT
60-
endif
61-
if BUILD_FWD
62-
tests_api_test_CPPFLAGS += -DWOLFSSH_FWD
63-
endif
64-
if BUILD_CERTS
65-
tests_api_test_CPPFLAGS += -DWOLFSSH_CERTS
66-
endif
67-
if BUILD_KEYBOARD_INTERACTIVE
68-
tests_api_test_CPPFLAGS += -DWOLFSSH_KEYBOARD_INTERACTIVE
69-
endif
15+
tests_api_test_CPPFLAGS = -DNO_MAIN_DRIVER $(AM_CPPFLAGS)
7016
tests_api_test_LDADD = src/libwolfssh.la
7117
tests_api_test_DEPENDENCIES = src/libwolfssh.la
7218

@@ -77,65 +23,14 @@ tests_testsuite_test_SOURCES = tests/testsuite.c tests/testsuite.h \
7723
examples/client/common.c \
7824
examples/client/common.h \
7925
examples/sftpclient/sftpclient.c
80-
tests_testsuite_test_CPPFLAGS = -DNO_MAIN_DRIVER
81-
if BUILD_KEYGEN
82-
tests_testsuite_test_CPPFLAGS += -DWOLFSSH_KEYGEN
83-
endif
84-
if BUILD_SCP
85-
tests_testsuite_test_CPPFLAGS += -DWOLFSSH_SCP
86-
endif
87-
if BUILD_SFTP
88-
tests_testsuite_test_CPPFLAGS += -DWOLFSSH_SFTP
89-
endif
90-
if BUILD_TERM
91-
tests_testsuite_test_CPPFLAGS += -DWOLFSSH_TERM
92-
endif
93-
if BUILD_SHELL
94-
tests_testsuite_test_CPPFLAGS += -DWOLFSSH_SHELL
95-
endif
96-
if BUILD_AGENT
97-
tests_testsuite_test_CPPFLAGS += -DWOLFSSH_AGENT
98-
endif
99-
if BUILD_FWD
100-
tests_testsuite_test_CPPFLAGS += -DWOLFSSH_FWD
101-
endif
102-
if BUILD_CERTS
103-
tests_testsuite_test_CPPFLAGS += -DWOLFSSH_CERTS
104-
endif
105-
if BUILD_KEYBOARD_INTERACTIVE
106-
tests_testsuite_test_CPPFLAGS += -DWOLFSSH_KEYBOARD_INTERACTIVE
107-
endif
26+
tests_testsuite_test_CPPFLAGS = -DNO_MAIN_DRIVER $(AM_CPPFLAGS)
10827
tests_testsuite_test_LDADD = src/libwolfssh.la
10928
tests_testsuite_test_DEPENDENCIES = src/libwolfssh.la
11029

11130
if BUILD_KEYBOARD_INTERACTIVE
11231
check_PROGRAMS += tests/auth.test
11332
tests_auth_test_SOURCES = tests/auth.c tests/auth.h
114-
tests_auth_test_CPPFLAGS = -DNO_MAIN_DRIVER -DWOLFSSH_KEYBOARD_INTERACTIVE
115-
if BUILD_KEYGEN
116-
tests_auth_test_CPPFLAGS += -DWOLFSSH_KEYGEN
117-
endif
118-
if BUILD_SCP
119-
tests_auth_test_CPPFLAGS += -DWOLFSSH_SCP
120-
endif
121-
if BUILD_SFTP
122-
tests_auth_test_CPPFLAGS += -DWOLFSSH_SFTP
123-
endif
124-
if BUILD_TERM
125-
tests_auth_test_CPPFLAGS += -DWOLFSSH_TERM
126-
endif
127-
if BUILD_SHELL
128-
tests_auth_test_CPPFLAGS += -DWOLFSSH_SHELL
129-
endif
130-
if BUILD_AGENT
131-
tests_auth_test_CPPFLAGS += -DWOLFSSH_AGENT
132-
endif
133-
if BUILD_FWD
134-
tests_auth_test_CPPFLAGS += -DWOLFSSH_FWD
135-
endif
136-
if BUILD_CERTS
137-
tests_auth_test_CPPFLAGS += -DWOLFSSH_CERTS
138-
endif
33+
tests_auth_test_CPPFLAGS = -DNO_MAIN_DRIVER $(AM_CPPFLAGS)
13934
tests_auth_test_LDADD = src/libwolfssh.la
14035
tests_auth_test_DEPENDENCIES = src/libwolfssh.la
14136
endif
@@ -145,33 +40,6 @@ tests_kex_test_SOURCES = tests/kex.c tests/kex.h \
14540
examples/client/client.c \
14641
examples/client/common.c \
14742
examples/client/common.h
148-
tests_kex_test_CPPFLAGS = -DNO_MAIN_DRIVER
149-
if BUILD_KEYGEN
150-
tests_kex_test_CPPFLAGS += -DWOLFSSH_KEYGEN
151-
endif
152-
if BUILD_SCP
153-
tests_kex_test_CPPFLAGS += -DWOLFSSH_SCP
154-
endif
155-
if BUILD_SFTP
156-
tests_kex_test_CPPFLAGS += -DWOLFSSH_SFTP
157-
endif
158-
if BUILD_TERM
159-
tests_kex_test_CPPFLAGS += -DWOLFSSH_TERM
160-
endif
161-
if BUILD_SHELL
162-
tests_kex_test_CPPFLAGS += -DWOLFSSH_SHELL
163-
endif
164-
if BUILD_AGENT
165-
tests_kex_test_CPPFLAGS += -DWOLFSSH_AGENT
166-
endif
167-
if BUILD_FWD
168-
tests_kex_test_CPPFLAGS += -DWOLFSSH_FWD
169-
endif
170-
if BUILD_CERTS
171-
tests_kex_test_CPPFLAGS += -DWOLFSSH_CERTS
172-
endif
173-
if BUILD_KEYBOARD_INTERACTIVE
174-
tests_kex_test_CPPFLAGS += -DWOLFSSH_KEYBOARD_INTERACTIVE
175-
endif
43+
tests_kex_test_CPPFLAGS = -DNO_MAIN_DRIVER $(AM_CPPFLAGS)
17644
tests_kex_test_LDADD = src/libwolfssh.la
17745
tests_kex_test_DEPENDENCIES = src/libwolfssh.la

wolfssh/port.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,15 @@ extern "C" {
14901490
#endif
14911491
#endif /* WOLFSSH_SFTP or WOLFSSH_SCP */
14921492

1493+
#ifndef WS_MAYBE_UNUSED
1494+
#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) || \
1495+
defined(__IAR_SYSTEMS_ICC__)
1496+
#define WS_MAYBE_UNUSED __attribute__((unused))
1497+
#else
1498+
#define WS_MAYBE_UNUSED
1499+
#endif
1500+
#endif /* WS_MAYBE_UNUSED */
1501+
14931502
/* setup compiler inlining */
14941503
#ifndef INLINE
14951504
#ifndef NO_INLINE
@@ -1502,10 +1511,10 @@ extern "C" {
15021511
#elif defined(THREADX)
15031512
#define INLINE _Inline
15041513
#else
1505-
#define INLINE
1514+
#define INLINE WS_MAYBE_UNUSED
15061515
#endif
15071516
#else
1508-
#define INLINE
1517+
#define INLINE WS_MAYBE_UNUSED
15091518
#endif
15101519
#endif /* INLINE */
15111520

wolfssh/test.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -962,13 +962,6 @@ static INLINE void ThreadJoin(THREAD_TYPE thread)
962962
(void)wolfSSL_JoinThread(thread);
963963
}
964964

965-
#ifdef WOLFSSL_THREAD_NO_JOIN
966-
static INLINE void ThreadStartNoJoin(THREAD_CB fun, void* args)
967-
{
968-
(void)wolfSSL_NewThreadNoJoin(fun, args);
969-
}
970-
#endif
971-
972965
#else
973966
typedef THREAD_RETURN (WOLFSSH_THREAD *THREAD_FUNC)(void*);
974967

@@ -1068,13 +1061,6 @@ static INLINE void ThreadDetach(THREAD_TYPE thread)
10681061
#endif
10691062
}
10701063

1071-
static INLINE void ThreadStartNoJoin(THREAD_FUNC fun, void* args)
1072-
{
1073-
THREAD_TYPE thread;
1074-
ThreadStart(fun, args, &thread);
1075-
ThreadDetach(thread);
1076-
}
1077-
10781064
#endif /* !WOLFSSH_OLD_THREADING && !WOLFSSH_OLDER_THREADING */
10791065

10801066
#endif /* WOLFSSH_TEST_THREADING */

0 commit comments

Comments
 (0)