4
%% Copyright Ericsson AB 2010. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
20
%%%-------------------------------------------------------------------
21
%%% File: config_static_SUITE
24
%%% Test suite for common_test which tests the get_config and require
26
%%%-------------------------------------------------------------------
27
-module(config_static_SUITE).
31
-include_lib("common_test/include/ct.hrl").
33
% The config contains variables:
35
% gen_cfg - list with two key-values tagged with a and b
36
% gen_cfg2 - list of five key-values tagged with c, d, e, f and g
37
% gen_cfg3 - list of two complex key-values taggen with:
38
% h: three elements inside - i, j and k
39
% l: m inside, contains n and o
43
{timetrap, {seconds,10}},
44
%% x1 doesn't exist in cfg-file!
47
{require, alias, gen_cfg},
52
init_per_suite(Config) ->
58
all() -> [test_get_config_simple, test_get_config_nested, test_default_suitewide,
59
test_config_name_already_in_use1, test_default_tclocal,
60
test_config_name_already_in_use2, test_alias_tclocal,
61
test_get_config_undefined].
63
init_per_testcase(_, Config) ->
66
end_per_testcase(_, _) ->
69
%% test getting a simple value
70
test_get_config_simple(_)->
71
suite = ct:get_config(x),
74
%% test getting a nested value
75
test_get_config_nested(_)->
76
a_value = ct:get_config({gen_cfg, a}),
79
%% test suite-wide default value
80
test_default_suitewide(_)->
81
suite = ct:get_config(x1),
85
test_config_name_already_in_use1() ->
86
[{timetrap, {seconds,2}},
89
test_config_name_already_in_use1(_) ->
90
ct:fail("Test should've been skipped, you shouldn't see this!"),
93
%% test defaults in a testcase
94
test_default_tclocal() ->
95
[{timetrap, {seconds,3}},
98
test_default_tclocal(_) ->
99
test3 = ct:get_config(y1),
102
%% should get skipped
103
test_config_name_already_in_use2() ->
104
[{require,alias,something},
105
{alias,{something,else}},
108
test_config_name_already_in_use2(_) ->
109
ct:fail("Test should've been skipped, you shouldn't see this!"),
113
test_alias_tclocal() ->
114
[{require,newalias,gen_cfg}].
115
test_alias_tclocal(_) ->
116
A = [{a,a_value},{b,b_value}] = ct:get_config(newalias),
117
A = ct:get_config(gen_cfg),
120
%% test for getting undefined variables
121
test_get_config_undefined(_) ->
122
undefined = ct:get_config(y1),