Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
paho.mqtt.c
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eclipse
paho.mqtt.c
Commits
037e0068
Commit
037e0068
authored
Aug 21, 2013
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test reporting for all tests
parent
342e70ff
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
135 deletions
+133
-135
build.xml
build.xml
+1
-1
SSLSocket.c
src/SSLSocket.c
+13
-13
test1.c
test/test1.c
+23
-41
test3.c
test/test3.c
+2
-2
test4.c
test/test4.c
+19
-55
test5.c
test/test5.c
+75
-23
No files found.
build.xml
View file @
037e0068
...
@@ -161,7 +161,7 @@
...
@@ -161,7 +161,7 @@
<target
name=
"test"
>
<target
name=
"test"
>
<foreach
target=
"runAtest"
param=
"aTest"
list=
"test1,test4"
/>
<foreach
target=
"runAtest"
param=
"aTest"
list=
"test1,test4"
/>
<foreach
target=
"runSSLtest"
param=
"aTest"
list=
"test3"
/>
<foreach
target=
"runSSLtest"
param=
"aTest"
list=
"test3
,test5
"
/>
</target>
</target>
<target
name=
"runAtest"
>
<target
name=
"runAtest"
>
...
...
src/SSLSocket.c
View file @
037e0068
...
@@ -456,21 +456,21 @@ int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts)
...
@@ -456,21 +456,21 @@ int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts)
if
(
net
->
ctx
!=
NULL
||
(
rc
=
SSLSocket_createContext
(
net
,
opts
))
==
1
)
if
(
net
->
ctx
!=
NULL
||
(
rc
=
SSLSocket_createContext
(
net
,
opts
))
==
1
)
{
{
int
i
;
int
i
;
SSL_CTX_set_info_callback
(
net
->
ctx
,
SSL_CTX_info_callback
);
SSL_CTX_set_info_callback
(
net
->
ctx
,
SSL_CTX_info_callback
);
if
(
opts
->
enableServerCertAuth
)
if
(
opts
->
enableServerCertAuth
)
SSL_CTX_set_verify
(
net
->
ctx
,
SSL_VERIFY_PEER
,
NULL
);
SSL_CTX_set_verify
(
net
->
ctx
,
SSL_VERIFY_PEER
,
NULL
);
net
->
ssl
=
SSL_new
(
net
->
ctx
);
net
->
ssl
=
SSL_new
(
net
->
ctx
);
/* Log all ciphers available to the SSL sessions (loaded in ctx) */
/* Log all ciphers available to the SSL sessions (loaded in ctx) */
for
(
i
=
0
;
;
i
++
)
for
(
i
=
0
;
;
i
++
)
{
{
const
char
*
cipher
=
SSL_get_cipher_list
(
net
->
ssl
,
i
);
const
char
*
cipher
=
SSL_get_cipher_list
(
net
->
ssl
,
i
);
if
(
cipher
==
NULL
)
break
;
if
(
cipher
==
NULL
)
Log
(
TRACE_MIN
,
1
,
"SSL cipher available: %d:%s"
,
i
,
cipher
)
;
break
;
}
Log
(
TRACE_MIN
,
1
,
"SSL cipher available: %d:%s"
,
i
,
cipher
);
}
if
((
rc
=
SSL_set_fd
(
net
->
ssl
,
net
->
socket
))
!=
1
)
if
((
rc
=
SSL_set_fd
(
net
->
ssl
,
net
->
socket
))
!=
1
)
SSLSocket_error
(
"SSL_set_fd"
,
net
->
ssl
,
net
->
socket
,
rc
);
SSLSocket_error
(
"SSL_set_fd"
,
net
->
ssl
,
net
->
socket
,
rc
);
}
}
...
@@ -486,11 +486,11 @@ int SSLSocket_connect(SSL* ssl, int sock)
...
@@ -486,11 +486,11 @@ int SSLSocket_connect(SSL* ssl, int sock)
FUNC_ENTRY
;
FUNC_ENTRY
;
rc
=
SSL_connect
(
ssl
);
rc
=
SSL_connect
(
ssl
);
if
(
rc
!=
1
)
if
(
rc
!=
1
)
{
{
int
error
;
int
error
;
error
=
SSLSocket_error
(
"SSL_connect"
,
ssl
,
sock
,
rc
);
error
=
SSLSocket_error
(
"SSL_connect"
,
ssl
,
sock
,
rc
);
if
(
error
==
SSL_FATAL
)
if
(
error
==
SSL_FATAL
)
rc
=
error
;
rc
=
error
;
}
}
...
...
test/test1.c
View file @
037e0068
...
@@ -217,6 +217,21 @@ START_TIME_TYPE global_start_time;
...
@@ -217,6 +217,21 @@ START_TIME_TYPE global_start_time;
char
output
[
3000
];
char
output
[
3000
];
char
*
cur_output
=
output
;
char
*
cur_output
=
output
;
void
write_test_result
()
{
long
duration
=
elapsed
(
global_start_time
);
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
}
void
myassert
(
char
*
filename
,
int
lineno
,
char
*
description
,
int
value
,
char
*
format
,
...)
void
myassert
(
char
*
filename
,
int
lineno
,
char
*
description
,
int
value
,
char
*
format
,
...)
{
{
++
tests
;
++
tests
;
...
@@ -377,14 +392,7 @@ int test1(struct Options options)
...
@@ -377,14 +392,7 @@ int test1(struct Options options)
exit:
exit:
MyLog
(
LOGA_INFO
,
"TEST1: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"TEST1: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d
\"
>
\n
"
,
elapsed
(
global_start_time
)
/
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -540,14 +548,7 @@ int test2(struct Options options)
...
@@ -540,14 +548,7 @@ int test2(struct Options options)
exit:
exit:
MyLog
(
LOGA_INFO
,
"%s: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"%s: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
testname
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
testname
,
tests
,
failures
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d
\"
>
\n
"
,
elapsed
(
global_start_time
)
/
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -627,14 +628,7 @@ int test3(struct Options options)
...
@@ -627,14 +628,7 @@ int test3(struct Options options)
/* TODO - unused - remove ? exit: */
/* TODO - unused - remove ? exit: */
MyLog
(
LOGA_INFO
,
"%s: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"%s: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
testname
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
testname
,
tests
,
failures
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d
\"
>
\n
"
,
elapsed
(
global_start_time
)
/
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -875,14 +869,7 @@ int test5(struct Options options)
...
@@ -875,14 +869,7 @@ int test5(struct Options options)
exit:
exit:
MyLog
(
LOGA_INFO
,
"%s: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"%s: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
testname
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
testname
,
tests
,
failures
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d
\"
>
\n
"
,
elapsed
(
global_start_time
)
/
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -1113,14 +1100,7 @@ int test6(struct Options options)
...
@@ -1113,14 +1100,7 @@ int test6(struct Options options)
exit:
exit:
MyLog
(
LOGA_INFO
,
"%s: test %s. %d tests run, %d failures.
\n
"
,
MyLog
(
LOGA_INFO
,
"%s: test %s. %d tests run, %d failures.
\n
"
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
testname
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
testname
,
tests
,
failures
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d
\"
>
\n
"
,
elapsed
(
global_start_time
)
/
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -1129,10 +1109,12 @@ int main(int argc, char** argv)
...
@@ -1129,10 +1109,12 @@ int main(int argc, char** argv)
int
rc
=
0
;
int
rc
=
0
;
int
(
*
tests
[])()
=
{
NULL
,
test1
,
test2
,
test3
,
test4
,
test5
,
test6
};
int
(
*
tests
[])()
=
{
NULL
,
test1
,
test2
,
test3
,
test4
,
test5
,
test6
};
xml
=
fopen
(
"TEST-test1.xml"
,
"w"
);
xml
=
fopen
(
"TEST-test1.xml"
,
"w"
);
fprintf
(
xml
,
"<testsuite name=
\"
test1
\"
tests=
\"
%d
\"
>
\n
"
,
ARRAY_SIZE
(
tests
)
-
1
);
fprintf
(
xml
,
"<testsuite name=
\"
test1
\"
tests=
\"
%d
\"
>
\n
"
,
ARRAY_SIZE
(
tests
)
-
1
);
setenv
(
"MQTT_C_CLIENT_TRACE"
,
"ON"
,
1
);
setenv
(
"MQTT_C_CLIENT_TRACE_LEVEL"
,
"ERROR"
,
1
);
getopts
(
argc
,
argv
);
getopts
(
argc
,
argv
);
if
(
options
.
test_no
==
0
)
if
(
options
.
test_no
==
0
)
...
...
test/test3.c
View file @
037e0068
...
@@ -352,12 +352,12 @@ FILE* xml;
...
@@ -352,12 +352,12 @@ FILE* xml;
START_TIME_TYPE
global_start_time
;
START_TIME_TYPE
global_start_time
;
char
output
[
3000
];
char
output
[
3000
];
char
*
cur_output
=
output
;
char
*
cur_output
=
output
;
long
duration
;
void
write_test_result
()
void
write_test_result
()
{
{
duration
=
elapsed
(
global_start_time
);
long
duration
=
elapsed
(
global_start_time
);
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
if
(
cur_output
!=
output
)
if
(
cur_output
!=
output
)
{
{
...
...
test/test4.c
View file @
037e0068
...
@@ -191,15 +191,9 @@ long elapsed(START_TIME_TYPE start_time)
...
@@ -191,15 +191,9 @@ long elapsed(START_TIME_TYPE start_time)
}
}
#endif
#endif
START_TIME_TYPE
global_start_time
;
long
duration
;
#define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d)
#define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d)
#define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e)
#define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e)
int
tests
=
0
;
int
tests
=
0
;
int
failures
=
0
;
int
failures
=
0
;
FILE
*
xml
;
FILE
*
xml
;
...
@@ -207,6 +201,19 @@ START_TIME_TYPE global_start_time;
...
@@ -207,6 +201,19 @@ START_TIME_TYPE global_start_time;
char
output
[
3000
];
char
output
[
3000
];
char
*
cur_output
=
output
;
char
*
cur_output
=
output
;
void
write_test_result
()
{
long
duration
=
elapsed
(
global_start_time
);
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
}
void
myassert
(
char
*
filename
,
int
lineno
,
char
*
description
,
int
value
,
char
*
format
,
...)
void
myassert
(
char
*
filename
,
int
lineno
,
char
*
description
,
int
value
,
char
*
format
,
...)
{
{
++
tests
;
++
tests
;
...
@@ -388,15 +395,7 @@ int test1(struct Options options)
...
@@ -388,15 +395,7 @@ int test1(struct Options options)
exit:
exit:
MyLog
(
LOGA_INFO
,
"TEST1: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"TEST1: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
write_test_result
();
duration
=
elapsed
(
global_start_time
);
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -491,14 +490,7 @@ exit:
...
@@ -491,14 +490,7 @@ exit:
MyLog
(
LOGA_INFO
,
"TEST2: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"TEST2: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
duration
=
elapsed
(
global_start_time
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -710,14 +702,7 @@ int test3(struct Options options)
...
@@ -710,14 +702,7 @@ int test3(struct Options options)
exit:
exit:
MyLog
(
LOGA_INFO
,
"TEST3: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"TEST3: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
duration
=
elapsed
(
global_start_time
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -901,14 +886,7 @@ int test4(struct Options options)
...
@@ -901,14 +886,7 @@ int test4(struct Options options)
exit:
exit:
MyLog
(
LOGA_INFO
,
"TEST4: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"TEST4: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
duration
=
elapsed
(
global_start_time
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -993,14 +971,7 @@ int test5(struct Options options)
...
@@ -993,14 +971,7 @@ int test5(struct Options options)
exit:
exit:
MyLog
(
LOGA_INFO
,
"TEST5: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"TEST5: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
duration
=
elapsed
(
global_start_time
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
@@ -1088,14 +1059,7 @@ int test6(struct Options options)
...
@@ -1088,14 +1059,7 @@ int test6(struct Options options)
exit:
exit:
MyLog
(
LOGA_INFO
,
"TEST6: test %s. %d tests run, %d failures."
,
MyLog
(
LOGA_INFO
,
"TEST6: test %s. %d tests run, %d failures."
,
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
(
failures
==
0
)
?
"passed"
:
"failed"
,
tests
,
failures
);
duration
=
elapsed
(
global_start_time
);
write_test_result
();
fprintf
(
xml
,
" time=
\"
%d.%.3d
\"
>
\n
"
,
duration
/
1000
,
duration
%
1000
);
if
(
cur_output
!=
output
)
{
fprintf
(
xml
,
output
);
cur_output
=
output
;
}
fprintf
(
xml
,
"</testcase>
\n
"
);
return
failures
;
return
failures
;
}
}
...
...
test/test5.c
View file @
037e0068
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment