mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-07-01 05:31:23 +02:00
40 lines
1.1 KiB
Lua
40 lines
1.1 KiB
Lua
|
local wlanconfig = require("network.wlanconfig")
|
||
|
|
||
|
local M = {
|
||
|
_is_test = true,
|
||
|
_skip = {},
|
||
|
_wifibox_only = {}
|
||
|
}
|
||
|
|
||
|
local function captureCommandOutput(cmd)
|
||
|
local f = assert(io.popen(cmd, 'r'))
|
||
|
return assert(f:read('*all'))
|
||
|
end
|
||
|
|
||
|
function M._setup()
|
||
|
wlanconfig.init()
|
||
|
end
|
||
|
|
||
|
function M.test_getMacAddress()
|
||
|
local reportedMac = wlanconfig.getMacAddress()
|
||
|
local output = captureCommandOutput('ifconfig wlan0')
|
||
|
local actualMac = output:match('HWaddr (%w%w:%w%w:%w%w:%w%w:%w%w:%w%w)'):gsub(':', ''):upper()
|
||
|
|
||
|
assert(reportedMac == actualMac)
|
||
|
end
|
||
|
|
||
|
function M.test_getSubstitutedSsid()
|
||
|
local mac = wlanconfig.getMacAddress()
|
||
|
local macTail = mac:sub(7)
|
||
|
|
||
|
local expected1 = 'pre' .. macTail .. 'post'
|
||
|
local expected2 = 'pre' .. macTail .. 'post-cache-test'
|
||
|
|
||
|
assert(wlanconfig.getSubstitutedSsid('pre%%MAC_ADDR_TAIL%%post') == expected1)
|
||
|
assert(wlanconfig.getSubstitutedSsid('pre%%MAC_ADDR_TAIL%%post-cache-test') == expected2)
|
||
|
assert(wlanconfig.getSubstitutedSsid('pre%%MAC_ADDR_TAIL%%post') == expected1)
|
||
|
assert(wlanconfig.getSubstitutedSsid('pre%%MAC_ADDR_TAIL%%post') == expected1)
|
||
|
end
|
||
|
|
||
|
return M
|