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
2c108549
Commit
2c108549
authored
Mar 14, 2014
by
Ian Craggs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MQTT 3.1.1 changes in tests and synchronous client
parent
5ea74966
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
18 deletions
+53
-18
MQTTClient.c
src/MQTTClient.c
+2
-1
MQTTClient.h
src/MQTTClient.h
+1
-1
test1.c
test/test1.c
+36
-6
test4.c
test/test4.c
+14
-10
No files found.
src/MQTTClient.c
View file @
2c108549
...
...
@@ -1030,7 +1030,8 @@ int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions* options)
}
if
(
strncmp
(
options
->
struct_id
,
"MQTC"
,
4
)
!=
0
||
(
options
->
struct_version
!=
0
&&
options
->
struct_version
!=
1
&&
options
->
struct_version
!=
2
))
(
options
->
struct_version
!=
0
&&
options
->
struct_version
!=
1
&&
options
->
struct_version
!=
2
&&
options
->
struct_version
!=
3
))
{
rc
=
MQTTCLIENT_BAD_STRUCTURE
;
goto
exit
;
...
...
src/MQTTClient.h
View file @
2c108549
...
...
@@ -607,7 +607,7 @@ typedef struct
int
MQTTVersion
;
}
MQTTClient_connectOptions
;
#define MQTTClient_connectOptions_initializer { {'M', 'Q', 'T', 'C'},
2
, 60, 1, 1, NULL, NULL, NULL, 30, 20, NULL, 0, NULL, 0}
#define MQTTClient_connectOptions_initializer { {'M', 'Q', 'T', 'C'},
3
, 60, 1, 1, NULL, NULL, NULL, 30, 20, NULL, 0, NULL, 0}
/**
* MQTTClient_libraryInfo is used to store details relating to the currently used
...
...
test/test1.c
View file @
2c108549
...
...
@@ -64,6 +64,8 @@ struct Options
int
hacount
;
int
verbose
;
int
test_no
;
int
MQTTVersion
;
int
iterations
;
}
options
=
{
"tcp://m2m.eclipse.org:1883"
,
...
...
@@ -71,6 +73,8 @@ struct Options
0
,
0
,
0
,
MQTTVERSION_DEFAULT
,
1
,
};
void
getopts
(
int
argc
,
char
**
argv
)
...
...
@@ -114,6 +118,23 @@ void getopts(int argc, char** argv)
else
usage
();
}
else
if
(
strcmp
(
argv
[
count
],
"--MQTTversion"
)
==
0
)
{
if
(
++
count
<
argc
)
{
options
.
MQTTVersion
=
atoi
(
argv
[
count
]);
printf
(
"setting MQTT version to %d
\n
"
,
options
.
MQTTVersion
);
}
else
usage
();
}
else
if
(
strcmp
(
argv
[
count
],
"--iterations"
)
==
0
)
{
if
(
++
count
<
argc
)
options
.
iterations
=
atoi
(
argv
[
count
]);
else
usage
();
}
else
if
(
strcmp
(
argv
[
count
],
"--verbose"
)
==
0
)
{
options
.
verbose
=
1
;
...
...
@@ -353,6 +374,7 @@ int test1(struct Options options)
opts
.
cleansession
=
1
;
opts
.
username
=
"testuser"
;
opts
.
password
=
"testpassword"
;
opts
.
MQTTVersion
=
options
.
MQTTVersion
;
if
(
options
.
haconnections
!=
NULL
)
{
opts
.
serverURIs
=
options
.
haconnections
;
...
...
@@ -519,6 +541,7 @@ int test2(struct Options options)
opts
.
keepAliveInterval
=
20
;
opts
.
cleansession
=
1
;
opts
.
MQTTVersion
=
options
.
MQTTVersion
;
if
(
options
.
haconnections
!=
NULL
)
{
opts
.
serverURIs
=
options
.
haconnections
;
...
...
@@ -667,6 +690,7 @@ int test4_run(int qos)
opts
.
keepAliveInterval
=
20
;
opts
.
reliable
=
0
;
opts
.
MQTTVersion
=
options
.
MQTTVersion
;
if
(
options
.
haconnections
!=
NULL
)
{
opts
.
serverURIs
=
options
.
haconnections
;
...
...
@@ -837,6 +861,7 @@ int test5(struct Options options)
opts
.
keepAliveInterval
=
20
;
opts
.
cleansession
=
0
;
opts
.
reliable
=
0
;
opts
.
MQTTVersion
=
options
.
MQTTVersion
;
if
(
options
.
haconnections
!=
NULL
)
{
opts
.
serverURIs
=
options
.
haconnections
;
...
...
@@ -1013,6 +1038,7 @@ int test6(struct Options options)
opts
.
keepAliveInterval
=
2
;
opts
.
cleansession
=
1
;
opts
.
MQTTVersion
=
options
.
MQTTVersion
;
opts
.
will
=
&
wopts
;
opts
.
will
->
message
=
test6_will_message
;
opts
.
will
->
qos
=
1
;
...
...
@@ -1103,6 +1129,7 @@ int main(int argc, char** argv)
{
int
rc
=
0
;
int
(
*
tests
[])()
=
{
NULL
,
test1
,
test2
,
test3
,
test4
,
test5
,
test6
};
int
i
;
xml
=
fopen
(
"TEST-test1.xml"
,
"w"
);
fprintf
(
xml
,
"<testsuite name=
\"
test1
\"
tests=
\"
%d
\"
>
\n
"
,
(
int
)(
ARRAY_SIZE
(
tests
)
-
1
));
...
...
@@ -1112,13 +1139,16 @@ int main(int argc, char** argv)
getopts
(
argc
,
argv
);
if
(
options
.
test_no
==
0
)
{
/* run all the tests */
for
(
options
.
test_no
=
1
;
options
.
test_no
<
ARRAY_SIZE
(
tests
);
++
options
.
test_no
)
rc
+=
tests
[
options
.
test_no
](
options
);
/* return number of failures. 0 = test succeeded */
for
(
i
=
0
;
i
<
options
.
iterations
;
++
i
)
{
if
(
options
.
test_no
==
0
)
{
/* run all the tests */
for
(
options
.
test_no
=
1
;
options
.
test_no
<
ARRAY_SIZE
(
tests
);
++
options
.
test_no
)
rc
+=
tests
[
options
.
test_no
](
options
);
/* return number of failures. 0 = test succeeded */
}
else
rc
=
tests
[
options
.
test_no
](
options
);
/* run just the selected test */
}
else
rc
=
tests
[
options
.
test_no
](
options
);
/* run just the selected test */
if
(
rc
==
0
)
MyLog
(
LOGA_INFO
,
"verdict pass"
);
...
...
test/test4.c
View file @
2c108549
...
...
@@ -1150,6 +1150,7 @@ int main(int argc, char** argv)
int
rc
=
0
;
int
(
*
tests
[])()
=
{
NULL
,
test1
,
test2
,
test3
,
test4
,
test5
,
test6
};
/* indexed starting from 1 */
MQTTAsync_nameValue
*
info
;
int
i
;
xml
=
fopen
(
"TEST-test4.xml"
,
"w"
);
fprintf
(
xml
,
"<testsuite name=
\"
test4
\"
tests=
\"
%d
\"
>
\n
"
,
(
int
)(
ARRAY_SIZE
(
tests
))
-
1
);
...
...
@@ -1165,20 +1166,23 @@ int main(int argc, char** argv)
info
++
;
}
if
(
options
.
test_no
==
-
1
)
{
/* run all the tests */
for
(
options
.
test_no
=
1
;
options
.
test_no
<
ARRAY_SIZE
(
tests
);
++
options
.
test_no
)
for
(
i
=
0
;
i
<
options
.
iterations
;
++
i
)
{
if
(
options
.
test_no
==
-
1
)
{
/* 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 */
}
}
else
{
failures
=
0
;
MQTTAsync_setTraceLevel
(
MQTTASYNC_TRACE_ERROR
);
rc
+=
tests
[
options
.
test_no
](
options
);
/* return number of failures. 0 = test succeeded */
rc
=
tests
[
options
.
test_no
](
options
);
/* run just the selected test */
}
}
else
{
MQTTAsync_setTraceLevel
(
MQTTASYNC_TRACE_ERROR
);
rc
=
tests
[
options
.
test_no
](
options
);
/* run just the selected test */
}
if
(
rc
==
0
)
MyLog
(
LOGA_INFO
,
"verdict pass"
);
...
...
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