aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/test/snmp_manager_config_test.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2011-03-02 16:23:04 +0100
committerMicael Karlberg <[email protected]>2011-03-02 16:23:04 +0100
commit24c45e5d18eafbc8fc85b0c49622980dac3f6fe2 (patch)
tree21e3e5759a65c3cae00aa4be8d4c1b461bd3af0d /lib/snmp/test/snmp_manager_config_test.erl
parent455ff4bc78f94c997d43a46fd2619b7d683c10c5 (diff)
downloadotp-24c45e5d18eafbc8fc85b0c49622980dac3f6fe2.tar.gz
otp-24c45e5d18eafbc8fc85b0c49622980dac3f6fe2.tar.bz2
otp-24c45e5d18eafbc8fc85b0c49622980dac3f6fe2.zip
* On some windows machines dirs seem to vanish sometime between
the call to init_per_testcase (when they are created) and the call to the actual test case (when they are used). * Try to handle systems where crypto is not built better. This *is* handled by application, but the test case snmp_app_test:undef_funcs could do a better job (which it hopefully does now :).
Diffstat (limited to 'lib/snmp/test/snmp_manager_config_test.erl')
-rw-r--r--lib/snmp/test/snmp_manager_config_test.erl105
1 files changed, 69 insertions, 36 deletions
diff --git a/lib/snmp/test/snmp_manager_config_test.erl b/lib/snmp/test/snmp_manager_config_test.erl
index a72dd0cc22..e38a99d413 100644
--- a/lib/snmp/test/snmp_manager_config_test.erl
+++ b/lib/snmp/test/snmp_manager_config_test.erl
@@ -169,36 +169,41 @@ all() ->
groups() ->
[{start_and_stop, [],
- [simple_start_and_stop, start_without_mandatory_opts1,
- start_without_mandatory_opts2,
- start_with_all_valid_opts, start_with_unknown_opts,
- start_with_incorrect_opts,
- start_with_invalid_manager_conf_file1,
- start_with_invalid_users_conf_file1,
- start_with_invalid_agents_conf_file1,
- start_with_invalid_usm_conf_file1]},
- {normal_op, [],
- [{group, system}, {group, agents}, {group, users},
- {group, usm_users}, {group, counter},
- {group, stats_counter}]},
- {system, [], [simple_system_op]},
- {users, [],
- [register_user_using_file, register_user_using_function,
- register_user_failed_using_function1]},
- {agents, [],
- [register_agent_using_file,
- register_agent_using_function,
- register_agent_failed_using_function1]},
- {usm_users, [],
- [register_usm_user_using_file,
- register_usm_user_using_function,
- register_usm_user_failed_using_function1,
- update_usm_user_info]},
- {counter, [], [create_and_increment]},
- {stats_counter, [], [stats_create_and_increment]},
- {tickets, [], [otp_7219, {group, otp_8395}]},
- {otp_8395, [],
- [otp_8395_1, otp_8395_2, otp_8395_3, otp_8395_4]}].
+ [simple_start_and_stop,
+ start_without_mandatory_opts1,
+ start_without_mandatory_opts2,
+ start_with_all_valid_opts, start_with_unknown_opts,
+ start_with_incorrect_opts,
+ start_with_invalid_manager_conf_file1,
+ start_with_invalid_users_conf_file1,
+ start_with_invalid_agents_conf_file1,
+ start_with_invalid_usm_conf_file1]},
+ {normal_op, [],
+ [{group, system},
+ {group, agents},
+ {group, users},
+ {group, usm_users},
+ {group, counter},
+ {group, stats_counter}]},
+ {system, [], [simple_system_op]},
+ {users, [],
+ [register_user_using_file,
+ register_user_using_function,
+ register_user_failed_using_function1]},
+ {agents, [],
+ [register_agent_using_file,
+ register_agent_using_function,
+ register_agent_failed_using_function1]},
+ {usm_users, [],
+ [register_usm_user_using_file,
+ register_usm_user_using_function,
+ register_usm_user_failed_using_function1,
+ update_usm_user_info]},
+ {counter, [], [create_and_increment]},
+ {stats_counter, [], [stats_create_and_increment]},
+ {tickets, [], [otp_7219, {group, otp_8395}]},
+ {otp_8395, [],
+ [otp_8395_1, otp_8395_2, otp_8395_3, otp_8395_4]}].
init_per_group(_GroupName, Config) ->
Config.
@@ -816,7 +821,10 @@ start_with_invalid_users_conf_file1(Conf) when is_list(Conf) ->
p("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
- DbDir = ?config(manager_db_dir, Conf),
+ DbDir = ?config(manager_db_dir, Conf),
+
+ verify_dir_existing(conf, ConfDir),
+ verify_dir_existing(db, DbDir),
Opts = [{versions, [v1]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
@@ -917,7 +925,10 @@ start_with_invalid_agents_conf_file1(Conf) when is_list(Conf) ->
p("start"),
process_flag(trap_exit, true),
ConfDir = ?config(manager_conf_dir, Conf),
- DbDir = ?config(manager_db_dir, Conf),
+ DbDir = ?config(manager_db_dir, Conf),
+
+ verify_dir_existing(conf, ConfDir),
+ verify_dir_existing(db, DbDir),
Opts = [{versions, [v1]},
{config, [{verbosity, trace}, {dir, ConfDir}, {db_dir, DbDir}]}],
@@ -2022,7 +2033,6 @@ register_usm_user_using_file(Conf) when is_list(Conf) ->
%% --
p("done"),
ok.
-%% ?SKIP(not_yet_implemented).
%%
@@ -2651,9 +2661,21 @@ write_usm_conf2(Dir, Str) ->
write_conf_file(Dir, File, Str) ->
- ?line {ok, Fd} = file:open(filename:join(Dir, File), write),
- ?line ok = io:format(Fd, "~s", [Str]),
- file:close(Fd).
+ case file:open(filename:join(Dir, File), write) of
+ {ok, Fd} ->
+ ?line ok = io:format(Fd, "~s", [Str]),
+ file:close(Fd);
+ {error, Reason} ->
+ Info =
+ [{dir, Dir, case (catch file:read_file_info(Dir)) of
+ {ok, FI} ->
+ FI;
+ _ ->
+ undefined
+ end},
+ {file, File}],
+ exit({failed_writing_conf_file, Info, Reason})
+ end.
maybe_start_crypto() ->
@@ -2679,6 +2701,17 @@ maybe_stop_crypto() ->
%% ------
+verify_dir_existing(DirName, Dir) ->
+ case file:read_file_info(Dir) of
+ {ok, _} ->
+ ok;
+ {error, Reason} ->
+ exit({non_existing_dir, DirName, Dir, Reason})
+ end.
+
+
+%% ------
+
str(X) ->
lists:flatten(io_lib:format("~w", [X])).