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
00e3a0f5
Commit
00e3a0f5
authored
Dec 05, 2017
by
Juergen Kosel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend test_issue373 to test also with QoS 1 and 2
Signed-off-by:
Juergen Kosel
<
juergen.kosel@softing.com
>
parent
c9741998
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
9 deletions
+32
-9
test_issue373.c
test/test_issue373.c
+32
-9
No files found.
test/test_issue373.c
View file @
00e3a0f5
...
...
@@ -54,12 +54,16 @@ struct Options
char
*
proxy_connection
;
/**< connection to proxy */
int
verbose
;
int
test_no
;
unsigned
int
QoS
;
unsigned
int
iterrations
;
}
options
=
{
"iot.eclipse.org:1883"
,
"localhost:1883"
,
0
,
0
,
0
,
5
};
void
getopts
(
int
argc
,
char
**
argv
)
...
...
@@ -227,7 +231,7 @@ int test373_messageArrived(void* context, char* topicName, int topicLen, MQTTAsy
static
char
test373Payload
[]
=
"No one is interested in this payload"
;
int
test373SendPublishMessage
(
MQTTAsync
handle
,
int
id
)
int
test373SendPublishMessage
(
MQTTAsync
handle
,
int
id
,
const
unsigned
int
QoS
)
{
int
rc
=
0
;
MQTTAsync_responseOptions
opts
=
MQTTAsync_responseOptions_initializer
;
...
...
@@ -240,7 +244,7 @@ int test373SendPublishMessage(MQTTAsync handle,int id)
pubmsg
.
payload
=
test373Payload
;
pubmsg
.
payloadlen
=
sizeof
(
test373Payload
);
pubmsg
.
qos
=
0
;
pubmsg
.
qos
=
QoS
;
rc
=
MQTTAsync_sendMessage
(
handle
,
topic
,
&
pubmsg
,
&
opts
);
if
(
rc
==
MQTTASYNC_SUCCESS
)
{
...
...
@@ -264,7 +268,9 @@ int test_373(struct Options options)
char
clientid
[
30
+
sizeof
(
unique
)];
heap_info
*
mqtt_mem
=
0
;
MyLog
(
LOGA_INFO
,
"Running test373 with QoS=%u, iterrations=%u
\n
"
,
options
.
QoS
,
options
.
iterrations
);
sprintf
(
clientid
,
"paho-test373-%s"
,
unique
);
connectCnt
=
0
;
rc
=
MQTTAsync_create
(
&
mqttasyncContext
,
options
.
proxy_connection
,
clientid
,
MQTTCLIENT_PERSISTENCE_NONE
,
NULL
);
...
...
@@ -290,7 +296,7 @@ int test_373(struct Options options)
goto
exit
;
}
MQTTAsync_setTraceLevel
(
MQTTASYNC_TRACE_ERROR
);
while
(
connectCnt
<
10
)
while
(
connectCnt
<
options
.
iterrations
)
{
if
(
!
connected
)
{
...
...
@@ -319,11 +325,11 @@ int test_373(struct Options options)
}
else
{
/* while connected send 100
0
message per second */
/* while connected send 100 message per second */
int
topicId
;
for
(
topicId
=
0
;
topicId
<
100
0
;
topicId
++
)
for
(
topicId
=
0
;
topicId
<
100
;
topicId
++
)
{
rc
=
test373SendPublishMessage
(
mqttasyncContext
,
topicId
);
rc
=
test373SendPublishMessage
(
mqttasyncContext
,
topicId
,
options
.
QoS
);
if
(
rc
!=
MQTTASYNC_SUCCESS
)
break
;
}
MySleep
(
100
);
...
...
@@ -337,6 +343,7 @@ int test_373(struct Options options)
MyLog
(
LOGA_INFO
,
"MQTT mem current %ld, max %ld"
,
mqtt_mem
->
current_size
,
mqtt_mem
->
max_size
);
#endif
MQTTAsync_disconnect
(
mqttasyncContext
,
NULL
);
connected
=
0
;
MyLog
(
LOGA_INFO
,
"PublishCnt %d, FailedCnt %d, Pending %d maxPending %d"
,
goodPublishCnt
,
failedPublishCnt
,
pendingMessageCnt
,
pendingMessageCntMax
);
#if !defined(_WINDOWS)
...
...
@@ -363,6 +370,7 @@ int main(int argc, char** argv)
int
*
numtests
=
&
tests
;
int
rc
=
0
;
int
(
*
tests
[])()
=
{
NULL
,
test_373
};
unsigned
int
QoS
;
sprintf
(
unique
,
"%u"
,
rand
());
MyLog
(
LOGA_INFO
,
"Random prefix/suffix is %s"
,
unique
);
...
...
@@ -374,9 +382,24 @@ int main(int argc, char** argv)
{
/* run all the tests */
for
(
options
.
test_no
=
1
;
options
.
test_no
<
ARRAY_SIZE
(
tests
);
++
options
.
test_no
)
{
failures
=
0
;
MQTTAsync_setTraceLevel
(
MQTTASYNC_TRACE_ERROR
);
rc
+=
tests
[
options
.
test_no
](
options
);
/* return number of failures. 0 = test succeeded */
/* test with QoS 0, 1 and 2 and just 5 iterrations */
for
(
QoS
=
0
;
QoS
<
3
;
QoS
++
)
{
failures
=
0
;
options
.
QoS
=
QoS
;
options
.
iterrations
=
5
;
MQTTAsync_setTraceLevel
(
MQTTASYNC_TRACE_ERROR
);
rc
+=
tests
[
options
.
test_no
](
options
);
/* return number of failures. 0 = test succeeded */
}
if
(
rc
==
0
)
{
/* Test with much more iterrations for QoS = 0 */
failures
=
0
;
options
.
QoS
=
0
;
options
.
iterrations
=
100
;
MQTTAsync_setTraceLevel
(
MQTTASYNC_TRACE_ERROR
);
rc
+=
tests
[
options
.
test_no
](
options
);
/* return number of failures. 0 = test succeeded */
}
}
}
else
...
...
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