Skip to content

Commit 9aaa98d

Browse files
committed
init.lua - fixed; update tests; update bootstrap; update readme
1 parent 65a83b7 commit 9aaa98d

File tree

9 files changed

+45
-22
lines changed

9 files changed

+45
-22
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ Key features
4141
$ git clone https://github.com/tarantool/mqtt.git
4242
$ cd mqtt
4343
$ git submodule update --init --recursive
44-
$ cmake .
45-
$ make
44+
$ ./bootstrap.sh
4645
```
4746

4847
[Back to content](#content)

bootstrap.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ mkdir -p build
1111
cd build
1212

1313
cmake \
14-
-DMOSQUITTO_INCLUDE_DIR=$PWD/third_party/mosquitto/lib/mosquitto.h \
15-
-DMOSQUITTO_LIBRARY=$PWD/third_party/mosquitto/build/lib/libmosquitto.so \
14+
-DMOSQUITTO_INCLUDE_DIR=$PWD/../third_party/mosquitto/lib/mosquitto.h \
15+
-DMOSQUITTO_LIBRARY=$PWD/../third_party/mosquitto/build/lib/libmosquitto.so \
1616
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
1717
../
1818

cmake/FindMosquitto.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ endif()
1212
if (NOT MOSQUITTO_LIBRARY)
1313
find_library(
1414
MOSQUITTO_LIBRARY
15-
NAMES libmosquitto libmosquitto.so.1 libmosquitto.dylid)
15+
NAMES libmosquitto libmosquitto.so* libmosquitto.dylid)
1616
endif()
1717

1818
include(FindPackageHandleStandardArgs)

mqtt-0.1.rockspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ external_dependencies = {
2222
build = {
2323
type = "cmake",
2424
}
25-

mqtt/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
add_library(driver SHARED driver.c)
2+
message(STATUS ${MOSQUITTO_LIBRARIES})
23
target_link_libraries(driver ${MOSQUITTO_LIBRARIES} -rdynamic)
34
set_target_properties(driver PROPERTIES PREFIX "" OUTPUT_NAME "driver")
45
install(TARGETS driver LIBRARY DESTINATION ${TARANTOOL_INSTALL_LIBDIR}/mqtt)

mqtt/init.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ mqtt_mt = {
202202
-- See
203203
-- <connect> <opts.auto_reconect>
204204
--
205-
reconnect = function()
205+
reconnect = function(self)
206206
return self.mqtt:reconnect()
207207
end,
208208

@@ -271,7 +271,7 @@ mqtt_mt = {
271271
-- true or false, emsg
272272
--
273273
will_set = function(self, topic, payload, qos, retain)
274-
return mqtt:will_set(topic, payload, qos, retain)
274+
return self.mqtt:will_set(topic, payload, qos, retain)
275275
end,
276276

277277
--
@@ -283,7 +283,7 @@ mqtt_mt = {
283283
-- true or false, emsg
284284
--
285285
will_clear = function(self)
286-
return mqtt:will_clear()
286+
return self.mqtt:will_clear()
287287
end,
288288

289289
--
@@ -305,7 +305,7 @@ mqtt_mt = {
305305
-- true or false, emsg
306306
--
307307
login_set = function(self, username, password)
308-
return mqtt:login_set(username, password)
308+
return self.mqtt:login_set(username, password)
309309
end,
310310

311311
--
@@ -327,7 +327,7 @@ mqtt_mt = {
327327
-- true or false, emsg
328328
--
329329
tls_insecure_set = function(self, value)
330-
return mqtt:tls_insecure_set(value)
330+
return self.mqtt:tls_insecure_set(value)
331331
end,
332332

333333
--
@@ -364,7 +364,7 @@ mqtt_mt = {
364364
-- <insecure_set>
365365
--
366366
tls_set = function(self, cafile, capath, certfile, keyfile)
367-
return mqtt:tls_set(cafile, capath, certfile, keyfile)
367+
return self.mqtt:tls_set(cafile, capath, certfile, keyfile)
368368
end,
369369

370370
--

test/api.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package.preload['mqtt.driver'] = './mqtt/driver.so'
2+
3+
local os = require('os')
4+
5+
local mqtt = require('mqtt')
6+
7+
conn = mqtt.new()
8+
9+
conn:connect({host="127.0.0.1", port=1883})
10+
conn:reconnect()
11+
conn:subscribe('channel/#')
12+
conn:unsubscribe('some/topic')
13+
conn:publish('channel2/messages', TIME, 0, false)
14+
conn:will_set('some/topic', 'str', 0, false)
15+
conn:will_clear()
16+
conn:login_set('user', 'password')
17+
conn:tls_insecure_set(false)
18+
--conn:tls_set('file', 'path', 'cert', 'key')
19+
conn:on_connect(function() end)
20+
conn:on_publish(function() end)
21+
conn:on_subscribe(function() end)
22+
conn:on_unsubscribe(function() end)
23+
conn:on_disconnect(function() end)
24+
conn:on_message(function() end)
25+
26+
os.exit(0)

test/run_all.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/bin/bash
22
set -e
3-
mkdir -p $PWD/tests/out
3+
rm -Rf $PWD/test/out
4+
mkdir -p $PWD/test/out
45
echo '[+] Testing ...'
5-
[ ! -f $PWD/mqtt/driver.so ] && \
6-
ln -s $PWD/build/mqtt/driver.so $PWD/mqtt/driver.so
7-
for test_case in `ls $PWD/tests | grep -e '$*\.lua'`; do
6+
rm -Rf $PWD/mqtt/driver.so
7+
ln -s $PWD/build/mqtt/driver.so $PWD/mqtt/driver.so
8+
for test_case in `ls $PWD/test | grep -e '$*\.lua'`; do
89
echo "[+] Case: $test_case"
9-
$PWD/tests/$test_case 2> $PWD/tests/out/$test_case.out
10+
tarantool $PWD/test/$test_case 2> $PWD/test/out/$test_case.out
1011
echo "[+] Case: $test_case -- OK"
1112
done

third_party/bootstrap.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
cd mosquitto
44
mkdir -p build
55
cd build
6-
cmake \
7-
-DCMAKE_BUILD_TYPE=RelWithDebInfo
8-
-DWITH_SRV=off \
9-
../
6+
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SRV=off ../
7+
make libmosquitto
108
cd -
11-
make libmosquitto -C build

0 commit comments

Comments
 (0)