diff options
Diffstat (limited to 'test/test_data.lua')
| -rw-r--r-- | test/test_data.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test_data.lua b/test/test_data.lua index 74167bf..34021c5 100644 --- a/test/test_data.lua +++ b/test/test_data.lua @@ -309,4 +309,17 @@ assert(data.cpu_model('model name\t: AMD Ryzen 9 7950X3D 16-Core Processor\n') == 'Ryzen 9 7950X3D', 'x3d, got ' .. tostring(data.cpu_model('model name\t: AMD Ryzen 9 7950X3D 16-Core Processor\n'))) +-- === Interface address ==================================================== +-- The fixture uses TEST-NET-1 (192.0.2.0/24, RFC 5737). This repository is +-- public: no real LAN address belongs in it, and no test may assert one. +local addr = data.iface_addr_parse(read('test/fixtures/ip_addr')) +assert(addr == '192.0.2.15', 'lan address, got ' .. tostring(addr)) + +-- A down interface has no inet line. nil, so the card shows '--' rather than +-- a stale or invented address. +assert(data.iface_addr_parse('5: br0: <BROADCAST,MULTICAST> mtu 1500 state DOWN\n') == nil, + 'a down interface gives nil') +assert(data.iface_addr_parse('') == nil, 'empty gives nil') +assert(data.iface_addr_parse(nil) == nil, 'nil gives nil') + print('test_data: all assertions passed') |
