~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to lib/snmp/test/snmp_manager_config_test.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
         start_and_stop/1,
49
49
 
50
50
         simple_start_and_stop/1,
51
 
         start_without_mandatory_opts/1,
 
51
         start_without_mandatory_opts1/1,
 
52
         start_without_mandatory_opts2/1,
52
53
         start_with_all_valid_opts/1,
53
54
         start_with_unknown_opts/1,
54
55
         start_with_incorrect_opts/1,
174
175
start_and_stop(suite) ->
175
176
    [
176
177
     simple_start_and_stop,
177
 
     start_without_mandatory_opts,
 
178
     start_without_mandatory_opts1,
 
179
     start_without_mandatory_opts2,
178
180
     start_with_all_valid_opts,
179
181
     start_with_unknown_opts,
180
182
     start_with_incorrect_opts,
215
217
%% ---
216
218
%% 
217
219
 
218
 
start_without_mandatory_opts(suite) -> [];
219
 
start_without_mandatory_opts(doc) ->
220
 
    "Start the snmp manager config process with the \n"
 
220
start_without_mandatory_opts1(suite) -> [];
 
221
start_without_mandatory_opts1(doc) ->
 
222
    "Start the snmp manager config process with some of the \n"
221
223
        "mandatory options missing.";
222
 
start_without_mandatory_opts(Conf) when list(Conf) ->
223
 
    put(tname,swomo),
 
224
start_without_mandatory_opts1(Conf) when list(Conf) ->
 
225
    put(tname,swomo1),
224
226
    put(verbosity,trace),
225
227
    p("start"),
226
228
    process_flag(trap_exit, true),
230
232
    write_manager_conf(ConfDir),
231
233
    
232
234
 
233
 
    %% First set of options (config, but no dir):
 
235
    %% config, but no dir:
234
236
    p("config option, but no dir"),
235
 
    Opts1 = [{priority, normal}, 
236
 
             {config, [{verbosity, trace}, {db_dir, DbDir}]}, {mibs, []}],
237
 
    %% ?line {error, R1} = snmpm_config:start_link(Opts1),
238
 
    ?line {error, {missing_mandatory,dir}} = config_start(Opts1),
239
 
    %% ?line ok = config_stop(),
 
237
    Opts = [{priority, normal}, 
 
238
            {config, [{verbosity, trace}, {db_dir, DbDir}]}, {mibs, []}],
 
239
    ?line {error, {missing_mandatory,dir}} = config_start(Opts),
 
240
 
 
241
    p("done"),
 
242
    ok.
 
243
 
 
244
 
 
245
%% 
 
246
%% ---
 
247
%% 
 
248
 
 
249
start_without_mandatory_opts2(suite) -> [];
 
250
start_without_mandatory_opts2(doc) ->
 
251
    "Start the snmp manager config process with some of the \n"
 
252
        "mandatory options missing.";
 
253
start_without_mandatory_opts2(Conf) when list(Conf) ->
 
254
    put(tname,swomo2),
 
255
    put(verbosity,trace),
 
256
    p("start"),
 
257
    process_flag(trap_exit, true),
 
258
    ConfDir = ?config(manager_conf_dir, Conf),
 
259
 
 
260
    write_manager_conf(ConfDir),
 
261
    
240
262
 
241
263
    %% Second set of options (no config):
242
264
    p("no config option"),
243
 
    Opts2 = [{priority, normal}, 
244
 
             {mibs, []}],
245
 
    ?line {error, {missing_mandatory,config,[dir, db_dir]}} = config_start(Opts2),
246
 
    %% ?line ok = config_stop(),
 
265
    Opts = [{priority, normal}, 
 
266
            {mibs, []}],
 
267
    ?line {error, {missing_mandatory,config,[dir, db_dir]}} = 
 
268
        config_start(Opts),
247
269
 
248
270
    p("done"),
249
271
    ok.
1554
1576
    ?line {error, not_found} = snmpm_config:system_info(kalle),
1555
1577
    
1556
1578
    ?line ok = config_stop(),
 
1579
    await_config_not_running(),
1557
1580
 
1558
1581
    p("done"),
1559
1582
    ok.
1767
1790
    %% --
1768
1791
    p("stop config process"),
1769
1792
    ?line ok = snmpm_config:stop(),
 
1793
    await_config_not_running(),
1770
1794
 
1771
1795
    %% --
1772
1796
    p("done"),
1897
1921
    %% --
1898
1922
    p("stop config process"),
1899
1923
    ?line ok = snmpm_config:stop(),
 
1924
    await_config_not_running(),
1900
1925
 
1901
1926
    %% --
1902
1927
    p("done"),
1997
2022
    %% --
1998
2023
    p("stop config process"),
1999
2024
    ?line ok = snmpm_config:stop(),
 
2025
    await_config_not_running(),
2000
2026
 
2001
2027
    %% --
2002
2028
    p("done"),
2108
2134
    ?line EndVal   = snmpm_config:incr_counter(test_id, IncVal),
2109
2135
 
2110
2136
    ?line ok = snmpm_config:stop(),
 
2137
    await_config_not_running(),
2111
2138
    ok.
2112
2139
 
2113
2140
 
2165
2192
    ?line 10 = loop(10, -1, Stats1Inc),
2166
2193
 
2167
2194
    ?line ok = snmpm_config:stop(),
 
2195
    await_config_not_running(),
2168
2196
    ok.
2169
2197
 
2170
2198
 
2171
2199
loop(0, Acc, _) ->
2172
2200
    Acc;
2173
 
loop(N, _, F) when N > 0, function(F) ->
 
2201
loop(N, _, F) when (N > 0) andalso is_function(F) ->
2174
2202
    Acc = F(),
2175
2203
    loop(N-1, Acc, F).
2176
2204
 
2197
2225
    ConfDir = ?config(manager_conf_dir, Config),
2198
2226
    DbDir   = ?config(manager_db_dir, Config),
2199
2227
 
 
2228
    p("write manager configuration"),
2200
2229
    write_manager_conf(ConfDir),
2201
2230
 
2202
2231
    Opts1 = [{versions, [v1]}, 
2203
2232
             {inform_request_behaviour, user}, 
2204
2233
             {config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
2205
2234
 
 
2235
    p("start manager config"),
2206
2236
    ?line {ok, _Pid1} = snmpm_config:start_link(Opts1),
2207
2237
 
 
2238
    p("get some manager config"),
2208
2239
    {ok, {user, _}} = snmpm_config:system_info(net_if_irb),
2209
2240
 
 
2241
    p("stop manager config"),
2210
2242
    ?line ok = snmpm_config:stop(),
 
2243
    await_config_not_running(),
2211
2244
 
2212
2245
    IRB_TO = 15322, 
2213
2246
    Opts2 = [{versions, [v1]}, 
2214
2247
             {inform_request_behaviour, {user, IRB_TO}}, 
2215
2248
             {config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
2216
2249
 
 
2250
    p("start manager config"),
2217
2251
    ?line {ok, _Pid2} = snmpm_config:start_link(Opts2),
2218
2252
 
 
2253
    p("get some manager config"),
2219
2254
    {ok, {user, IRB_TO}} = snmpm_config:system_info(net_if_irb),
2220
2255
 
 
2256
    p("stop manager config"),
2221
2257
    ?line ok = snmpm_config:stop(),
 
2258
    await_config_not_running(),
 
2259
 
 
2260
    p("done"),
2222
2261
    ok.
2223
2262
 
2224
2263