aboutsummaryrefslogtreecommitdiffstats
path: root/test/afb-test/tests/alsacore_APITest.lua
blob: d3401f382cd23fee942acb9719689885b40af243 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
--[[
   Copyright (C) 2019 "IoT.bzh"
   Author Frédéric Marec <frederic.marec@iot.bzh>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


   NOTE: strict mode: every global variables should be prefixed by '_'
--]]

local testPrefix ="alsacore_APITest_"
local devid_keys = {"devid", "wrong_key", nil}
local devid_values = {"hw:0", "wrong_value", 3.141592654, -275, nil}
local sndname_keys = {"sndname", "wrong_key", nil}
local sndname_values = {"HDA-Intel", "wrong_value", 3.141592654, -275, nil}
local prefix_keys = {"prefix", "wrong_key", nil}
local prefix_values = {"4a-hal-generic", "wrong_value", 3.141592654, -275, nil}
local name_keys = { "name", "wrong_key", nil}
local name_values = {"hal-4a-intel", "wrong_value", 3.141592654, -275, nil}
local value_keys = { "value", "wrong_key", nil}
local value_values = {10, "wrong_value", 3.141592654, -275, nil}
local ctl_keys = { "ctl", "wrong_key", nil}
local mode_keys = { "mode", "wrong_key", nil}
local mode_values = {3, "wrong_value", 3.141592654, -275, nil}

local function formatize (arg)
  return tostring(arg):gsub("[^a-zA-Z0-9_]", "_")
end

for _, devid_key in pairs(devid_keys)
do
  for _, devid_value in pairs(devid_values)
  do
    local arg1 = formatize(devid_key).."_"
    local arg2 = formatize(devid_value).."_"

    -- This tests the 'ping' verb of the alsacore API
    _AFT.testVerbStatusSuccess(testPrefix.."ping", "alsacore","ping", {}, nil, nil)

    -- This tests the 'infoget' verb of the alsacore API
    _AFT.testVerbStatusSuccess(testPrefix.."infoget", "alsacore","infoget", {}, nil, nil)

    -- This tests the 'ctlget' verb of the alsacore API
    _AFT.testVerbStatusSuccess(testPrefix.."ctlget", "alsacore","ctlget", {devid = "hw:0"}, nil, nil)
    _AFT.testVerbStatusError(testPrefix.."ctlget", "alsacore","ctlget", {}, nil, nil)

    -- This tests the 'ctlset' verb of the alsacore API
    _AFT.testVerbStatusSuccess(testPrefix.."ctlset", "alsacore","ctlset", {devid = "hw:0"}, nil, nil)
    _AFT.testVerbStatusError(testPrefix.."ctlset", "alsacore","ctlset", {}, nil, nil)

    -- This tests the 'subscribe' verb of the alsacore API
    _AFT.testVerbStatusSuccess(testPrefix.."subscribe", "alsacore","subscribe", {devid = "hw:0"}, nil, nil)
    _AFT.testVerbStatusError(testPrefix.."subscribe", "alsacore","subscribe", {}, nil, nil)

    for _, sndname_key in pairs(sndname_keys)
    do
      for _, sndname_value in pairs(sndname_values)
      do
        local arg3 = formatize(sndname_key).."_"
        local arg4 = formatize(sndname_value).."_"

        -- This tests the 'cardidget' verb of the alsacore API
        _AFT.testVerbStatusSuccess(testPrefix.."cardidget", "alsacore","cardidget", {devid = "hw:0", sndname="HDA-Intel"}, nil, nil)
        _AFT.testVerbStatusSuccess(testPrefix.."cardidget", "alsacore","cardidget", {sndname="HDA-Intel"}, nil, nil)
        _AFT.testVerbStatusError(testPrefix.."cardidget", "alsacore","cardidget", {devid = "hw:0"}, nil, nil)

        for _, name_key in pairs(name_keys)
        do
          for _, name_value in pairs(name_values)
          do
            for _, prefix_key in pairs(prefix_keys)
            do
              for _, prefix_value in pairs(prefix_values)
              do
                for _, value_key in pairs(value_keys)
                do
                  for _, value_value in pairs(value_values)
                  do

                    local arg5 = formatize(name_key).."_"
                    local arg6 = formatize(name_value).."_"
                    local arg7 = formatize(prefix_key).."_"
                    local arg8 = formatize(prefix_value).."_"
                    local arg9 = formatize(value_key).."_"
                    local arg10 = formatize(value_value).."_"

                    -- This tests the 'halregister' verb of the alsacore API
                    _AFT.testVerbStatusSuccess(testPrefix.."halregister", "alsacore","halregister", {devid = "hw:0", prefix = "4a-hal-generic", name = "hal-4a-intel", value = 10, sndname="HDA-Intel"}, nil, nil)
                    _AFT.testVerbStatusSuccess(testPrefix.."halregister", "alsacore","halregister", {prefix = "4a-hal-generic", name = "hal-4a-intel", value = 10, sndname="HDA-Intel"}, nil, nil)
                    _AFT.testVerbStatusError(testPrefix.."halregister", "alsacore","halregister", {devid = "hw:0", prefix = "4a-hal-generic", name = "hal-4a-intel", value = 10}, nil, nil)
                    _AFT.testVerbStatusError(testPrefix.."halregister", "alsacore","halregister", {devid = "hw:0", name = "hal-4a-intel", value = 10, sndname="HDA-Intel"}, nil, nil)

                    -- This tests the 'hallist' verb of the alsacore API
                    _AFT.testVerbStatusSuccess(testPrefix.."hallist", "alsacore","hallist", {devid = "hw:0"}, nil, nil)
                    _AFT.testVerbStatusSuccess(testPrefix.."hallist", "alsacore","hallist", {}, nil, nil)

                    -- This tests the 'pcminfo' verb of the alsacore API
                    _AFT.testVerbStatusError(testPrefix.."pcminfo", "alsacore","pcminfo", {devid = "hw:0", name = "sysdefault:CARD=PCH"}, nil, nil)
                    _AFT.testVerbStatusError(testPrefix.."pcminfo", "alsacore","pcminfo", {name = "sysdefault:CARD=PCH"}, nil, nil)

                    -- This tests the 'ucmquery' verb of the alsacore API
                    _AFT.testVerbStatusError(testPrefix.."ucmquery", "alsacore","ucmquery", {devid = "hw:0", name = "sysdefault"}, nil, nil)

                    -- This tests the 'ucmset' verb of the alsacore API
                    _AFT.testVerbStatusError(testPrefix.."ucmset", "alsacore","ucmset", {devid = "hw:0", name = "sysdefault"}, nil, nil)

                    -- This tests the 'ucmget' verb of the alsacore API
                    _AFT.testVerbStatusError(testPrefix.."ucmget", "alsacore","ucmget", {devid = "hw:0", name = "sysdefault"}, nil, nil)

                    -- This tests the 'ucmreset' verb of the alsacore API
                    _AFT.testVerbStatusError(testPrefix.."ucmreset", "alsacore","ucmreset", {devid = "hw:0", name = "sysdefault"}, nil, nil)

                    -- This tests the 'ucmclose' verb of the alsacore API
                    _AFT.testVerbStatusError(testPrefix.."ucmclose", "alsacore","ucmclose", {devid = "hw:0", name = "sysdefault"}, nil, nil)
                  end
                end
              end
            end
          end
        end
      end
    end
  end
  for _, ctl_key in pairs(ctl_keys)
  do
    for _, mode_key in pairs(mode_keys)
    do
      for _, mode_key in pairs(mode_values)
      do
        local arg5 = formatize(ctl_key).."_"
        local arg7 = formatize(mode_key).."_"
        local arg8 = formatize(mode_value).."_"

        -- This tests the 'addcustomctl' verb of the alsacore API
        _AFT.testVerbStatusError(testPrefix.."addcustomctl", "alsacore","addcustomctl", {devid = "hw:0", ctl = "test-addcustomctl", mode = 3}, nil, nil)

      end
    end
  end
end