diff --git a/.gitlab/tests/cram/scripts/target/pwhm-usp-events.lua b/.gitlab/tests/cram/scripts/target/pwhm-usp-events.lua new file mode 100644 index 0000000000..2c7395d5cf --- /dev/null +++ b/.gitlab/tests/cram/scripts/target/pwhm-usp-events.lua @@ -0,0 +1,32 @@ +#!/usr/bin/lua + +local req_object = arg[1] +local req_event = arg[2] +local lamx = require 'lamx' + +local usp_backend_config = { + usp = { + EndpointID = 'proto::local_controller' + } +} + +lamx.backend.load("/usr/bin/mods/usp/mod-amxb-usp.so") +lamx.backend.push_config(usp_backend_config) +lamx.bus.open("usp:/var/run/pwhm_usp.sock") + +local el = lamx.eventloop.new() +local print_event = function(event, data) + if event == req_event then + print("Event " .. event) + table.dump(data) + el:stop() + end +end + +local sub = lamx.bus.subscribe(req_object, print_event); + +el:start() + +--lamx.bus.ubsubscribe(sub) + +lamx.backend.remove("usp") diff --git a/.gitlab/tests/cram/wifi/wifi-usp.t b/.gitlab/tests/cram/wifi/wifi-usp.t index d9b9a4eda2..fe341b8be9 100644 --- a/.gitlab/tests/cram/wifi/wifi-usp.t +++ b/.gitlab/tests/cram/wifi/wifi-usp.t @@ -1,6 +1,8 @@ Create R alias: $ alias R="${CRAM_REMOTE_COMMAND:-}" + $ alias C="${CRAM_REMOTE_COPY:-}" + $ C ${TESTDIR}/../scripts/target/pwhm-usp-events.lua root@${TARGET_LAN_IP}:/tmp/event.lua 2>/dev/null $ R logger -t cram "Starting pwhm direct USP socket test ..." @@ -14,4 +16,29 @@ Check if there is at least one connected client (should be beerocks processes): $ R "netstat -ap 2>/dev/null | grep 'CONNECTED.*pwhm_usp.sock'| wc -l" [1-9]$ (re) +Test USP events: + + $ R "lua /tmp/event.lua 'Device.WiFi.AccessPoint.1.Enable!' 'dm:object-changed' > /tmp/pwhm_usp_events &" + + $ R "ba-cli WiFi.AccessPoint.1.Enable=1" > /dev/null 2>&1 + + $ sleep 5 + + $ R "cat /tmp/pwhm_usp_events" + Event dm:object-changed + { + object = "Device.WiFi.AccessPoint.1.", + parameters = { + Enable = { + from = "", + to = "true" + } + }, + path = "Device.WiFi.AccessPoint.1." + } + + $ R "ba-cli WiFi.AccessPoint.1.Enable=0" > /dev/null 2>&1 + + $ sleep 5 + $ R logger -t cram "Test finished!"