summaryrefslogtreecommitdiffstats
path: root/tests/cram/test_ucilua.t
blob: c7c9a93a91ab9fa14a500e18127df6901800d8b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
set LUA_CPATH and ucilua for convenience:

  $ export LC_ALL=C
  $ [ -n "$UCI_LUA" ] && export LUA_CPATH="$(dirname "$UCI_LUA")/?.so"
  $ alias ucilua="valgrind --quiet --leak-check=full lua -luci"

check available methods:

  $ ucilua -e 'table.foreach(uci,function(m) print(m) end)'
  add_history
  add_delta
  close
  set_confdir
  save
  cursor
  get_all
  foreach
  __gc
  set_savedir
  revert
  delete
  reorder
  set
  get_conf2dir
  get_savedir
  changes
  set_conf2dir
  get_confdir
  list_configs
  commit
  unload
  rename
  add
  load
  get

run basic Lua tests:

  $ cp -R "$TESTDIR/config" .
  $ export CONFIG_DIR=$(pwd)/config
  $ ucilua $TESTDIR/lua/basic.lua
  ---------------
  enabled: off
  .anonymous: false
  ipaddr: 2.3.4.5
  .index: 2
  .name: lan
  test: 123
  .type: interface
  ifname: eth0
  proto: static
  ---------------
  .name: wan
  .type: interface
  .index: 3
  enabled: on
  ifname: eth1
  proto: dhcp
  .anonymous: false
  aliases: c d
  nil\tuci: Parse error (EOF with unterminated ') at line 1, byte 18 (esc)