diff options
51 files changed, 1734 insertions, 935 deletions
@@ -73,4 +73,4 @@ Copyright and License [1]: http://www.erlang.org [2]: http://wiki.github.com/erlang/otp/submitting-patches - [3]: http://www.erlang.org/faq.html + [3]: http://www.erlang.org/static/doc/mailinglist.html diff --git a/erts/doc/src/erlc.xml b/erts/doc/src/erlc.xml index 3358b8f115..09ed4bd372 100644 --- a/erts/doc/src/erlc.xml +++ b/erts/doc/src/erlc.xml @@ -67,7 +67,7 @@ <item> <p>Instructs the compiler to search for include files in the specified directory. When encountering an - <c><![CDATA[-include]]></c> or <c><![CDATA[-include_dir]]></c> directive, the + <c><![CDATA[-include]]></c> or <c><![CDATA[-include_lib]]></c> directive, the compiler searches for header files in the following directories:</p> <list type="ordered"> diff --git a/erts/emulator/beam/erl_async.c b/erts/emulator/beam/erl_async.c index cb975d64b0..f308039baf 100644 --- a/erts/emulator/beam/erl_async.c +++ b/erts/emulator/beam/erl_async.c @@ -394,6 +394,8 @@ static ERTS_INLINE void call_async_ready(ErtsAsync *a) } erts_port_release(p); } + if (a->pdl) + driver_pdl_dec_refc(a->pdl); if (a->hndl) erts_ddll_dereference_driver(a->hndl); } @@ -403,9 +405,6 @@ static ERTS_INLINE void async_reply(ErtsAsync *a, ErtsThrQPrepEnQ_t *prep_enq) #if ERTS_USE_ASYNC_READY_Q ErtsAsyncReadyQ *arq; - if (a->pdl) - driver_pdl_dec_refc(a->pdl); - #if ERTS_ASYNC_PRINT_JOB erts_fprintf(stderr, "=>> %ld\n", a->async_id); #endif @@ -425,8 +424,6 @@ static ERTS_INLINE void async_reply(ErtsAsync *a, ErtsThrQPrepEnQ_t *prep_enq) #else /* ERTS_USE_ASYNC_READY_Q */ call_async_ready(a); - if (a->pdl) - driver_pdl_dec_refc(a->pdl); erts_free(ERTS_ALC_T_ASYNC, (void *) a); #endif /* ERTS_USE_ASYNC_READY_Q */ diff --git a/erts/emulator/beam/erl_time_sup.c b/erts/emulator/beam/erl_time_sup.c index f90daadadc..a44401d7b1 100644 --- a/erts/emulator/beam/erl_time_sup.c +++ b/erts/emulator/beam/erl_time_sup.c @@ -351,7 +351,7 @@ static int clock_resolution; /* ** The clock resolution should really be the resolution of the ** time function in use, which on most platforms -** is 1. On VxWorks the resolution shold be +** is 1. On VxWorks the resolution should be ** the number of ticks per second (or 1, which would work nicely to). ** ** Setting lower resolutions is mostly interesting when timers are used diff --git a/erts/preloaded/src/prim_file.erl b/erts/preloaded/src/prim_file.erl index 0fc56c8c8e..ec158ba970 100644 --- a/erts/preloaded/src/prim_file.erl +++ b/erts/preloaded/src/prim_file.erl @@ -453,7 +453,7 @@ position(#file_descriptor{module = ?MODULE, data = {Port, _}}, At) -> {error, Reason} end. -%% Returns {error, Reaseon} | ok. +%% Returns {error, Reason} | ok. truncate(#file_descriptor{module = ?MODULE, data = {Port, _}}) -> drv_command(Port, <<?FILE_TRUNCATE>>). diff --git a/erts/test/otp_SUITE.erl b/erts/test/otp_SUITE.erl index 332733e075..5f28f22606 100644 --- a/erts/test/otp_SUITE.erl +++ b/erts/test/otp_SUITE.erl @@ -181,6 +181,7 @@ dialyzer_filter(Undef) -> ({_,{dialyzer_codeserver,_,_}}) -> false; ({_,{dialyzer_contracts,_,_}}) -> false; ({_,{dialyzer_cl_parse,_,_}}) -> false; + ({_,{dialyzer_timing,_,_}}) -> false; ({_,{dialyzer_plt,_,_}}) -> false; ({_,{dialyzer_succ_typings,_,_}}) -> false; ({_,{dialyzer_utils,_,_}}) -> false; diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl index 56f31de638..b0c37d79e7 100644 --- a/lib/asn1/test/asn1_SUITE.erl +++ b/lib/asn1/test/asn1_SUITE.erl @@ -248,7 +248,7 @@ init_per_testcase(Func, Config) -> [{case_dir, CaseDir}, {watchdog, Dog}|Config]. end_per_testcase(_Func, Config) -> - true = code:del_path(?config(case_dir, Config)), + code:del_path(?config(case_dir, Config)), test_server:timetrap_cancel(?config(watchdog, Config)). %%------------------------------------------------------------------------------ diff --git a/lib/common_test/doc/src/config_file_chapter.xml b/lib/common_test/doc/src/config_file_chapter.xml index e843ed3ba4..3e6fb21659 100644 --- a/lib/common_test/doc/src/config_file_chapter.xml +++ b/lib/common_test/doc/src/config_file_chapter.xml @@ -29,6 +29,8 @@ <file>config_file_chapter.xml</file> </header> + <marker id="top"></marker> + <section> <title>General</title> diff --git a/lib/common_test/doc/src/ct_hooks.xml b/lib/common_test/doc/src/ct_hooks.xml index b98c04a850..b3e713c77f 100644 --- a/lib/common_test/doc/src/ct_hooks.xml +++ b/lib/common_test/doc/src/ct_hooks.xml @@ -5,7 +5,7 @@ <erlref> <header> <copyright> - <year>2010</year><year>2011</year> + <year>2010</year><year>2012</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -111,11 +111,12 @@ </func> <func> - <name>Module:pre_init_per_suite(SuiteName, Config, CTHState) -> + <name>Module:pre_init_per_suite(SuiteName, InitData, CTHState) -> Result</name> <fsummary>Called before init_per_suite</fsummary> <type> <v>SuiteName = atom()</v> + <v>InitData = Config | SkipOrFail</v> <v>Config = NewConfig = [{Key,Value}]</v> <v>CTHState = NewCTHState = term()</v> <v>Result = {Return, NewCTHState}</v> @@ -140,7 +141,8 @@ <p><c>SuiteName</c> is the name of the suite to be run.</p> - <p><c>Config</c> is the original config list of the test suite.</p> + <p><c>InitData</c> is the original config list of the test suite, or + a <c>SkipOrFail</c> tuple if a previous CTH has returned this.</p> <p><c>CTHState</c> is the current internal state of the CTH.</p> @@ -212,11 +214,12 @@ </func> <func> - <name>Module:pre_init_per_group(GroupName, Config, CTHState) -> + <name>Module:pre_init_per_group(GroupName, InitData, CTHState) -> Result</name> <fsummary>Called before init_per_group</fsummary> <type> <v>GroupName = atom()</v> + <v>InitData = Config | SkipOrFail</v> <v>Config = NewConfig = [{Key,Value}]</v> <v>CTHState = NewCTHState = term()</v> <v>Result = {NewConfig | SkipOrFail, NewCTHState}</v> @@ -269,11 +272,12 @@ </func> <func> - <name>Module:pre_init_per_testcase(TestcaseName, Config, CTHState) -> + <name>Module:pre_init_per_testcase(TestcaseName, InitData, CTHState) -> Result</name> <fsummary>Called before init_per_testcase</fsummary> <type> <v>TestcaseName = atom()</v> + <v>InitData = Config | SkipOrFail</v> <v>Config = NewConfig = [{Key,Value}]</v> <v>CTHState = NewCTHState = term()</v> <v>Result = {NewConfig | SkipOrFail, NewCTHState}</v> @@ -330,11 +334,12 @@ </func> <func> - <name>Module:pre_end_per_group(GroupName, Config, CTHState) -> + <name>Module:pre_end_per_group(GroupName, EndData, CTHState) -> Result</name> <fsummary>Called before end_per_group</fsummary> <type> <v>GroupName = atom()</v> + <v>EndData = Config | SkipOrFail</v> <v>Config = NewConfig = [{Key,Value}]</v> <v>CTHState = NewCTHState = term()</v> <v>Result = {NewConfig | SkipOrFail, NewCTHState}</v> @@ -387,11 +392,12 @@ </func> <func> - <name>Module:pre_end_per_suite(SuiteName, Config, CTHState) -> + <name>Module:pre_end_per_suite(SuiteName, EndData, CTHState) -> Result</name> <fsummary>Called before end_per_suite</fsummary> <type> <v>SuiteName = atom()</v> + <v>EndData = Config | SkipOrFail</v> <v>Config = NewConfig = [{Key,Value}]</v> <v>CTHState = NewCTHState = term()</v> <v>Result = {NewConfig | SkipOrFail, NewCTHState}</v> diff --git a/lib/common_test/doc/src/ct_hooks_chapter.xml b/lib/common_test/doc/src/ct_hooks_chapter.xml index c938851e0e..86237f5fc1 100644 --- a/lib/common_test/doc/src/ct_hooks_chapter.xml +++ b/lib/common_test/doc/src/ct_hooks_chapter.xml @@ -252,6 +252,13 @@ {ok, Handle} -> {[{db_handle, Handle} | Config], CTHState#state{ handle = Handle }} end.</code> + <note>If using multiple CTHs, the first part of the return tuple will be + used as input for the next CTH. So in the case above the next CTH might + get <c>{fail,Reason}</c> as the second parameter. If you have many CTHs + which interact, it might be a good idea to not let each CTH return + <c>fail</c> or <c>skip</c>. Instead return that an action should be taken + through the <c>Config</c> list and implement a CTH which at the end takes + the correct action. </note> </section> diff --git a/lib/common_test/doc/src/ct_master_chapter.xml b/lib/common_test/doc/src/ct_master_chapter.xml index f4f0ecad62..21deed099d 100644 --- a/lib/common_test/doc/src/ct_master_chapter.xml +++ b/lib/common_test/doc/src/ct_master_chapter.xml @@ -124,7 +124,8 @@ <p><c>NodeRef = NodeAlias | node() | master</c></p> <p>A <c>NodeAlias</c> (<c>atom()</c>) is used in a test specification as a - reference to a node name (so the actual node name only needs to be declared once). + reference to a node name (so the actual node name only needs to be declared once, + which can of course also be achieved using constants). The alias is declared with a <c>node</c> term:</p> <p><c>{node, NodeAlias, NodeName}</c></p> @@ -141,30 +142,32 @@ CT Master:</p> <pre> - {node, node1, ct_node@host_x}. - {node, node2, ct_node@host_y}. - - {logdir, master, "/home/test/master_logs"}. - {logdir, "/home/test/logs"}. + {define, 'Top', "/home/test"}. + {define, 'T1', "'Top'/t1"}. + {define, 'T2', "'Top'/t2"}. + {define, 'T3', "'Top'/t3"}. + {define, 'CfgFile', "config.cfg"}. + {define, 'Node', ct_node}. + + {node, node1, 'Node@host_x'}. + {node, node2, 'Node@host_y'}. + + {logdir, master, "'Top'/master_logs"}. + {logdir, "'Top'/logs"}. - {config, node1, "/home/test/t1/cfg/config.cfg"}. - {config, node2, "/home/test/t2/cfg/config.cfg"}. - {config, "/home/test/t3/cfg/config.cfg"}. + {config, node1, "'T1'/'CfgFile'"}. + {config, node2, "'T2'/'CfgFile'"}. + {config, "'T3'/'CfgFile'"}. - {alias, t1, "/home/test/t1"}. - {alias, t2, "/home/test/t2"}. - {alias, t3, "/home/test/t3"}. + {suites, node1, 'T1', all}. + {skip_suites, node1, 'T1', [t1B_SUITE,t1D_SUITE], "Not implemented"}. + {skip_cases, node1, 'T1', t1A_SUITE, [test3,test4], "Irrelevant"}. + {skip_cases, node1, 'T1', t1C_SUITE, [test1], "Ignore"}. - {suites, node1, t1, all}. - {skip_suites, node1, t1, [t1B_SUITE,t1D_SUITE], "Not implemented"}. - {skip_cases, node1, t1, t1A_SUITE, [test3,test4], "Irrelevant"}. - {skip_cases, node1, t1, t1C_SUITE, [test1], "Ignore"}. + {suites, node2, 'T2', [t2B_SUITE,t2C_SUITE]}. + {cases, node2, 'T2', t2A_SUITE, [test4,test1,test7]}. - {suites, node2, t2, [t2B_SUITE,t2C_SUITE]}. - {cases, node2, t2, t2A_SUITE, [test4,test1,test7]}. - - {skip_suites, t3, all, "Not implemented"}. - </pre> + {skip_suites, 'T3', all, "Not implemented"}.</pre> <p>This example specifies the same tests as the original example. But now if started with a call to <c>ct_master:run(TestSpecName)</c>, the @@ -190,10 +193,6 @@ name as the Common Test node in question (typically <c>ct@somehost</c> if started with the <c>ct_run</c> program), will be performed. Tests without explicit node association will always be performed too of course!</p> - - <note><p>It is recommended that absolute paths are used for log directories, - config files and test directory aliases in the test specifications so that - current working directory settings are not important.</p></note> </section> <section> diff --git a/lib/common_test/doc/src/ct_run.xml b/lib/common_test/doc/src/ct_run.xml index 8061c840b0..9cc5495af7 100644 --- a/lib/common_test/doc/src/ct_run.xml +++ b/lib/common_test/doc/src/ct_run.xml @@ -36,6 +36,8 @@ OS command line. </comsummary> + <marker id="top"></marker> + <description> <p>The <c>ct_run</c> program is automatically installed with Erlang/OTP and Common Test (please see the Installation chapter in the Common @@ -72,6 +74,10 @@ following <c>-erl_args</c> on the command line. These directories are added to the code path normally (i.e. on specified form)</p> + <p>Exit status is set before the program ends. Value <c>0</c> indicates a successful + test result, <c>1</c> indicates one or more failed or auto-skipped test cases, and + <c>2</c> indicates test execution failure.</p> + <p>If <c>ct_run</c> is called with option:</p> <pre>-help</pre> <p>it prints all valid start flags to stdout.</p> @@ -112,6 +118,7 @@ [-basic_html] [-ct_hooks CTHModule1 CTHOpts1 and CTHModule2 CTHOpts2 and .. CTHModuleN CTHOptsN] + [-exit_status ignore_config] </pre> </section> <section> @@ -145,6 +152,7 @@ [-basic_html] [-ct_hooks CTHModule1 CTHOpts1 and CTHModule2 CTHOpts2 and .. CTHModuleN CTHOptsN] + [-exit_status ignore_config] </pre> </section> <section> diff --git a/lib/common_test/doc/src/example_chapter.xml b/lib/common_test/doc/src/example_chapter.xml index f269dba2cd..3bba7bd783 100644 --- a/lib/common_test/doc/src/example_chapter.xml +++ b/lib/common_test/doc/src/example_chapter.xml @@ -28,7 +28,8 @@ <rev></rev> <file>example_chapter.xml</file> </header> - + + <marker id="top"></marker> <section> <title>Test suite example</title> diff --git a/lib/common_test/doc/src/getting_started_chapter.xml b/lib/common_test/doc/src/getting_started_chapter.xml index 891cbc49f3..3cf04bb1a2 100644 --- a/lib/common_test/doc/src/getting_started_chapter.xml +++ b/lib/common_test/doc/src/getting_started_chapter.xml @@ -214,11 +214,56 @@ <section> <title>What happens next?</title> - <p> - You will find detailed information about the basics introduced here in this - chapter in the following chapters in the User's Guide, as well as - presentations of many more useful features. Have fun! - </p> + + <p>Well, you might already be asking yourself questions such as:</p> + + <list> + <item>"How and where can I specify variable data for my tests that mustn't + be hard-coded in the test suites (such as host names, addresses, + user login data, etc)?" The + <seealso marker="config_file_chapter#top">External Configuration Data</seealso> + chapter will give you that information. + </item> + <item>"Is there a way to declare a number of different tests and run them + in one session without having to write my own scripts? And can such + declarations be used for regression testing?" The + <seealso marker="run_test_chapter#test_specifications">Test Specifications</seealso> + chapter answers these questions. + </item> + <item>"Can test cases and/or test runs be automatically repeated?" Learn more about + <seealso marker="write_test_chapter#test_case_groups">Test Case Groups</seealso> + and also read about start flags/options in the + <seealso marker="run_test_chapter#ct_run">Running Tests</seealso> chapter and + the Reference Manual. + </item> + <item>"Will Common Test execute my test cases in sequence or in parallel?" The + <seealso marker="write_test_chapter#test_case_groups">Test Case Groups</seealso> + section in the Running Tests chapter will give you the answer. + </item> + <item>"What's the syntax for timetraps (mentioned above), and how do I set them?" + This is explained in the + <seealso marker="write_test_chapter#timetraps">Timetrap Timeouts</seealso> + part of the Writing Test Suites chapter. + </item> + <item>"What functions are available for logging and printing?" Check the + <seealso marker="write_test_chapter#logging">Logging</seealso> + section in the Writing Test Suites chapter. + </item> + <item>"I need data files for my tests. Where do I store them preferrably?" + You should read about + <seealso marker="write_test_chapter#data_priv_dir">Data and Private + Directories</seealso> for information about this. + </item> + <item>"May I start with a test suite example, please?" + <seealso marker="example_chapter#top">Sure!</seealso> + </item> + </list> + <p>You will probably want to get started on your own first test suites now, while + at the same time digging deeper into the Common Test User's Guide and Reference Manual. + You will find that there's lots more to learn about the things that have been introduced + in this chapter. You will of course also be presented many more useful features, such as the + ones listed above. Have fun! + </p> </section> </chapter> diff --git a/lib/common_test/doc/src/run_test_chapter.xml b/lib/common_test/doc/src/run_test_chapter.xml index 058b27d622..ea62df27cc 100644 --- a/lib/common_test/doc/src/run_test_chapter.xml +++ b/lib/common_test/doc/src/run_test_chapter.xml @@ -178,6 +178,8 @@ <item><c><![CDATA[-basic_html]]></c>, switches off html enhancements that might not be compatible with older browsers.</item> <item><c><![CDATA[-logopts <opts>]]></c>, makes it possible to modify aspects of the logging behaviour, see <seealso marker="run_test_chapter#logopts">Log options</seealso> below.</item> + <item><c><![CDATA[-verbosity <levels>]]></c>, sets <seealso marker="write_test_chapter#logging">verbosity levels + for printouts</seealso>.</item> </list> <note><p>Directories passed to Common Test may have either relative or absolute paths.</p></note> @@ -196,60 +198,73 @@ the current working directory of the Erlang Runtime System during the test run!</p> </note> - <p>For more information about the <c>ct_run</c> program, see the - <seealso marker="install_chapter#general">Installation</seealso> chapter. - </p> - </section> - - <section> - <title>Running tests from the Web based GUI</title> - - <p>The web based GUI, VTS, is started with the <c>ct_run</c> - program. From the GUI you can load config files, and select - directories, suites and cases to run. You can also state the - config files, directories, suites and cases on the command line - when starting the web based GUI. - </p> - + <p>The <c>ct_run</c> program sets the exit status before shutting down. The following values + are defined:</p> <list> - <item><c>ct_run -vts</c></item> - <item><c><![CDATA[ct_run -vts -config <configfilename>]]></c></item> - <item><c><![CDATA[ct_run -vts -config <configfilename> -suite <suitewithfullpath> - -case <casename>]]></c></item> + <item><c>0</c> indicates a successful testrun, i.e. one without failed or auto-skipped test cases.</item> + <item><c>1</c> indicates that one or more test cases have failed, or have been auto-skipped.</item> + <item><c>2</c> indicates that the test execution has failed because of e.g. compilation errors, an + illegal return value from an info function, etc.</item> </list> + <p>If auto-skipped test cases should not affect the exit status, you may change the default + behaviour using start flag:</p> + <pre>-exit_status ignore_config</pre> - <p>From the GUI you can run tests and view the result and the logs. + <p>For more information about the <c>ct_run</c> program, see the + <seealso marker="ct_run#top">Reference Manual</seealso> and the + <seealso marker="install_chapter#general">Installation</seealso> chapter. </p> - - <p>Note that <c>ct_run -vts</c> will try to open the Common Test start - page in an existing web browser window or start the browser if it is - not running. Which browser should be started may be specified with - the browser start command option:</p> - <p><c><![CDATA[ct_run -vts -browser <browser_start_cmd>]]></c></p> - <p>Example:</p> - <p><c><![CDATA[$ ct_run -vts -browser 'firefox&']]></c></p> - <p>Note that the browser must run as a separate OS process or VTS will hang!</p> - <p>If no specific browser start command is specified, Firefox will - be the default browser on Unix platforms and Internet Explorer on Windows. - If Common Test fails to start a browser automatically, or <c>'none'</c> is - specified as the value for -browser (i.e. <c>-browser none</c>), start your - favourite browser manually and type in the URL that Common Test - displays in the shell.</p> </section> - + <section> <title>Running tests from the Erlang shell or from an Erlang program</title> <p>Common Test provides an Erlang API for running tests. The main (and most flexible) function for specifying and executing tests is called - <c><seealso marker="ct#run_test-1">ct:run_test/1</seealso></c>. This function takes the same start parameters as - the <c>ct_run</c> program described above, only the flags are instead + <c><seealso marker="ct#run_test-1">ct:run_test/1</seealso></c>. + This function takes the same start parameters as + the <c><seealso marker="run_test_chapter#ct_run">ct_run</seealso></c> + program described above, only the flags are instead given as options in a list of key-value tuples. E.g. a test specified with <c>ct_run</c> like:</p> + <p><c>$ ct_run -suite ./my_SUITE -logdir ./results</c></p> <p>is with <c><seealso marker="ct#run_test-1">ct:run_test/1</seealso></c> specified as:</p> <p><c>1> ct:run_test([{suite,"./my_SUITE"},{logdir,"./results"}]).</c></p> - <p>For detailed documentation, please see the <c>ct</c> manual page.</p> + + <p>The function returns the test result, represented by the tuple: + <c>{Ok,Failed,{UserSkipped,AutoSkipped}}</c>, where each element is an + integer. If test execution fails, the function returns the tuple: + <c>{error,Reason}</c>, where the term <c>Reason</c> explains the + failure.</p> + + <section> + <title>Releasing the Erlang shell</title> + <p>During execution of tests, started with + <c><seealso marker="ct#run_test-1">ct:run_test/1</seealso></c>, + the Erlang shell process, controlling stdin, will remain the top + level process of the Common Test system of processes. The result + is that the Erlang shell is not available for interaction during + the test run. If this is not desirable, maybe because the shell is needed + for debugging purposes or for interaction with the SUT during test + execution, you may set the <c>release_shell</c> start option to + <c>true</c> (in the call to <c>ct:run_test/1</c> or by + using the corresponding test specification term, see below). This will + make Common Test release the shell immediately after the test suite + compilation stage. To accomplish this, a test runner process + is spawned to take control of the test execution, and the effect is that + <c>ct:run_test/1</c> returns the pid of this process rather than the + test result - which instead is printed to tty at the end of the test run.</p> + <note><p>Note that in order to use the + <c><seealso marker="ct#break-1">ct:break/1/2</seealso></c> and + <c><seealso marker="ct#continue-0">ct:continue/0/1</seealso></c> functions, + <c>release_shell</c> <em>must</em> be set to <c>true</c>.</p></note> + </section> + + <p>For detailed documentation about + <c><seealso marker="ct#run_test-1">ct:run_test/1</seealso></c>, + please see the + <c><seealso marker="ct#run_test-1">ct</seealso></c> manual page.</p> </section> <section> @@ -353,31 +368,34 @@ <marker id="test_specifications"></marker> <section> - <title>Using test specifications</title> + <title>Test Specifications</title> <p>The most flexible way to specify what to test, is to use a so called test specification. A test specification is a sequence of - Erlang terms. The terms may be declared in a text file or passed - to the test server at runtime as a list - (see <c>run_testspec/1</c> in the manual page - for <c>ct</c>). There are two general types of terms: - configuration terms and test specification terms.</p> + Erlang terms. The terms are normally declared in a text file (see + <c><seealso marker="ct#run_test-1">ct:run_test/1</seealso></c>), but + may also be passed to Common Test on the form of a list (see + <c><seealso marker="ct#run_testspec-1">ct:run_testspec/1</seealso></c>). + There are two general types of terms: configuration terms and test + specification terms.</p> <p>With configuration terms it is possible to e.g. label the test run (similar to <c>ct_run -label</c>), evaluate arbitrary expressions - before starting a test, import configuration - data (similar to - <c>ct_run -config/-userconfig</c>), specify HTML log directories (similar - to - <c>ct_run -logdir</c>), give aliases to test nodes and test - directories (to make a specification easier to read and - maintain), enable code coverage analysis (see - the <seealso marker="cover_chapter#cover">Code Coverage - Analysis</seealso> chapter) and specify event_handler plugins - (see the <seealso marker="event_handler_chapter#event_handling"> - Event Handling</seealso> chapter). There is also a term for - specifying include directories that should be passed on to the - compiler when automatic compilation is performed (similar - to <c>ct_run -include</c>, see above).</p> + before starting the test, import configuration data (similar to + <c>ct_run -config/-userconfig</c>), specify the top level HTML log + directory (similar to <c>ct_run -logdir</c>), enable code coverage + analysis (similar to <c>ct_run -cover</c>), install Common Test Hooks + (similar to <c>ct_run -ch_hooks</c>), install event_handler plugins + (similar to <c>ct_run -event_handler</c>), specify include directories + that should be passed to the compiler for automatic compilation + (similar to <c>ct_run -include</c>), disable the auto compilation + feature (similar to <c>ct_run -no_auto_compile</c>), set verbosity + levels (similar to <c>ct_run -verbosity</c>), and more.</p> + <p>Configuration terms can be combined with <c>ct_run</c> start flags, + or <c>ct:run_test/1</c> options. The result will for some flags/options + and terms be that the values are merged (e.g. configuration files, + include directories, verbosity levels, silent connections), and for + others that the start flags/options override the test specification + terms (e.g. log directory, label, style sheet, auto compilation).</p> <p>With test specification terms it is possible to state exactly which tests should run and in which order. A test term specifies either one or more suites, one or more test case groups, or one @@ -392,11 +410,12 @@ S, is a test of all cases in S. However, if a term specifying test case X and Y in S is merged with a term specifying case Z in S, the result is a test of X, Y and Z in S. To disable this - behaviour, it is possible in test specification to set the - <c>merge_tests</c> term to <c>false</c>.</p> + behaviour, i.e. to instead perform each test sequentially in a "script-like" + manner, the term <c>merge_tests</c> can be set to <c>false</c> in + the test specification.</p> <p>A test term can also specify one or more test suites, groups, or test cases to be skipped. Skipped suites, groups and cases - are not executed and show up in the HTML test log files as + are not executed and show up in the HTML log files as SKIPPED.</p> <p>When a test case group is specified, the resulting test executes the @@ -429,12 +448,27 @@ Testing). The node parameters in the <c>init</c> term are only relevant in the latter (see the <seealso marker="ct_master_chapter#test_specifications">Large - Scale Testing</seealso> chapter for information). For details on - the event_handler term, see the + Scale Testing</seealso> chapter for information). For more information + about the various terms, please see the corresponding sections in the + User's Guide, such as e.g. the + <seealso marker="run_test_chapter#ct_run"><c>ct_run</c> + program</seealso> for an overview of available start flags + (since most flags have a corresponding configuration term), and + more detailed explanation of e.g. + <seealso marker="write_test_chapter#logging">Logging</seealso> + (for the <c>verbosity</c>, <c>stylesheet</c> and <c>basic_html</c> terms), + <seealso marker="config_file_chapter#top">External Configuration Data</seealso> + (for the <c>config</c> and <c>userconfig</c> terms), <seealso marker="event_handler_chapter#event_handling">Event - Handling</seealso> chapter.</p> + Handling</seealso> (for the <c>event_handler</c> term), + <seealso marker="ct_hooks_chapter#installing">Common Test Hooks</seealso> + (for the <c>ct_hooks</c> term), etc.</p> <p>Config terms:</p> <pre> + {merge_tests, Bool}. + + {define, Constant, Value}. + {node, NodeAlias, Node}. {init, InitOptions}. @@ -443,6 +477,15 @@ {label, Label}. {label, NodeRefs, Label}. + {verbosity, VerbosityLevels}. + {verbosity, NodeRefs, VerbosityLevels}. + + {stylesheet, CSSFile}. + {stylesheet, NodeRefs, CSSFile}. + + {silent_connections, ConnTypes}. + {silent_connections, NodeRefs, ConnTypes}. + {multiply_timetraps, N}. {multiply_timetraps, NodeRefs, N}. @@ -455,19 +498,23 @@ {include, IncludeDirs}. {include, NodeRefs, IncludeDirs}. + {auto_compile, Bool}, + {auto_compile, NodeRefs, Bool}, + {config, ConfigFiles}. + {config, ConfigDir, ConfigBaseNames}. {config, NodeRefs, ConfigFiles}. + {config, NodeRefs, ConfigDir, ConfigBaseNames}. {userconfig, {CallbackModule, ConfigStrings}}. {userconfig, NodeRefs, {CallbackModule, ConfigStrings}}. - {alias, DirAlias, Dir}. - - {merge_tests, Bool}. - {logdir, LogDir}. {logdir, NodeRefs, LogDir}. + {logopts, LogOpts}. + {logopts, NodeRefs, LogOpts}. + {create_priv_dir, PrivDirOption}. {create_priv_dir, NodeRefs, PrivDirOption}. @@ -480,83 +527,176 @@ {ct_hooks, NodeRefs, CTHModules}. {enable_builtin_hooks, Bool}. - </pre> + + {basic_html, Bool}. + {basic_html, NodeRefs, Bool}. + + {release_shell, Bool}.</pre> + <p>Test terms:</p> <pre> - {suites, DirRef, Suites}. - {suites, NodeRefs, DirRef, Suites}. + {suites, Dir, Suites}. + {suites, NodeRefs, Dir, Suites}. - {groups, DirRef, Suite, Groups}. - {groups, NodeRefsDirRef, Suite, Groups}. + {groups, Dir, Suite, Groups}. + {groups, NodeRefs, Dir, Suite, Groups}. - {groups, DirRef, Suite, GroupSpec, {cases,Cases}}. - {groups, NodeRefsDirRef, Suite, GroupSpec, {cases,Cases}}. + {groups, Dir, Suite, GroupSpec, {cases,Cases}}. + {groups, NodeRefs, Dir, Suite, GroupSpec, {cases,Cases}}. - {cases, DirRef, Suite, Cases}. - {cases, NodeRefs, DirRef, Suite, Cases}. + {cases, Dir, Suite, Cases}. + {cases, NodeRefs, Dir, Suite, Cases}. - {skip_suites, DirRef, Suites, Comment}. - {skip_suites, NodeRefs, DirRef, Suites, Comment}. + {skip_suites, Dir, Suites, Comment}. + {skip_suites, NodeRefs, Dir, Suites, Comment}. - {skip_groups, DirRef, Suite, GroupNames, Comment}. - {skip_groups, NodeRefs, DirRef, Suite, GroupNames, Comment}. + {skip_groups, Dir, Suite, GroupNames, Comment}. + {skip_groups, NodeRefs, Dir, Suite, GroupNames, Comment}. - {skip_cases, DirRef, Suite, Cases, Comment}. - {skip_cases, NodeRefs, DirRef, Suite, Cases, Comment}. - </pre> + {skip_cases, Dir, Suite, Cases, Comment}. + {skip_cases, NodeRefs, Dir, Suite, Cases, Comment}.</pre> + <p>Types:</p> <pre> - NodeAlias = atom() - InitOptions = term() - Node = node() - NodeRef = NodeAlias | Node | master - NodeRefs = all_nodes | [NodeRef] | NodeRef - N = integer() - Bool = true | false - CoverSpecFile = string() - IncludeDirs = string() | [string()] - ConfigFiles = string() | [string()] - DirAlias = atom() - Dir = string() - LogDir = string() - PrivDirOption = auto_per_run | auto_per_tc | manual_per_tc - EventHandlers = atom() | [atom()] - InitArgs = [term()] - CTHModules = [CTHModule | {CTHModule, CTHInitArgs} | {CTHModule, CTHInitArgs, CTHPriority}] - CTHModule = atom() - CTHInitArgs = term() - DirRef = DirAlias | Dir - Suites = atom() | [atom()] | all - Suite = atom() - Groups = GroupSpec | [GroupSpec] | all - GroupSpec = GroupName | {GroupName,Properties} | {GroupName,Properties,GroupSpec} - GroupName = atom() - GroupNames = GroupName | [GroupName] - Cases = atom() | [atom()] | all - Comment = string() | "" - </pre> - <p>Example:</p> + Bool = true | false + Constant = atom() + Value = term() + NodeAlias = atom() + Node = node() + NodeRef = NodeAlias | Node | master + NodeRefs = all_nodes | [NodeRef] | NodeRef + InitOptions = term() + Label = atom() | string() + VerbosityLevels = integer() | [{Category,integer()}] + Category = atom() + CSSFile = string() + ConnTypes = all | [atom()] + N = integer() + CoverSpecFile = string() + IncludeDirs = string() | [string()] + ConfigFiles = string() | [string()] + ConfigDir = string() + ConfigBaseNames = string() | [string()] + CallbackModule = atom() + ConfigStrings = string() | [string()] + LogDir = string() + LogOpts = [term()] + PrivDirOption = auto_per_run | auto_per_tc | manual_per_tc + EventHandlers = atom() | [atom()] + InitArgs = [term()] + CTHModules = [CTHModule | {CTHModule, CTHInitArgs} | {CTHModule, CTHInitArgs, CTHPriority}] + CTHModule = atom() + CTHInitArgs = term() + Dir = string() + Suites = atom() | [atom()] | all + Suite = atom() + Groups = GroupSpec | [GroupSpec] | all + GroupSpec = GroupName | {GroupName,Properties} | {GroupName,Properties,GroupSpec} + GroupName = atom() + GroupNames = GroupName | [GroupName] + Cases = atom() | [atom()] | all + Comment = string() | ""</pre> + + <p>The difference between the <c>config</c> terms above, is that with + <c>ConfigDir</c>, <c>ConfigBaseNames</c> is a list of base names, + i.e. without directory paths. <c>ConfigFiles</c> must be full names, + including paths. E.g, these two terms have the same meaning:</p> <pre> - {logdir, "/home/test/logs"}. + {config, ["/home/testuser/tests/config/nodeA.cfg", + "/home/testuser/tests/config/nodeB.cfg"]}. + + {config, "/home/testuser/tests/config", ["nodeA.cfg","nodeB.cfg"]}.</pre> + + <note><p>Any relative paths specified in the test specification, will be + relative to the directory which contains the test specification file, if + <c>ct_run -spec TestSpecFile ...</c> or + <c>ct:run:test([{spec,TestSpecFile},...])</c> + executes the test. The path will be relative to the top level log directory, if + <c>ct:run:testspec(TestSpec)</c> executes the test.</p></note> - {config, "/home/test/t1/cfg/config.cfg"}. - {config, "/home/test/t2/cfg/config.cfg"}. - {config, "/home/test/t3/cfg/config.cfg"}. + <p>The <c>define</c> term introduces a constant, which is used to + replace the name <c>Constant</c> with <c>Value</c>, wherever it's found in + the test specification. This replacement happens during an initial iteration + through the test specification. Constants may be used anywhere in the test + specification, e.g. in arbitrary lists and tuples, and even in strings + and inside the value part of other constant definitions! A constant can + also be part of a node name, but that is the only place where a constant + can be part of an atom.</p> + + <note><p>For the sake of readability, the name of the constant must always + begin with an upper case letter, or a <c>$</c>, <c>?</c>, or <c>_</c>. + This also means that it must always be single quoted (obviously, since + the constant name is actually an atom, not text).</p></note> + + <p>The main benefit of constants is that they can be used to reduce the size + (and avoid repetition) of long strings, such as file paths. Compare these + terms:</p> + + <pre> + %% 1a. no constant + {config, "/home/testuser/tests/config", ["nodeA.cfg","nodeB.cfg"]}. + {suites, "/home/testuser/tests/suites", all}. - {alias, t1, "/home/test/t1"}. - {alias, t2, "/home/test/t2"}. - {alias, t3, "/home/test/t3"}. + %% 1b. with constant + {define, 'TESTDIR', "/home/testuser/tests"}. + {config, "'TESTDIR'/config", ["nodeA.cfg","nodeB.cfg"]}. + {suites, "'TESTDIR'/suites", all}. + + %% 2a. no constants + {config, [testnode@host1, testnode@host2], "../config", ["nodeA.cfg","nodeB.cfg"]}. + {suites, [testnode@host1, testnode@host2], "../suites", [x_SUITE, y_SUITE]}. + + %% 2b. with constants + {define, 'NODE', testnode}. + {define, 'NODES', ['NODE'@host1, 'NODE'@host2]}. + {config, 'NODES', "../config", ["nodeA.cfg","nodeB.cfg"]}. + {suites, 'NODES', "../suites", [x_SUITE, y_SUITE]}.</pre> + + <p>Constants make the test specification term <c>alias</c>, in previous + versions of Common Test, redundant. This term has been deprecated but will + remain supported in upcoming Common Test releases. Replacing <c>alias</c> + terms with <c>define</c> is strongly recommended though! Here's an example + of such a replacement:</p> + + <pre> + %% using the old alias term + {config, "/home/testuser/tests/config/nodeA.cfg"}. + {alias, suite_dir, "/home/testuser/tests/suites"}. + {groups, suite_dir, x_SUITE, group1}. + + %% replacing with constants + {define, 'TestDir', "/home/testuser/tests"}. + {define, 'CfgDir', "'TestDir'/config"}. + {define, 'SuiteDir', "'TestDir'/suites"}. + {config, 'CfgDir', "nodeA.cfg"}. + {groups, 'SuiteDir', x_SUITE, group1}.</pre> + + <p>Actually, constants could well replace the <c>node</c> term too, but + this still has declarative value, mainly when used in combination + with <c>NodeRefs == all_nodes</c> (see types above).</p> + + <p>Here follows a simple test specification example:</p> + <pre> + {define, 'Top', "/home/test"}. + {define, 'T1', "'Top'/t1"}. + {define, 'T2', "'Top'/t2"}. + {define, 'T3', "'Top'/t3"}. + {define, 'CfgFile', "config.cfg"}. + + {logdir, "'Top'/logs"}. - {suites, t1, all}. - {skip_suites, t1, [t1B_SUITE,t1D_SUITE], "Not implemented"}. - {skip_cases, t1, t1A_SUITE, [test3,test4], "Irrelevant"}. - {skip_cases, t1, t1C_SUITE, [test1], "Ignore"}. + {config, ["'T1'/'CfgFile'", "'T2'/'CfgFile'", "'T3'/'CfgFile'"]}. - {suites, t2, [t2B_SUITE,t2C_SUITE]}. - {cases, t2, t2A_SUITE, [test4,test1,test7]}. + {suites, 'T1', all}. + {skip_suites, 'T1', [t1B_SUITE,t1D_SUITE], "Not implemented"}. + {skip_cases, 'T1', t1A_SUITE, [test3,test4], "Irrelevant"}. + {skip_cases, 'T1', t1C_SUITE, [test1], "Ignore"}. - {skip_suites, t3, all, "Not implemented"}. - </pre> + {suites, 'T2', [t2B_SUITE,t2C_SUITE]}. + {cases, 'T2', t2A_SUITE, [test4,test1,test7]}. + + {skip_suites, 'T3', all, "Not implemented"}.</pre> + <p>The example specifies the following:</p> <list> <item>The specified logdir directory will be used for storing @@ -564,8 +704,6 @@ date and time).</item> <item>The variables in the specified test system config files will be imported for the test.</item> - <item>Aliases are given for three test system directories. The suites in - this example are stored in "/home/test/tX/test".</item> <item>The first test to run includes all suites for system t1. Excluded from the test are however the t1B and t1D suites. Also test cases test3 and test4 in t1A as well as the test1 case in t1C are excluded from @@ -590,8 +728,46 @@ If <c><seealso marker="ct#run_test-1">ct:run_test/1</seealso></c> is used for starting the tests, the relaxed scanner mode is enabled by means of the tuple: <c>{allow_user_terms,true}</c></p> </section> + + <section> + <title>Running tests from the Web based GUI</title> + + <p>The web based GUI, VTS, is started with the + <c><seealso marker="run_test_chapter#ct_run">ct_run</seealso></c> + program. From the GUI you can load config files, and select + directories, suites and cases to run. You can also state the + config files, directories, suites and cases on the command line + when starting the web based GUI. + </p> + + <list> + <item><c>ct_run -vts</c></item> + <item><c><![CDATA[ct_run -vts -config <configfilename>]]></c></item> + <item><c><![CDATA[ct_run -vts -config <configfilename> -suite <suitewithfullpath> + -case <casename>]]></c></item> + </list> + + <p>From the GUI you can run tests and view the result and the logs. + </p> + + <p>Note that <c>ct_run -vts</c> will try to open the Common Test start + page in an existing web browser window or start the browser if it is + not running. Which browser should be started may be specified with + the browser start command option:</p> + <p><c><![CDATA[ct_run -vts -browser <browser_start_cmd>]]></c></p> + <p>Example:</p> + <p><c><![CDATA[$ ct_run -vts -browser 'firefox&']]></c></p> + <p>Note that the browser must run as a separate OS process or VTS will hang!</p> + <p>If no specific browser start command is specified, Firefox will + be the default browser on Unix platforms and Internet Explorer on Windows. + If Common Test fails to start a browser automatically, or <c>'none'</c> is + specified as the value for -browser (i.e. <c>-browser none</c>), start your + favourite browser manually and type in the URL that Common Test + displays in the shell.</p> + </section> <section> + <marker id="log_files"></marker> <title>Log files</title> <p>As the execution of the test suites proceed, events are logged in @@ -719,17 +895,30 @@ <p>instead of each <c>x</c> printed on a new line, which is the default behaviour.</p> </section> + <section> + <marker id="table_sorting"></marker> + <title>Sorting HTML table columns</title> + <p>By clicking the name in the column header of any table (e.g. "Ok", "Case", "Time", etc), + the table rows are sorted in whatever order makes sense for the type of value (e.g. + numerical for "Ok" or "Time", and alphabetical for "Case"). The sorting is performed + by means of JavaScript code, automatically inserted into the HTML log files. Common Test + uses the <url href="http://jquery.com">jQuery</url> library and the + <url href="http://tablesorter.com">tablesorter</url> plugin, with customized sorting + functions, for this implementation.</p> + </section> </section> <section> <marker id="html_stylesheet"></marker> <title>HTML Style Sheets</title> - <p>Common Test uses a CSS file to control the look of the HTML - files generated during test runs. If, for some reason, the - log files are not displayed correctly in the HTML browser of your - choice, or you prefer the "pre Common Test v1.6 look" - of the log files (i.e. not using CSS), use the start flag/option - <c>basic_html</c> to revert to the old style.</p> + <p>Common Test uses an HTML Style Sheet (CSS file) to control the look of + the HTML log files generated during test runs. If, for some reason, the + log files are not displayed correctly in the browser of your + choice, or you prefer a more primitive ("pre Common Test v1.6") look + of the logs, use the start flag/option:</p> + <pre>basic_html</pre> + <p>This disables the use of Style Sheets, as well as JavaScripts (see + table sorting above).</p> <p>Common Test includes an <em>optional</em> feature to allow user HTML style sheets for customizing printouts. The @@ -882,75 +1071,82 @@ <section> <marker id="silent_connections"></marker> <title>Silent Connections</title> - <p>The protocol handling processes in Common Test, implemented by ct_telnet, ct_ftp etc, - do verbose printing to the test case logs. This can be switched off by means - of the <c>-silent_connections</c> flag:</p> + <p>The protocol handling processes in Common Test, implemented by ct_telnet, + ct_ssh, ct_ftp etc, do verbose printing to the test case logs. This can be switched off + by means of the <c>-silent_connections</c> flag:</p> <pre> ct_run -silent_connections [conn_types] </pre> - <p>where <c>conn_types</c> specifies <c>telnet, ftp, rpc</c> and/or <c>snmp</c>.</p> + <p>where <c>conn_types</c> specifies <c>ssh, telnet, ftp, rpc</c> and/or <c>snmp</c>.</p> <p>Example:</p> <pre> - ct_run ... -silent_connections telnet ftp</pre> - <p>switches off logging for telnet and ftp connections.</p> + ct_run ... -silent_connections ssh telnet</pre> + <p>switches off logging for ssh and telnet connections.</p> <pre> ct_run ... -silent_connections</pre> <p>switches off logging for all connection types.</p> - <p>Basic and important information such as opening and closing a connection, - fatal communication error and reconnection attempts will always be printed even - if logging has been suppressed for the connection type in question. However, operations - such as sending and receiving data may be performed silently.</p> + <p>Fatal communication error and reconnection attempts will always be printed even + if logging has been suppressed for the connection type in question. However, operations + such as sending and receiving data will be performed silently.</p> <p>It is possible to also specify <c>silent_connections</c> in a test suite. This is accomplished by returning a tuple, <c>{silent_connections,ConnTypes}</c>, in the <c>suite/0</c> or test case info list. If <c>ConnTypes</c> is a list of atoms - (<c>telnet, ftp, rpc</c> and/or <c>snmp</c>), output for any corresponding connections + (<c>ssh, telnet, ftp, rpc</c> and/or <c>snmp</c>), output for any corresponding connections will be suppressed. Full logging is per default enabled for any connection of type not specified in <c>ConnTypes</c>. Hence, if <c>ConnTypes</c> is the empty list, logging is enabled for all connections.</p> - <p>The <c>silent_connections</c> setting returned from a test case info function overrides, - for the test case in question, any setting made with <c>suite/0</c> (which is the setting - used for all cases in the suite). Example:</p> + <p>Example:</p> <pre> -module(my_SUITE). + + suite() -> [..., {silent_connections,[telnet,ssh]}, ...]. + ... - suite() -> [..., {silent_connections,[telnet,ftp]}, ...]. - ... + my_testcase1() -> - [{silent_connections,[ftp]}]. + [{silent_connections,[ssh]}]. + my_testcase1(_) -> - ... + ... + my_testcase2(_) -> - ... + ... </pre> <p>In this example, <c>suite/0</c> tells Common Test to suppress - printouts from telnet and ftp connections. This is valid for + printouts from telnet and ssh connections. This is valid for all test cases. However, <c>my_testcase1/0</c> specifies that - for this test case, only ftp should be silent. The result is + for this test case, only ssh should be silent. The result is that <c>my_testcase1</c> will get telnet info (if any) printed - in the log, but not ftp info. <c>my_testcase2</c> will get no + in the log, but not ssh info. <c>my_testcase2</c> will get no info from either connection printed.</p> - <p>The <c>-silent_connections</c> tag (or - <c>silent_connections</c> tagged tuple in the call to - <c><seealso marker="ct#run_test-1">ct:run_test/1</seealso></c>) overrides any settings in the test - suite.</p> + <p><c>silent_connections</c> may also be specified with a term + in a test specification + (see <seealso marker="run_test_chapter#test_specifications">Test + Specifications</seealso>). Connections provided with the + <c>silent_connections</c> start flag/option, will be merged with + any connections listed in the test specification.</p> + + <p>The <c>silent_connections</c> start flag/option and test + specification term, overrides any settings made by the info functions + inside the test suite.</p> - <p>Note that in the current Common Test version, the + <note><p>Note that in the current Common Test version, the <c>silent_connections</c> feature only works for telnet - connections. Support for other connection types will be added - in future Common Test versions.</p> + and ssh connections! Support for other connection types will be added + in future Common Test versions.</p></note> </section> </chapter> diff --git a/lib/common_test/doc/src/write_test_chapter.xml b/lib/common_test/doc/src/write_test_chapter.xml index 1fae50577e..248d7de8b6 100644 --- a/lib/common_test/doc/src/write_test_chapter.xml +++ b/lib/common_test/doc/src/write_test_chapter.xml @@ -47,7 +47,7 @@ module for details about these functions.</p> <p>The CT application also includes other modules named - <c><![CDATA[ct_<something>]]></c> that + <c><![CDATA[ct_<component>]]></c> that provide various support, mainly simplified use of communication protocols such as rpc, snmp, ftp, telnet, etc.</p> @@ -886,7 +886,7 @@ of its sub-groups. If a timetrap value is defined by <c>group/1</c> for a sub-group, it overrides that of its higher level groups. Timetrap values set by individual test cases (by means of the test case info - function) overrides both group- and suite- level timetraps.</p> + function) override both group- and suite- level timetraps.</p> <p>It is also possible to dynamically set/reset a timetrap during the excution of a test case, or configuration function. This is done by calling @@ -935,6 +935,99 @@ </section> <section> + <marker id="logging"></marker> + <title>Logging - categories and verbosity levels</title> + <p>Common Test provides three main functions for printing strings:</p> + <list> + <item><c>ct:log(Category, Importance, Format, Args)</c></item> + <item><c>ct:print(Category, Importance, Format, Args)</c></item> + <item><c>ct:pal(Category, Importance, Format, Args)</c></item> + </list> + <p>The <c>log/1/2/3/4</c> function will print a string to the test case + log file. The <c>print/1/2/3/4</c> function will print the string to screen, + and the <c>pal/1/2/3/4</c> function will print the same string both to file and + screen. (The functions are documented in the <c>ct</c> reference manual).</p> + + <p>The optional <c>Category</c> argument may be used to categorize the + log printout, and categories can be used for two things:</p> + <list> + <item>To compare the importance of the printout to a specific + verbosity level, and</item> + <item>to format the printout according to a user specific HTML + Style Sheet (CSS).</item> + </list> + + <p>The <c>Importance</c> argument specifies a level of importance + which, compared to a verbosity level (general and/or set per category), + determines if the printout should be visible or not. <c>Importance</c> + is an arbitrary integer in the range 0..99. Pre-defined constants + exist in the <c>ct.hrl</c> header file. The default importance level, + <c>?STD_IMPORTANCE</c> (used if the <c>Importance</c> argument is not + provided), is 50. This is also the importance used for standard IO, e.g. + from printouts made with <c>io:format/2</c>, <c>io:put_chars/1</c>, etc.</p> + + <p><c>Importance</c> is compared to a verbosity level set by means of the + <c>verbosity</c> start flag/option. The verbosity level can be set per + category and/or generally. The default verbosity level, <c>?STD_VERBOSITY</c>, + is 50, i.e. all standard IO gets printed. If a lower verbosity level is set, + standard IO printouts will be ignored. Common Test performs the following test:</p> + <pre>Importance >= (100-VerbosityLevel)</pre> + <p>This also means that verbosity level 0 effectively turns all logging off + (with the exception of printouts made by Common Test itself).</p> + + <p>The general verbosity level is not associated with any particular + category. This level sets the threshold for the standard IO printouts, + uncategorized <c>ct:log/print/pal</c> printouts, as well as + printouts for categories with undefined verbosity level.</p> + + <p>Example:</p> + <pre> + + Some printouts during test case execution: + + io:format("1. Standard IO, importance = ~w~n", [?STD_IMPORTANCE]), + ct:log("2. Uncategorized, importance = ~w", [?STD_IMPORTANCE]), + ct:log(info, "3. Categorized info, importance = ~w", [?STD_IMPORTANCE]]), + ct:log(info, ?LOW_IMPORTANCE, "4. Categorized info, importance = ~w", [?LOW_IMPORTANCE]), + ct:log(error, "5. Categorized error, importance = ~w", [?HI_IMPORTANCE]), + ct:log(error, ?HI_IMPORTANCE, "6. Categorized error, importance = ~w", [?MAX_IMPORTANCE]), + + If starting the test without specifying any verbosity levels: + + $ ct_run ... + + the following gets printed: + + 1. Standard IO, importance = 50 + 2. Uncategorized, importance = 50 + 3. Categorized info, importance = 50 + 5. Categorized error, importance = 75 + 6. Categorized error, importance = 99 + + If starting the test with: + + $ ct_run -verbosity 1 and info 75 + + the following gets printed: + + 3. Categorized info, importance = 50 + 4. Categorized info, importance = 25 + 6. Categorized error, importance = 99 + </pre> + + <p>How categories can be mapped to CSS tags is documented in the + <seealso marker="run_test_chapter#html_stylesheet">Running Tests</seealso> + chapter.</p> + + <p>The <c>Format</c> and <c>Args</c> arguments in <c>ct:log/print/pal</c> are + always passed on to the <c>io:format/3</c> function in <c>stdlib</c> + (please see the <c>io</c> manual page for details).</p> + + <p>For more information about log files, please see the + <seealso marker="run_test_chapter#log_files">Running Tests</seealso> chapter.</p> + </section> + + <section> <title>Illegal dependencies</title> <p>Even though it is highly efficient to write test suites with @@ -944,7 +1037,6 @@ Erlang/OTP test suites.</p> <list> - <item>Depending on current directory, and writing there:<br></br> <p>This is a common error in test suites. It is assumed that @@ -956,19 +1048,10 @@ </p> </item> - <item>Depending on the Clearcase (file version control system) - paths and files:<br></br> - - <p>The test suites are stored in Clearcase but are not - (necessarily) run within this environment. The directory - structure may vary from test run to test run. - </p> - </item> - <item>Depending on execution order:<br></br> - <p>During development of test suites, no assumption should be made - (preferrably) about the execution order of the test cases or suites. + <p>During development of test suites, no assumption should preferrably + be made about the execution order of the test cases or suites. E.g. a test case should not assume that a server it depends on, has already been started by a previous test case. There are several reasons for this: diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index aa8813c391..49b51c9207 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -25,24 +25,24 @@ %%% %%% <p><strong>Test Suite Support Macros</strong></p> %%% -%%% <p>The <code>config</code> macro is defined in <code>ct.hrl</code>. This +%%% <p>The <c>config</c> macro is defined in <c>ct.hrl</c>. This %%% macro should be used to retrieve information from the -%%% <code>Config</code> variable sent to all test cases. It is used with two +%%% <c>Config</c> variable sent to all test cases. It is used with two %%% arguments, where the first is the name of the configuration -%%% variable you wish to retrieve, and the second is the <code>Config</code> +%%% variable you wish to retrieve, and the second is the <c>Config</c> %%% variable supplied to the test case.</p> %%% %%% <p>Possible configuration variables include:</p> %%% <ul> -%%% <li><code>data_dir</code> - Data file directory.</li> -%%% <li><code>priv_dir</code> - Scratch file directory.</li> -%%% <li>Whatever added by <code>init_per_suite/1</code> or -%%% <code>init_per_testcase/2</code> in the test suite.</li> +%%% <li><c>data_dir</c> - Data file directory.</li> +%%% <li><c>priv_dir</c> - Scratch file directory.</li> +%%% <li>Whatever added by <c>init_per_suite/1</c> or +%%% <c>init_per_testcase/2</c> in the test suite.</li> %%% </ul> %%% @type var_name() = atom(). A variable name which is specified when -%%% <code>ct:require/2</code> is called, -%%% e.g. <code>ct:require(mynodename,{node,[telnet]})</code> +%%% <c>ct:require/2</c> is called, +%%% e.g. <c>ct:require(mynodename,{node,[telnet]})</c> %%% %%% @type target_name() = var_name(). The name of a target. %%% @@ -99,10 +99,10 @@ %%% <p>Run this function once before first test.</p> %%% %%% <p>Example:<br/> -%%% <code>install([{config,["config_node.ctc","config_user.ctc"]}])</code>.</p> +%%% <c>install([{config,["config_node.ctc","config_user.ctc"]}])</c>.</p> %%% %%% <p>Note that this function is automatically run by the -%%% <code>ct_run</code> program.</p> +%%% <c>ct_run</c> program.</p> install(Opts) -> ct_run:install(Opts). @@ -115,10 +115,10 @@ install(Opts) -> %%% %%% @doc Run the given test case(s). %%% -%%% <p>Requires that <code>ct:install/1</code> has been run first.</p> +%%% <p>Requires that <c>ct:install/1</c> has been run first.</p> %%% %%% <p>Suites (*_SUITE.erl) files must be stored in -%%% <code>TestDir</code> or <code>TestDir/test</code>. All suites +%%% <c>TestDir</c> or <c>TestDir/test</c>. All suites %%% will be compiled when test is run.</p> run(TestDir,Suite,Cases) -> ct_run:run(TestDir,Suite,Cases). @@ -201,25 +201,32 @@ run(TestDirs) -> %%% AutoSkipped = integer() %%% TestRunnerPid = pid() %%% Reason = term() -%%% @doc <p>Run tests as specified by the combination of options in <code>Opts</code>. +%%% @doc <p>Run tests as specified by the combination of options in <c>Opts</c>. %%% The options are the same as those used with the -%%% <seealso marker="ct_run#ct_run"><code>ct_run</code></seealso> program. -%%% Note that here a <code>TestDir</code> can be used to point out the path to -%%% a <code>Suite</code>. Note also that the option <code>testcase</code> -%%% corresponds to the <code>-case</code> option in the <code>ct_run</code> -%%% program. Configuration files specified in <code>Opts</code> will be +%%% <seealso marker="ct_run#ct_run"><c>ct_run</c></seealso> program. +%%% Note that here a <c>TestDir</c> can be used to point out the path to +%%% a <c>Suite</c>. Note also that the option <c>testcase</c> +%%% corresponds to the <c>-case</c> option in the <c>ct_run</c> +%%% program. Configuration files specified in <c>Opts</c> will be %%% installed automatically at startup.</p> -%%% <p><code>TestRunnerPid</code> is returned if <code>release_shell == true</code> -%%% (see the User's Guide for details).</p> -%%% <p><code>Reason</code> indicates what type of error has been encountered.</p> +%%% <p><c>TestRunnerPid</c> is returned if <c>release_shell == true</c> +%%% (see <c>break/1</c> for details).</p> +%%% <p><c>Reason</c> indicates what type of error has been encountered.</p> run_test(Opts) -> ct_run:run_test(Opts). %%%----------------------------------------------------------------- %%% @spec run_testspec(TestSpec) -> Result %%% TestSpec = [term()] -%%% @doc Run test specified by <code>TestSpec</code>. The terms are +%%% Result = {Ok,Failed,{UserSkipped,AutoSkipped}} | {error,Reason} +%%% Ok = integer() +%%% Failed = integer() +%%% UserSkipped = integer() +%%% AutoSkipped = integer() +%%% Reason = term() +%%% @doc Run test specified by <c>TestSpec</c>. The terms are %%% the same as those used in test specification files. +%%% <p><c>Reason</c> indicates what type of error has been encountered.</p> run_testspec(TestSpec) -> ct_run:run_testspec(TestSpec). @@ -239,8 +246,8 @@ step(TestDir,Suite,Case) -> %%% Opt = config | keep_inactive %%% %%% @doc Step through a test case with the debugger. If the -%%% <code>config</code> option has been given, breakpoints will -%%% be set also on the configuration functions in <code>Suite</code>. +%%% <c>config</c> option has been given, breakpoints will +%%% be set also on the configuration functions in <c>Suite</c>. %%% @see run/3 step(TestDir,Suite,Case,Opts) -> ct_run:step(TestDir,Suite,Case,Opts). @@ -252,20 +259,20 @@ step(TestDir,Suite,Case,Opts) -> %%% %%% <p>From this mode all test case support functions can be executed %%% directly from the erlang shell. The interactive mode can also be -%%% started from the OS command line with <code>ct_run -shell -%%% [-config File...]</code>.</p> +%%% started from the OS command line with <c>ct_run -shell +%%% [-config File...]</c>.</p> %%% %%% <p>If any functions using "required config data" (e.g. telnet or %%% ftp functions) are to be called from the erlang shell, config data -%%% must first be required with <code>ct:require/2</code>.</p> +%%% must first be required with <c>ct:require/2</c>.</p> %%% %%% <p>Example:<br/> -%%% <code>> ct:require(unix_telnet, unix).</code><br/> -%%% <code>ok</code><br/> -%%% <code>> ct_telnet:open(unix_telnet).</code><br/> -%%% <code>{ok,<0.105.0>}</code><br/> -%%% <code>> ct_telnet:cmd(unix_telnet, "ls .").</code><br/> -%%% <code>{ok,["ls","file1 ...",...]}</code></p> +%%% <c>> ct:require(unix_telnet, unix).</c><br/> +%%% <c>ok</c><br/> +%%% <c>> ct_telnet:open(unix_telnet).</c><br/> +%%% <c>{ok,<0.105.0>}</c><br/> +%%% <c>> ct_telnet:cmd(unix_telnet, "ls .").</c><br/> +%%% <c>{ok,["ls","file1 ...",...]}</c></p> start_interactive() -> ct_util:start(interactive). @@ -292,21 +299,21 @@ stop_interactive() -> %%% to specify arbitrarily deep tuples as <c>Required</c>. Note that it is %%% only the last element of the tuple which can be a list of <c>SubKey</c>s. %%% -%%% <p>Example 1: require the variable <code>myvar</code>:</p> +%%% <p>Example 1: require the variable <c>myvar</c>:</p> %%% <pre>ok = ct:require(myvar).</pre> %%% %%% <p>In this case the config file must at least contain:</p> %%% <pre>{myvar,Value}.</pre> %%% -%%% <p>Example 2: require the key <code>myvar</code> with -%%% subkeys <code>sub1</code> and <code>sub2</code>:</p> +%%% <p>Example 2: require the key <c>myvar</c> with +%%% subkeys <c>sub1</c> and <c>sub2</c>:</p> %%% <pre>ok = ct:require({myvar,[sub1,sub2]}).</pre> %%% %%% <p>In this case the config file must at least contain:</p> %%% <pre>{myvar,[{sub1,Value},{sub2,Value}]}.</pre> %%% -%%% <p>Example 3: require the key <code>myvar</code> with -%%% subkey <code>sub1</code> with <code>subsub1</code>:</p> +%%% <p>Example 3: require the key <c>myvar</c> with +%%% subkey <c>sub1</c> with <c>subsub1</c>:</p> %%% <pre>ok = ct:require({myvar,sub1,sub2}).</pre> %%% %%% <p>In this case the config file must at least contain:</p> @@ -332,12 +339,12 @@ require(Required) -> %%% of <c>SubKey</c>s. %%% %%% <p>If the requested data is available, the sub entry will be -%%% associated with <code>Name</code> so that the value of the element -%%% can be read with <code>get_config/1,2</code> provided -%%% <code>Name</code> instead of the whole <code>Required</code> term.</p> +%%% associated with <c>Name</c> so that the value of the element +%%% can be read with <c>get_config/1,2</c> provided +%%% <c>Name</c> instead of the whole <c>Required</c> term.</p> %%% %%% <p>Example: Require one node with a telnet connection and an -%%% ftp connection. Name the node <code>a</code>: +%%% ftp connection. Name the node <c>a</c>: %%% <pre>ok = ct:require(a,{machine,node}).</pre> %%% All references to this node may then use the node name. %%% E.g. you can fetch a file over ftp like this:</p> @@ -346,12 +353,12 @@ require(Required) -> %%% <p>For this to work, the config file must at least contain:</p> %%% <pre>{machine,[{node,[{telnet,IpAddr},{ftp,IpAddr}]}]}.</pre> %%% -%%% <note>The behaviour of this function changed radically in common_test +%%% <note><p>The behaviour of this function changed radically in common_test %%% 1.6.2. In order too keep some backwards compatability it is still possible %%% to do: <br/><c>ct:require(a,{node,[telnet,ftp]}).</c><br/> %%% This will associate the name <c>a</c> with the top level <c>node</c> entry. %%% For this to work, the config file must at least contain:<br/> -%%% <c>{node,[{telnet,IpAddr},{ftp,IpAddr}]}.</c></note> +%%% <c>{node,[{telnet,IpAddr},{ftp,IpAddr}]}.</c></p></note> %%% %%% @see require/1 %%% @see get_config/1 @@ -386,7 +393,7 @@ get_config(Required,Default) -> %%% %%% <p>This function returns the matching value(s) or config element(s), %%% given a config variable key or its associated name -%%% (if one has been specified with <code>require/2</code> or a +%%% (if one has been specified with <c>require/2</c> or a %%% require statement).</p> %%% %%% <p>Example, given the following config file:</p> @@ -394,33 +401,33 @@ get_config(Required,Default) -> %%% {unix,[{telnet,IpAddr}, %%% {user,[{username,Username}, %%% {password,Password}]}]}.</pre> -%%% <p><code>ct:get_config(unix,Default) -> +%%% <p><c>ct:get_config(unix,Default) -> %%% [{telnet,IpAddr}, %%% {user, [{username,Username}, -%%% {password,Password}]}]</code><br/> -%%% <code>ct:get_config({unix,telnet},Default) -> IpAddr</code><br/> -%%% <code>ct:get_config({unix,user,username},Default) -> Username</code><br/> -%%% <code>ct:get_config({unix,ftp},Default) -> Default</code><br/> -%%% <code>ct:get_config(unknownkey,Default) -> Default</code></p> +%%% {password,Password}]}]</c><br/> +%%% <c>ct:get_config({unix,telnet},Default) -> IpAddr</c><br/> +%%% <c>ct:get_config({unix,user,username},Default) -> Username</c><br/> +%%% <c>ct:get_config({unix,ftp},Default) -> Default</c><br/> +%%% <c>ct:get_config(unknownkey,Default) -> Default</c></p> %%% %%% <p>If a config variable key has been associated with a name (by -%%% means of <code>require/2</code> or a require statement), the name +%%% means of <c>require/2</c> or a require statement), the name %%% may be used instead of the key to read the value:</p> %%% -%%% <p><code>ct:require(myuser,{unix,user}) -> ok.</code><br/> -%%% <code>ct:get_config(myuser,Default) -> +%%% <p><c>ct:require(myuser,{unix,user}) -> ok.</c><br/> +%%% <c>ct:get_config(myuser,Default) -> %%% [{username,Username}, -%%% {password,Password}]</code></p> +%%% {password,Password}]</c></p> %%% %%% <p>If a config variable is defined in multiple files and you want to -%%% access all possible values, use the <code>all</code> option. The +%%% access all possible values, use the <c>all</c> option. The %%% values will be returned in a list and the order of the elements %%% corresponds to the order that the config files were specified at %%% startup.</p> %%% %%% <p>If you want config elements (key-value tuples) returned as result -%%% instead of values, use the <code>element</code> option. -%%% The returned elements will then be on the form <code>{Required,Value}</code></p> +%%% instead of values, use the <c>element</c> option. +%%% The returned elements will then be on the form <c>{Required,Value}</c></p> %%% %%% @see get_config/1 %%% @see get_config/2 @@ -493,11 +500,11 @@ log(X1,X2,X3) -> %%% <p>This function is meant for printing a string directly from a %%% test case to the test case log file.</p> %%% -%%% <p>Default <code>Category</code> is <code>default</code>, -%%% default <code>Importance</code> is <code>?STD_IMPORTANCE</code>, -%%% and default value for <code>Args</code> is <code>[]</code>.</p> -%%% <p>Please see the User's Guide for details on <code>Category</code> -%%% and <code>Importance</code>.</p> +%%% <p>Default <c>Category</c> is <c>default</c>, +%%% default <c>Importance</c> is <c>?STD_IMPORTANCE</c>, +%%% and default value for <c>Args</c> is <c>[]</c>.</p> +%%% <p>Please see the User's Guide for details on <c>Category</c> +%%% and <c>Importance</c>.</p> log(Category,Importance,Format,Args) -> ct_logs:tc_log(Category,Importance,Format,Args). @@ -547,11 +554,11 @@ print(X1,X2,X3) -> %%% <p>This function is meant for printing a string from a test case %%% to the console.</p> %%% -%%% <p>Default <code>Category</code> is <code>default</code>, -%%% default <code>Importance</code> is <code>?STD_IMPORTANCE</code>, -%%% and default value for <code>Args</code> is <code>[]</code>.</p> -%%% <p>Please see the User's Guide for details on <code>Category</code> -%%% and <code>Importance</code>.</p> +%%% <p>Default <c>Category</c> is <c>default</c>, +%%% default <c>Importance</c> is <c>?STD_IMPORTANCE</c>, +%%% and default value for <c>Args</c> is <c>[]</c>.</p> +%%% <p>Please see the User's Guide for details on <c>Category</c> +%%% and <c>Importance</c>.</p> print(Category,Importance,Format,Args) -> ct_logs:tc_print(Category,Importance,Format,Args). @@ -601,11 +608,11 @@ pal(X1,X2,X3) -> %%% <p>This function is meant for printing a string from a test case, %%% both to the test case log file and to the console.</p> %%% -%%% <p>Default <code>Category</code> is <code>default</code>, -%%% default <code>Importance</code> is <code>?STD_IMPORTANCE</code>, -%%% and default value for <code>Args</code> is <code>[]</code>.</p> -%%% <p>Please see the User's Guide for details on <code>Category</code> -%%% and <code>Importance</code>.</p> +%%% <p>Default <c>Category</c> is <c>default</c>, +%%% default <c>Importance</c> is <c>?STD_IMPORTANCE</c>, +%%% and default value for <c>Args</c> is <c>[]</c>.</p> +%%% <p>Please see the User's Guide for details on <c>Category</c> +%%% and <c>Importance</c>.</p> pal(Category,Importance,Format,Args) -> ct_logs:tc_pal(Category,Importance,Format,Args). @@ -624,7 +631,7 @@ capture_start() -> %%% @spec capture_stop() -> ok %%% %%% @doc Stop capturing text strings (a session started with -%%% <code>capture_start/0</code>). +%%% <c>capture_start/0</c>). %%% %%% @see capture_start/0 %%% @see capture_get/1 @@ -647,9 +654,9 @@ capture_get() -> %%% %%% @doc Return and purge the list of text strings buffered %%% during the latest session of capturing printouts to stdout. -%%% With <code>ExclCategories</code> it's possible to specify -%%% log categories that should be ignored in <code>ListOfStrings</code>. -%%% If <code>ExclCategories = []</code>, no filtering takes place. +%%% With <c>ExclCategories</c> it's possible to specify +%%% log categories that should be ignored in <c>ListOfStrings</c>. +%%% If <c>ExclCategories = []</c>, no filtering takes place. %%% %%% @see capture_start/0 %%% @see capture_stop/0 @@ -674,7 +681,7 @@ capture_get([]) -> %%% Reason = term() %%% %%% @doc Terminate a test case with the given error -%%% <code>Reason</code>. +%%% <c>Reason</c>. fail(Reason) -> try exit({test_case_failed,Reason}) @@ -694,7 +701,7 @@ fail(Reason) -> %%% %%% @doc Terminate a test case with an error message specified %%% by a format string and a list of values (used as arguments to -%%% <code>io_lib:format/2</code>). +%%% <c>io_lib:format/2</c>). fail(Format, Args) -> try io_lib:format(Format, Args) of Str -> @@ -717,11 +724,11 @@ fail(Format, Args) -> %%% @spec comment(Comment) -> void() %%% Comment = term() %%% -%%% @doc Print the given <code>Comment</code> in the comment field in +%%% @doc Print the given <c>Comment</c> in the comment field in %%% the table on the test suite result page. %%% %%% <p>If called several times, only the last comment is printed. -%%% The test case return value <code>{comment,Comment}</code> +%%% The test case return value <c>{comment,Comment}</c> %%% overwrites the string set by this function.</p> comment(Comment) when is_list(Comment) -> Formatted = @@ -744,10 +751,10 @@ comment(Comment) -> %%% @doc Print the formatted string in the comment field in %%% the table on the test suite result page. %%% -%%% <p>The <code>Format</code> and <code>Args</code> arguments are -%%% used in call to <code>io_lib:format/2</code> in order to create -%%% the comment string. The behaviour of <code>comment/2</code> is -%%% otherwise the same as the <code>comment/1</code> function (see +%%% <p>The <c>Format</c> and <c>Args</c> arguments are +%%% used in call to <c>io_lib:format/2</c> in order to create +%%% the comment string. The behaviour of <c>comment/2</c> is +%%% otherwise the same as the <c>comment/1</c> function (see %%% above for details).</p> comment(Format, Args) when is_list(Format), is_list(Args) -> Formatted = @@ -792,11 +799,11 @@ get_target_name(Handle) -> %%% @doc Parse the printout from an SQL table and return a list of tuples. %%% %%% <p>The printout to parse would typically be the result of a -%%% <code>select</code> command in SQL. The returned -%%% <code>Table</code> is a list of tuples, where each tuple is a row +%%% <c>select</c> command in SQL. The returned +%%% <c>Table</c> is a list of tuples, where each tuple is a row %%% in the table.</p> %%% -%%% <p><code>Heading</code> is a tuple of strings representing the +%%% <p><c>Heading</c> is a tuple of strings representing the %%% headings of each column in the table.</p> parse_table(Data) -> ct_util:parse_table(Data). @@ -868,8 +875,8 @@ make_and_load(Dir, Suite) -> %%% SuiteUserData = [term()] %%% Reason = term() %%% -%%% @doc Returns any data specified with the tag <code>userdata</code> -%%% in the list of tuples returned from <code>Suite:suite/0</code>. +%%% @doc Returns any data specified with the tag <c>userdata</c> +%%% in the list of tuples returned from <c>Suite:suite/0</c>. userdata(TestDir, Suite) -> case make_and_load(TestDir, Suite) of E = {error,_} -> @@ -904,9 +911,9 @@ get_userdata(_BadTerm, Spec) -> %%% TCUserData = [term()] %%% Reason = term() %%% -%%% @doc Returns any data specified with the tag <code>userdata</code> -%%% in the list of tuples returned from <code>Suite:group(GroupName)</code> -%%% or <code>Suite:Case()</code>. +%%% @doc Returns any data specified with the tag <c>userdata</c> +%%% in the list of tuples returned from <c>Suite:group(GroupName)</c> +%%% or <c>Suite:Case()</c>. userdata(TestDir, Suite, {group,GroupName}) -> case make_and_load(TestDir, Suite) of E = {error,_} -> @@ -986,7 +993,7 @@ get_testdata(Key) -> %%% executing. The function is therefore only safe to call from a function which %%% has been called (or synchronously invoked) by the test case.</p> %%% -%%% <p><code>Reason</code>, the reason for aborting the test case, is printed +%%% <p><c>Reason</c>, the reason for aborting the test case, is printed %%% in the test case log.</p> abort_current_testcase(Reason) -> test_server_ctrl:abort_current_testcase(Reason). @@ -999,13 +1006,13 @@ abort_current_testcase(Reason) -> %%% Reason = term() %%% %%% @doc <p>This function encrypts the source config file with DES3 and -%%% saves the result in file <code>EncryptFileName</code>. The key, +%%% saves the result in file <c>EncryptFileName</c>. The key, %%% a string, must be available in a text file named -%%% <code>.ct_config.crypt</code> in the current directory, or the +%%% <c>.ct_config.crypt</c> in the current directory, or the %%% home directory of the user (it is searched for in that order).</p> %%% <p>See the Common Test User's Guide for information about using %%% encrypted config files when running tests.</p> -%%% <p>See the <code>crypto</code> application for details on DES3 +%%% <p>See the <c>crypto</c> application for details on DES3 %%% encryption/decryption.</p> encrypt_config_file(SrcFileName, EncryptFileName) -> ct_config:encrypt_config_file(SrcFileName, EncryptFileName). @@ -1019,13 +1026,13 @@ encrypt_config_file(SrcFileName, EncryptFileName) -> %%% Reason = term() %%% %%% @doc <p>This function encrypts the source config file with DES3 and -%%% saves the result in the target file <code>EncryptFileName</code>. +%%% saves the result in the target file <c>EncryptFileName</c>. %%% The encryption key to use is either the value in -%%% <code>{key,Key}</code> or the value stored in the file specified -%%% by <code>{file,File}</code>.</p> +%%% <c>{key,Key}</c> or the value stored in the file specified +%%% by <c>{file,File}</c>.</p> %%% <p>See the Common Test User's Guide for information about using %%% encrypted config files when running tests.</p> -%%% <p>See the <code>crypto</code> application for details on DES3 +%%% <p>See the <c>crypto</c> application for details on DES3 %%% encryption/decryption.</p> encrypt_config_file(SrcFileName, EncryptFileName, KeyOrFile) -> ct_config:encrypt_config_file(SrcFileName, EncryptFileName, KeyOrFile). @@ -1037,11 +1044,11 @@ encrypt_config_file(SrcFileName, EncryptFileName, KeyOrFile) -> %%% TargetFileName = string() %%% Reason = term() %%% -%%% @doc <p>This function decrypts <code>EncryptFileName</code>, previously -%%% generated with <code>encrypt_config_file/2/3</code>. The original +%%% @doc <p>This function decrypts <c>EncryptFileName</c>, previously +%%% generated with <c>encrypt_config_file/2/3</c>. The original %%% file contents is saved in the target file. The encryption key, a %%% string, must be available in a text file named -%%% <code>.ct_config.crypt</code> in the current directory, or the +%%% <c>.ct_config.crypt</c> in the current directory, or the %%% home directory of the user (it is searched for in that order).</p> decrypt_config_file(EncryptFileName, TargetFileName) -> ct_config:decrypt_config_file(EncryptFileName, TargetFileName). @@ -1054,8 +1061,8 @@ decrypt_config_file(EncryptFileName, TargetFileName) -> %%% KeyOrFile = {key,string()} | {file,string()} %%% Reason = term() %%% -%%% @doc <p>This function decrypts <code>EncryptFileName</code>, previously -%%% generated with <code>encrypt_config_file/2/3</code>. The original +%%% @doc <p>This function decrypts <c>EncryptFileName</c>, previously +%%% generated with <c>encrypt_config_file/2/3</c>. The original %%% file contents is saved in the target file. The key must have the %%% the same value as that used for encryption.</p> decrypt_config_file(EncryptFileName, TargetFileName, KeyOrFile) -> @@ -1072,7 +1079,7 @@ decrypt_config_file(EncryptFileName, TargetFileName, KeyOrFile) -> %%% given callback module and configuration string. Callback module %%% should be either loaded or present in the code part. Loaded %%% configuration variables can later be removed using -%%% <code>remove_config/2</code> function.</p> +%%% <c>remove_config/2</c> function.</p> add_config(Callback, Config)-> ct_config:add_config(Callback, Config). @@ -1101,9 +1108,9 @@ remove_config(Callback, Config) -> %%% A = list() %%% %%% @doc <p>Use this function to set a new timetrap for the running test case. -%%% If the argument is <code>Func</code>, the timetrap will be triggered -%%% when this function returns. <code>Func</code> may also return a new -%%% <code>Time</code> value, which in that case will be the value for the +%%% If the argument is <c>Func</c>, the timetrap will be triggered +%%% when this function returns. <c>Func</c> may also return a new +%%% <c>Time</c> value, which in that case will be the value for the %%% new timetrap.</p> timetrap(Time) -> test_server:timetrap_cancel(), @@ -1174,13 +1181,21 @@ sync_notify(Name,Data) -> %%% 'enable break with release_shell option' %%% TestCases = [atom()] %%% -%%% @doc <p>This function will cancel all timetraps and pause the +%%% @doc <p>This function will cancel any active timetrap and pause the %%% execution of the current test case until the user calls the %%% <c>continue/0</c> function. It gives the user the opportunity %%% to interact with the erlang node running the tests, e.g. for %%% debugging purposes or for manually executing a part of the %%% test case. If a parallel group is executing, <c>break/2</c> %%% should be called instead.</p> +%%% <p>A cancelled timetrap will not be automatically +%%% reactivated after the break, but must be started exlicitly with +%%% <c>ct:timetrap/1</c></p> +%%% <p>In order for the break/continue functionality to work, +%%% Common Test must release the shell process controlling stdin. +%%% This is done by setting the <c>release_shell</c> start option +%%% to <c>true</c>. See the User's Guide for more information.</p> + break(Comment) -> case {ct_util:get_testdata(starter), ct_util:get_testdata(release_shell)} of @@ -1191,7 +1206,7 @@ break(Comment) -> {error,'enable break with release_shell option'}; _ -> case get_testdata(curr_tc) of - {ok,{_,TestCase}} -> + {ok,{_,_TestCase}} -> test_server:break(?MODULE, Comment); {ok,Cases} when is_list(Cases) -> {error,{'multiple cases running', @@ -1215,6 +1230,7 @@ break(Comment) -> %%% pause a test case executing in a parallel group. The %%% <c>continue/1</c> function should be used to resume %%% execution of <c>TestCase</c>.</p> +%%% <p>See <c>break/1</c> for more details.</p> break(TestCase, Comment) -> case {ct_util:get_testdata(starter), ct_util:get_testdata(release_shell)} of diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1.cfg b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1.cfg index 6466571623..b431301df6 100644 --- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1.cfg +++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1.cfg @@ -1,5 +1,5 @@ %% -*- erlang -*- -{netconf1,[{ssh,"localhost"}, +{netconf1,[{ssh,"127.0.0.1"}, {port,2060}, {user,"xxx"}, {password,"xxx"}]}. diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl index 79768a9a6a..d337158bce 100644 --- a/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl +++ b/lib/common_test/test/ct_netconfc_SUITE_data/netconfc1_SUITE.erl @@ -107,7 +107,8 @@ all() -> connection_crash, get_event_streams, create_subscription, - receive_event] + receive_event + ] end. @@ -216,6 +217,7 @@ hello_required_exists(Config) -> ?NS:expect_do_reply('close-session',close,ok), ?ok = ct_netconfc:close_session(my_named_connection), + timer:sleep(500), %% Then check that it can be used again after the first is closed {ok,_Client2} = open_configured_success(my_named_connection,DataDir), @@ -234,7 +236,7 @@ hello_global_pwd(Config) -> hello_no_session_id(Config) -> DataDir = ?config(data_dir,Config), ?NS:hello(no_session_id), - ?NS:expect(hello), + ?NS:expect(no_session_id,hello), {error,{incorrect_hello,no_session_id_found}} = open(DataDir), ok. @@ -261,7 +263,7 @@ hello_no_caps(Config) -> no_server_hello(Config) -> DataDir = ?config(data_dir,Config), - ?NS:expect(hello), + ?NS:expect(undefined,hello), {error,{hello_session_failed,timeout}} = open(DataDir,[{timeout,2000}]), ok. @@ -435,7 +437,7 @@ kill_session(Config) -> {ok,Client} = open_success(DataDir), ?NS:hello(2), - ?NS:expect(hello), + ?NS:expect(2,hello), {ok,_OtherClient} = open(DataDir), ?NS:expect_do_reply('kill-session',{kill,2},ok), diff --git a/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl b/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl index 665b0e556c..2427f37f52 100644 --- a/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl +++ b/lib/common_test/test/ct_netconfc_SUITE_data/ns.erl @@ -31,9 +31,13 @@ hello/1, hello/2, expect/1, + expect/2, expect_reply/2, + expect_reply/3, expect_do/2, + expect_do/3, expect_do_reply/3, + expect_do_reply/4, hupp/1, hupp/2]). @@ -110,22 +114,30 @@ hello(SessionId,Stuff) -> %% actions. To be called directly before sending a request. expect(Expect) -> expect_do_reply(Expect,undefined,undefined). +expect(SessionId,Expect) -> + expect_do_reply(SessionId,Expect,undefined,undefined). %% Tell server to expect the given message and reply with the give %% reply. To be called directly before sending a request. expect_reply(Expect,Reply) -> expect_do_reply(Expect,undefined,Reply). +expect_reply(SessionId,Expect,Reply) -> + expect_do_reply(SessionId,Expect,undefined,Reply). %% Tell server to expect the given message and perform an action. To %% be called directly before sending a request. expect_do(Expect,Do) -> expect_do_reply(Expect,Do,undefined). +expect_do(SessionId,Expect,Do) -> + expect_do_reply(SessionId,Expect,Do,undefined). %% Tell server to expect the given message, perform an action and %% reply with the given reply. To be called directly before sending a %% request. expect_do_reply(Expect,Do,Reply) -> - add_expect({Expect,Do,Reply}). + add_expect(1,{Expect,Do,Reply}). +expect_do_reply(SessionId,Expect,Do,Reply) -> + add_expect(SessionId,{Expect,Do,Reply}). %% Hupp the server - i.e. tell it to do something - %% e.g. hupp(send_event) will cause send_event(State) to be called on @@ -133,17 +145,19 @@ expect_do_reply(Expect,Do,Reply) -> hupp(send_event) -> hupp(send,[make_msg(event)]); hupp(kill) -> - hupp(fun hupp_kill/1,[]). + hupp(1,fun hupp_kill/1,[]). hupp(send,Data) -> - hupp(fun hupp_send/2,[Data]); -hupp(Fun,Args) when is_function(Fun) -> - [{_,Pid}] = lookup(channel_process), + hupp(1,fun hupp_send/2,[Data]). + +hupp(SessionId,Fun,Args) when is_function(Fun) -> + [{_,Pid}] = lookup({channel_process,SessionId}), Pid ! {hupp,Fun,Args}. %%%----------------------------------------------------------------- %%% Main loop of the netconf server init_server(Dir) -> + register(main_ns_proc,self()), ets:new(ns_tab,[set,named_table,public]), Config = ?ssh_config(Dir), {_,Host} = lists:keyfind(interface, 1, Config), @@ -165,7 +179,12 @@ loop(Daemon) -> receive {stop,From} -> ssh:stop_daemon(Daemon), - From ! stopped + From ! stopped; + {table_trans,Fun,Args,From} -> + %% Simple transaction mechanism for ets table + R = apply(Fun,Args), + From ! {table_trans_done,R}, + loop(Daemon) end. %%---------------------------------------------------------------------- @@ -178,7 +197,7 @@ terminate(_Reason, _State) -> ok. handle_ssh_msg({ssh_cm,CM,{data, Ch, _Type = 0, Data}}, State) -> - %% erlang:display({self(),data,CM,Ch,State}), + %% io:format("~p~n",[{self(),Data,CM,Ch,State}]), data_for_channel(CM, Ch, Data, State); handle_ssh_msg({ssh_cm,CM,{closed, Ch}}, State) -> %% erlang:display({self(),closed,CM,Ch,State}), @@ -194,7 +213,7 @@ handle_msg({ssh_channel_up,Ch,CM},undefined) -> %% erlang:display({self(),up,CM,Ch}), ConnRef = {CM,Ch}, SessionId = maybe_hello(ConnRef), - insert(channel_process,self()), % used to hupp the server + insert({channel_process,SessionId},self()), % used to hupp the server {ok, #session{connection = ConnRef, session_id = SessionId}}; handle_msg({hupp,Fun,Args},State) -> @@ -214,17 +233,19 @@ data_for_channel(CM, Ch, Data, State) -> Stacktrace = erlang:get_stacktrace(), error_logger:error_report([{?MODULE, data_for_channel}, {request, Data}, + {buffer, State#session.buffer}, {reason, {Class, Reason}}, {stacktrace, Stacktrace}]), stop_channel(CM, Ch, State) end. data(Data, State = #session{connection = ConnRef, - buffer = Buffer}) -> + buffer = Buffer, + session_id = SessionId}) -> AllData = <<Buffer/binary,Data/binary>>, case find_endtag(AllData) of {ok,Msgs,Rest} -> - [check_expected(ConnRef,Msg) || Msg <- Msgs], + [check_expected(SessionId,ConnRef,Msg) || Msg <- Msgs], {ok,State#session{buffer=Rest}}; need_more -> {ok,State#session{buffer=AllData}} @@ -258,15 +279,42 @@ send({CM,Ch},Data) -> kill({CM,_Ch}) -> ssh:close(CM). -add_expect(Add) -> - case lookup(expect) of +add_expect(SessionId,Add) -> + table_trans(fun do_add_expect/2,[SessionId,Add]). + +table_trans(Fun,Args) -> + S = self(), + case whereis(main_ns_proc) of + S -> + apply(Fun,Args); + Pid -> + Pid ! {table_trans,Fun,Args,self()}, + receive + {table_trans_done,Result} -> + Result + after 5000 -> + exit(table_trans_timeout) + end + end. + +do_add_expect(SessionId,Add) -> + case lookup({expect,SessionId}) of [] -> - insert(expect,[Add]); - [{expect,First}] -> - insert(expect,First ++ [Add]) + insert({expect,SessionId},[Add]); + [{_,First}] -> + insert({expect,SessionId},First ++ [Add]) end, ok. +do_get_expect(SessionId) -> + case lookup({expect,SessionId}) of + [{_,[{Expect,Do,Reply}|Rest]}] -> + insert({expect,SessionId},Rest), + {Expect,Do,Reply}; + _ -> + error + end. + insert(Key,Value) -> ets:insert(ns_tab,{Key,Value}). lookup(Key) -> @@ -292,17 +340,18 @@ find_endtag(Data) -> {ok,lists:sublist(Msgs,length(Msgs)-1),lists:last(Msgs)} end. -check_expected(ConnRef,Msg) -> - case lookup(expect) of - [{expect,[{Expect,Do,Reply}|Rest]}] -> - insert(expect,Rest), +check_expected(SessionId,ConnRef,Msg) -> + %% io:format("~p~n",[{check_expected,SessionId,Msg}]), + case table_trans(fun do_get_expect/1,[SessionId]) of + {Expect,Do,Reply} -> %% erlang:display({got,io_lib:format("~s",[Msg])}), %% erlang:display({expected,Expect}), match(Msg,Expect), do(ConnRef, Do), reply(ConnRef,Reply); - Expected -> - exit({error,{got_unexpected,Msg,Expected}}) + error -> + timer:sleep(1000), + exit({error,{got_unexpected,SessionId,Msg,ets:tab2list(ns_tab)}}) end. match(Msg,Expect) -> diff --git a/lib/compiler/doc/src/compile.xml b/lib/compiler/doc/src/compile.xml index be9eb1cd75..27d750f929 100644 --- a/lib/compiler/doc/src/compile.xml +++ b/lib/compiler/doc/src/compile.xml @@ -316,7 +316,7 @@ module.beam: module.erl \ <item> <p>Add <c>Dir</c> to the list of directories to be searched when including a file. When encountering an - <c>-include</c> or <c>-include_dir</c> directive, + <c>-include</c> or <c>-include_lib</c> directive, the compiler searches for header files in the following directories:</p> <list type="ordered"> diff --git a/lib/crypto/c_src/crypto.c b/lib/crypto/c_src/crypto.c index a24747a872..91ab244620 100644 --- a/lib/crypto/c_src/crypto.c +++ b/lib/crypto/c_src/crypto.c @@ -1875,7 +1875,7 @@ static int get_rsa_private_key(ErlNifEnv* env, ERL_NIF_TERM key, RSA *rsa) static ERL_NIF_TERM rsa_sign_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {/* (Type, Data|{digest,Digest}, Key=[E,N,D]|[E,N,D,P1,P2,E1,E2,C]) */ ErlNifBinary data_bin, ret_bin; - unsigned char hmacbuf[SHA_DIGEST_LENGTH]; + unsigned char hmacbuf[SHA512_LEN]; unsigned rsa_s_len; RSA* rsa; int i; diff --git a/lib/crypto/test/crypto_SUITE.erl b/lib/crypto/test/crypto_SUITE.erl index 1b5bc44dde..7ac693f371 100644 --- a/lib/crypto/test/crypto_SUITE.erl +++ b/lib/crypto/test/crypto_SUITE.erl @@ -349,6 +349,14 @@ hmac_update_sha256(doc) -> hmac_update_sha256(suite) -> []; hmac_update_sha256(Config) when is_list(Config) -> + case openssl_version() of + V when V < 16#908000 -> + {skipped,"OpenSSL version too old"}; + _ -> + hmac_update_sha256_do() + end. + +hmac_update_sha256_do() -> ?line Key = hexstr2bin("00010203101112132021222330313233" "04050607141516172425262734353637" "08090a0b18191a1b28292a2b38393a3b" @@ -368,6 +376,14 @@ hmac_update_sha512(doc) -> hmac_update_sha512(suite) -> []; hmac_update_sha512(Config) when is_list(Config) -> + case openssl_version() of + V when V < 16#908000 -> + {skipped,"OpenSSL version too old"}; + _ -> + hmac_update_sha512_do() + end. + +hmac_update_sha512_do() -> ?line Key = hexstr2bin("00010203101112132021222330313233" "04050607141516172425262734353637" "08090a0b18191a1b28292a2b38393a3b" @@ -406,6 +422,14 @@ hmac_rfc4231(doc) -> hmac_rfc4231(suite) -> []; hmac_rfc4231(Config) when is_list(Config) -> + case openssl_version() of + V when V < 16#908000 -> + {skipped,"OpenSSL version too old"}; + _ -> + hmac_rfc4231_do() + end. + +hmac_rfc4231_do() -> %% Test Case 1 Case1Key = binary:copy(<<16#0b>>, 20), Case1Data = <<"Hi There">>, @@ -1927,3 +1951,11 @@ my_dss_sign(Data,Key) -> ?line S3 = crypto:dss_sign(none, crypto:sha(Raw), Key), [S1,S2,S3]. +openssl_version() -> + case crypto:info_lib() of + [{<<"OpenSSL">>,LibVer,_}] when is_integer(LibVer) -> + LibVer; + _ -> + undefined + end. + diff --git a/lib/diameter/doc/src/diameter.xml b/lib/diameter/doc/src/diameter.xml index 10139b90c7..b8652a7482 100644 --- a/lib/diameter/doc/src/diameter.xml +++ b/lib/diameter/doc/src/diameter.xml @@ -5,7 +5,7 @@ <header> <copyright> -<year>2011</year> +<year>2011</year><year>2012</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -43,13 +43,13 @@ under the License. <description> <p> -This module provides the interface with which a user -creates a service that sends and receives messages using the +This module provides the interface with which a user can +implement a Diameter node that sends and receives messages using the Diameter protocol as defined in RFC 3588.</p> <p> Basic usage consists of creating a representation of a -locally implemented Diameter peer and its capabilities with <seealso +locally implemented Diameter node and its capabilities with <seealso marker="#start_service">start_service/2</seealso>, adding transport capability using <seealso marker="#add_transport">add_transport/2</seealso> and sending Diameter @@ -61,17 +61,15 @@ marker="diameter_app">diameter_app(3)</seealso> callback modules as specified in the service configuration.</p> <p> -Beware the difference between <em>diameter application</em> and -<em>Diameter application</em>. +Beware the difference between <em>diameter</em> (not capitalised) and +<em>Diameter</em> (capitalised). The former refers to the Erlang application named diameter whose main -api is defined here, the latter to an application of the Diameter -protocol in the sense of RFC 3588. -More generally, capitalized Diameter refers to the RFC -and diameter to this implementation.</p> +api is defined here, the latter to Diameter protocol in the sense of +RFC 3588.</p> <p> -The diameter application must be started before calling functions in -this module.</p> +The diameter application must be started before calling most functions +in this module.</p> </description> @@ -84,13 +82,15 @@ this module.</p> <tag><c>Address()</c></tag> <tag><c>DiameterIdentity()</c></tag> +<tag><c>Grouped()</c></tag> +<tag><c>OctetString()</c></tag> <tag><c>Time()</c></tag> <tag><c>Unsigned32()</c></tag> <tag><c>UTF8String()</c></tag> <item> <p> Types corresponding to RFC 3588 AVP Data Formats. -Defined in <seealso marker="diameter_dict">diameter_dict(4)</seealso>.</p> +Defined in <seealso marker="diameter_dict#DATA_TYPES">diameter_dict(4)</seealso>.</p> <marker id="application_alias"/> </item> @@ -99,10 +99,9 @@ Defined in <seealso marker="diameter_dict">diameter_dict(4)</seealso>.</p> <item> <p> A name identifying a Diameter application in -service configuration passed to <seealso -marker="#start_service">start_service/2</seealso> and passed to -<seealso marker="#call">call/4</seealso> when sending requests -belonging to the application.</p> +service configuration. +Passed to <seealso marker="#call">call/4</seealso> when sending requests +defined by the application.</p> <marker id="application_module"/> </item> @@ -120,19 +119,14 @@ ExtraArgs = list() A module implementing the callback interface defined in <seealso marker="diameter_app">diameter_app(3)</seealso>, along with any extra arguments to be appended to those documented for the interface. -Any extra arguments are appended to the documented list of arguments for -each function. -Note that additional arguments specific to an outgoing request be +Note that extra arguments specific to an outgoing request can be specified to <seealso marker="#call">call/4</seealso>, in which case -the call-specific arguments are appended to any specified with the -callback module.</p> +those are are appended to any module-specific extra arguments.</p> <p> Specifying a <c>#diameter_callback{}</c> record allows individual functions to be configured in place of the usual <seealso -marker="diameter_app">diameter_app(3)</seealso> callbacks, with -default implementations provided by module <c>diameter_callback</c> -unless otherwise specified. +marker="diameter_app">diameter_app(3)</seealso> callbacks. See that module for details.</p> <marker id="application_opt"/> @@ -142,18 +136,18 @@ See that module for details.</p> <item> <p> -Options defining a Diameter application as configured in an -<c>application</c> option passed to -<seealso marker="#start_service">start_service/2</seealso>.</p> +Options defining a Diameter application. +Has one the following types.</p> <taglist> -<tag><c>{alias, application_alias()}</c></tag> +<tag><c>{alias, <seealso marker="#application_alias">application_alias()</seealso>}</c></tag> <item> <p> An unique identifier for the application in the scope of the service. -Optional, defaults to the value of the <c>dictionary</c> option.</p> +Defaults to the value of the <c>dictionary</c> option if +unspecified.</p> </item> <tag><c>{dictionary, atom()}</c></tag> @@ -166,23 +160,23 @@ documented in <seealso marker="diameter_dict">diameter_dict(4)</seealso>.</p> </item> -<tag><c>{module, application_module()}</c></tag> +<tag><c>{module, <seealso marker="#application_module">application_module()</seealso>}</c></tag> <item> <p> -A callback module with which messages of the Diameter application are +The callback module with which messages of the Diameter application are handled. See <seealso marker="diameter_app">diameter_app(3)</seealso> for -information on the required interface and semantics.</p> +the required interface and semantics.</p> </item> <tag><c>{state, term()}</c></tag> <item> <p> The initial callback state. -Defaults to the value of the <c>alias</c> option if unspecified. -The prevailing state is passed to certain +The prevailing state is passed to some <seealso marker="diameter_app">diameter_app(3)</seealso> -callbacks, which can then return a new state.</p> +callbacks, which can then return a new state. +Defaults to the value of the <c>alias</c> option if unspecified.</p> </item> <tag><c>{call_mutates_state, true|false}</c></tag> @@ -190,19 +184,18 @@ callbacks, which can then return a new state.</p> <p> Specifies whether or not the <seealso marker="diameter_app#pick_peer">pick_peer/4</seealso> -application callback (following from a call to -<seealso marker="#call">call/4</seealso>) -can modifiy state, +application callback can modify the application state, Defaults to <c>false</c> if unspecified.</p> +<note> <p> -Note that <seealso -marker="diameter_app#pick_peer">pick_peer</seealso> callbacks are -serialized when these are allowed to modify state, which is a +<seealso marker="diameter_app#pick_peer">pick_peer</seealso> callbacks +are serialized when these are allowed to modify state, which is a potential performance bottleneck. A simple Diameter client may suffer no ill effects from using mutable -state but a server or agent that responds to incoming request but -sending its own requests should probably avoid it.</p> +state but a server or agent that responds to incoming request should +probably avoid it.</p> +</note> </item> <tag><c>{answer_errors, callback|report|discard}</c></tag> @@ -213,9 +206,9 @@ decode errors are handled. If <c>callback</c> then errors result in a <seealso marker="diameter_app#handle_answer">handle_answer/4</seealso> callback in the same fashion as for <seealso -marker="diameter_app#handle_request">handle_request/3</seealso>, in the -<c>errors</c> field of the <c>diameter_packet</c> record passed into -the callback. +marker="diameter_app#handle_request">handle_request/3</seealso>, with +errors communicated in the <c>errors</c> field of the +<c>#diameter_packet{}</c> record passed to the callback. If <c>report</c> then an answer containing errors is discarded without a callback and a warning report is written to the log. If <c>discard</c> then an answer containing errors is silently @@ -239,7 +232,8 @@ Defaults to <c>report</c> if unspecified.</p> <p> Options available to <seealso marker="#call">call/4</seealso> when -sending an outgoing Diameter request.</p> +sending an outgoing Diameter request. +Has one of the following types.</p> <taglist> @@ -248,12 +242,12 @@ sending an outgoing Diameter request.</p> <p> Extra arguments to append to callbacks to the callback module in question. -These are appended to any extra arguments configured with the callback +These are appended to any extra arguments configured on the callback itself. Multiple options append to the argument list.</p> </item> -<tag><c>{filter, peer_filter()}</c></tag> +<tag><c>{filter, <seealso marker="#peer_filter">peer_filter()</seealso>}</c></tag> <item> <p> A filter to apply to the list of available peers before passing them to @@ -264,7 +258,7 @@ corresponding list of filters. Defaults to <c>none</c>.</p> </item> -<tag><c>{timeout, Unsigned32()}</c></tag> +<tag><c>{timeout, <seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>}</c></tag> <item> <p> The number of milliseconds after which the request should @@ -298,121 +292,55 @@ to fail.</p> <item> <p> -AVP values used in outgoing CER/CEA messages during capabilities exchange. -Can be configured both on a service and a transport, the latter taking -precedence over the former.</p> +AVP values sent in outgoing CER or CEA messages during capabilities +exchange. +Can be configured both on a service and a transport, values specified +on the latter taking precedence over any specified on the former. +Has one of the following types.</p> <taglist> -<tag><c>{'Origin-Host', DiameterIdentity()}</c></tag> -<item> -<p> -Value of the Origin-Host AVP in outgoing messages.</p> -</item> - -<tag><c>{'Origin-Realm', DiameterIdentity()}</c></tag> -<item> -<p> -Value of the Origin-Realm AVP in outgoing messages.</p> -</item> - -<tag><c>{'Host-IP-Address', [Address()]}</c></tag> -<item> -<p> -Values of Host-IP-Address AVPs. -Optional.</p> - -<p> -The list of addresses is available to the start function of a -transport module, which either uses them as is or returns a new list -(typically as configured as <c>transport_config()</c> on the -transport module in question) in order for the correct list of -addresses to be sent in capabilities exchange messages.</p> -</item> - -<tag><c>{'Vendor-Id', Unsigned32()}</c></tag> +<tag><c>{'Origin-Host', <seealso marker="diameter_dict#DATA_TYPES">DiameterIdentity()</seealso>}</c></tag> +<tag><c>{'Origin-Realm', <seealso marker="diameter_dict#DATA_TYPES">DiameterIdentity()</seealso>}</c></tag> +<tag><c>{'Host-IP-Address', [<seealso marker="diameter_dict#DATA_TYPES">Address()</seealso>]}</c></tag> <item> <p> -Value of the Vendor-Id AVP sent in an outgoing capabilities -exchange message.</p> +An address list is available to the start function of a +<seealso marker="diameter_transport">transport module</seealso>, which +can return a new list for use in the subsequent CER or CEA. +Host-IP-Address need not be specified if the transport start function +returns an address list.</p> </item> -<tag><c>{'Product-Name', UTF8String()}</c></tag> +<tag><c>{'Vendor-Id', <seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>}</c></tag> +<tag><c>{'Product-Name', <seealso marker="diameter_dict#DATA_TYPES">UTF8String()</seealso>}</c></tag> +<tag><c>{'Origin-State-Id', <seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>}</c></tag> <item> <p> -Value of the Product-Name AVP sent in an outgoing capabilities -exchange message.</p> -</item> - -<tag><c>{'Origin-State-Id', Unsigned32()}</c></tag> -<item> -<p> -Value of Origin-State-Id to be included in outgoing messages sent by -diameter itself. -In particular, the AVP will be included in CER/CEA and DWR/DWA messages. -Optional.</p> - -<p> +Origin-State-Id is optional but will be included in outgoing messages +sent by diameter itself: CER/CEA, DWR/DWA and DPR/DPA. Setting a value of <c>0</c> (zero) is equivalent to not setting a value as documented in RFC 3588. The function <seealso marker="#origin_state_id">origin_state_id/0</seealso> -can be used as to retrieve a value that is set when the diameter +can be used as to retrieve a value that is computed when the diameter application is started.</p> </item> -<tag><c>{'Supported-Vendor-Id', [Unsigned32()]}</c></tag> +<tag><c>{'Supported-Vendor-Id', [<seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>]}</c></tag> +<tag><c>{'Auth-Application-Id', [<seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>]}</c></tag> +<tag><c>{'Inband-Security-Id', [<seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>]}</c></tag> <item> <p> -Values of Supported-Vendor-Id AVPs sent in an outgoing -capabilities exchange message. -Optional, defaults to the empty list.</p> -</item> - -<tag><c>{'Auth-Application-Id', [Unsigned32()]}</c></tag> -<item> -<p> -Values of Auth-Application-Id AVPs sent in an outgoing -capabilities exchange message. -Optional, defaults to the empty list.</p> -</item> - -<tag><c>{'Inband-Security-Id', [Unsigned32()]}</c></tag> -<item> -<p> -Values of Inband-Security-Id AVPs sent in an outgoing -capabilities exchange message. -Optional, defaults to the empty list, which is equivalent to a -list containing only 0 (= NO_INBAND_SECURITY).</p> - -<p> +Inband-Security-Id defaults to the empty list, which is equivalent to a +list containing only 0 (= NO_INBAND_SECURITY). If 1 (= TLS) is specified then TLS is selected if the CER/CEA received from the peer offers it.</p> </item> -<tag><c>{'Acct-Application-Id', [Unsigned32()]}</c></tag> -<item> -<p> -Values of Acct-Application-Id AVPs sent in an outgoing -capabilities exchange message. -Optional, defaults to the empty list.</p> -</item> - -<tag><c>{'Vendor-Specific-Application-Id', [Grouped()]}</c></tag> -<item> -<p> -Values of Vendor-Specific-Application-Id AVPs sent in -an outgoing capabilities exchange message. -Optional, defaults to the empty list.</p> -</item> - -<tag><c>{'Firmware-Revision', Unsigned32()}</c></tag> -<item> -<p> -Value of the Firmware-Revision AVP sent in an outgoing capabilities -exchange message. -Optional.</p> -</item> +<tag><c>{'Acct-Application-Id', [<seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>]}</c></tag> +<tag><c>{'Vendor-Specific-Application-Id', [<seealso marker="diameter_dict#DATA_TYPES">Grouped()</seealso>]}</c></tag> +<tag><c>{'Firmware-Revision', <seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>}</c></tag> </taglist> @@ -441,14 +369,17 @@ eval(F) -> </code> <p> -Applying an evaluable() <c>E</c> to an argument list <c>A</c> +Applying an <c><seealso marker="#evaluable">evaluable()</seealso></c> +<c>E</c> to an argument list <c>A</c> is meant in the sense of <c>eval([E|A])</c>.</p> +<warning> <p> -Beware of using local funs (that is, fun expressions not of the -form <c>fun Module:Name/Arity</c>) in situations in which the fun is -not short-lived and code is to be upgraded at runtime since any -processes retaining such a fun will have a reference to old code.</p> +Beware of using fun expressions of the form <c>fun Name/Arity</c> (not +fun Mod:Name/Arity) in situations in which the fun is not short-lived +and code is to be upgraded at runtime since any processes retaining +such a fun will have a reference to old code.</p> +</warning> <marker id="peer_filter"/> </item> @@ -490,63 +421,76 @@ or any peer if the request does not contain a <c>Destination-Realm</c> AVP.</p> </item> -<tag><c>{host, any|DiameterIdentity()}</c></tag> +<tag><c>{host, any|<seealso marker="diameter_dict#DATA_TYPES">DiameterIdentity()</seealso>}</c></tag> <item> <p> Matches only those peers whose <c>Origin-Host</c> has the specified value, or all peers if the atom <c>any</c>.</p> </item> -<tag><c>{realm, any|DiameterIdentity()</c></tag> +<tag><c>{realm, any|<seealso marker="diameter_dict#DATA_TYPES">DiameterIdentity()</seealso></c></tag> <item> <p> Matches only those peers whose <c>Origin-Realm</c> has the -value, or all peers if the atom <c>any</c>.</p> +specified value, or all peers if the atom <c>any</c>.</p> </item> -<tag><c>{eval, evaluable()}</c></tag> +<tag><c>{eval, <seealso marker="#evaluable">evaluable()</seealso>}</c></tag> <item> <p> -Matches only those peers for which the specified evaluable() returns +Matches only those peers for which the specified <c><seealso +marker="#evaluable">evaluable()</seealso></c> returns <c>true</c> on the connection's <c>diameter_caps</c> record. Any other return value or exception is equivalent to <c>false</c>.</p> </item> -<tag><c>{neg, peer_filter()}</c></tag> +<tag><c>{neg, <seealso marker="#peer_filter">peer_filter()</seealso>}</c></tag> <item> <p> Matches only those peers not matched by the specified filter.</p> </item> -<tag><c>{all, [peer_filter()]}</c></tag> +<tag><c>{all, [<seealso marker="#peer_filter">peer_filter()</seealso>]}</c></tag> <item> <p> -Matches only those peers matched by each filter of the specified list.</p> +Matches only those peers matched by each filter in the specified list.</p> </item> -<tag><c>{any, [peer_filter()]}</c></tag> +<tag><c>{any, [<seealso marker="#peer_filter">peer_filter()</seealso>]}</c></tag> <item> <p> -Matches only those peers matched by at least one filter of the +Matches only those peers matched by at least one filter in the specified list.</p> </item> </taglist> <p> -Note that the <c>host</c> and <c>realm</c> filters examine the +An invalid filter is equivalent to <c>{any,[]}</c>, a filter +that matches no peer.</p> + +<note> +<p> +The <c>host</c> and <c>realm</c> filters examine the outgoing request as passed to <seealso marker="#call">call/4</seealso>, -assuming that this is a record- or list-valued message() as documented -in <seealso marker="diameter_app">diameter_app(3)</seealso>, and that -the message contains at most one of each AVP. -If this is not the case then the <c>{host|realm, DiameterIdentity()}</c> +assuming that this is a record- or list-valued <c><seealso +marker="diameter_app#message">diameter_app:message()</seealso></c>, +and that the message contains at most one of each AVP. +If this is not the case then the <c>{host|realm, <seealso +marker="diameter_dict#DATA_TYPES">DiameterIdentity()</seealso>}</c> filters must be used to achieve the desired result. -Note also that an empty host/realm (which should not be typical) -is equivalent to an unspecified one for the purposes of filtering.</p> +An empty <c><seealso +marker="diameter_dict#DATA_TYPES">DiameterIdentity()</seealso></c> +(which should not be typical) +matches all hosts/realms for the purposes of filtering.</p> +</note> +<warning> <p> -An invalid filter is equivalent to <c>{any, []}</c>, a filter -that matches no peer.</p> +A <c>host</c> filter is not typically desirable when setting +Destination-Host since it will remove peer agents from the +candidates list.</p> +</warning> <marker id="service_event"/> </item> @@ -554,12 +498,12 @@ that matches no peer.</p> <tag><c>service_event() = #diameter_event{}</c></tag> <item> <p> -Event message sent to processes that have subscribed using <seealso -marker="#subscribe">subscribe/1</seealso>.</p> +An event message sent to processes that have subscribed to these using +<seealso marker="#subscribe">subscribe/1</seealso>.</p> <p> -The <c>info</c> field of the event record can be one of the -following.</p> +The <c>info</c> field of the event record can have one of the +following types.</p> <taglist> @@ -568,27 +512,27 @@ following.</p> <tag><c>{down, Ref, Peer, Config}</c></tag> <item> <code> -Ref = transport_ref() -Peer = diameter_app:peer() -Config = {connect|listen, [transport_opt()]} +Ref = <seealso marker="#transport_ref">transport_ref()</seealso> +Peer = <seealso marker="diameter_app#peer">diameter_app:peer()</seealso> +Config = {connect|listen, [<seealso marker="#transport_opt">transport_opt()</seealso>]} Pkt = #diameter_packet{} </code> <p> The RFC 3539 watchdog state machine has -transitioned into (<c>up</c>) or out of (<c>down</c>) the open +transitioned into (<c>up</c>) or out of (<c>down</c>) the OKAY state. -If a <c>diameter_packet</c> record is present in an <c>up</c> tuple -then there has been an exchange of capabilities exchange messages and -the record contains the received CER or CEA, otherwise the -connection has reestablished without the loss or transport +If a <c>#diameter_packet{}</c> record is present in an <c>up</c> event +then there has been a capabilties exchange on a newly established +transport connection and the record contains the received CER or CEA. +Otherwise a connection has reestablished without the loss or connectivity.</p> <p> -Note that a single up/down event for a given peer corresponds to -as many <seealso marker="diameter_app#peer_up">peer_up/peer_down</seealso> -callbacks as there are Diameter applications shared by the peer, -as determined during capablilities exchange. +Note that a single <c>up</c>/<c>down</c> event for a given peer +corresponds to one <seealso marker="diameter_app#peer_up">peer_up/peer_down</seealso> +callback for each of the Diameter applications negotiated during +capablilities exchange. That is, the event communicates connectivity with the peer as a whole while the callbacks communicate connectivity with respect to individual Diameter applications.</p> @@ -597,26 +541,28 @@ respect to individual Diameter applications.</p> <tag><c>{reconnect, Ref, Opts}</c></tag> <item> <code> -Ref = transport_ref() -Opts = [transport_opt()] +Ref = <seealso marker="#transport_ref">transport_ref()</seealso> +Opts = [<seealso marker="#transport_opt">transport_opt()</seealso>] </code> <p> A connecting transport is attempting to establish/reestablish a -transport connection with a peer following <c>reconnect_timer</c> or -<c>watchdog_timer</c> expiry.</p> +transport connection with a peer following <seealso +marker="#reconnect_timer">reconnect_timer</seealso> or +<seealso marker="#watchdog_timer">watchdog_timer</seealso> +expiry.</p> </item> <tag><c>{closed, Ref, Reason, Config}</c></tag> <item> <code> -Ref = transport_ref() -Config = {connect|listen, [transport_opt()]} +Ref = <seealso marker="#transport_ref">transport_ref()</seealso> +Config = {connect|listen, [<seealso marker="#transport_opt">transport_opt()</seealso>]} </code> <p> -Capabilities exchange has failed. <c>Reason</c> can be one of -the following.</p> +Capabilities exchange has failed. +<c>Reason</c> can have one of the following types.</p> <taglist> @@ -627,17 +573,17 @@ Result = ResultCode | {capabilities_cb, CB, ResultCode|discard} Caps = #diameter_caps{} Pkt = #diameter_packet{} ResultCode = integer() -CB = evaluable() +CB = <seealso marker="#evaluable">evaluable()</seealso> </code> <p> An incoming CER has been answered with the indicated result code or discarded. -The capabilities record contains pairs of values for the the local -node and remote peer. -The packet record contains the CER in question. +<c>Caps</c> contains pairs of values for the the local node and remote +peer. +<c>Pkt</c> contains the CER in question. In the case of rejection by a capabilities callback, the tuple -indicates the rejecting callback.</p> +contains the rejecting callback.</p> </item> <tag><c>{'CER', Caps, {ResultCode, Pkt}}</c></tag> @@ -651,9 +597,8 @@ Pkt = #diameter_packet{} <p> An incoming CER contained errors and has been answered with the indicated result code. -The capabilities record contains only values for the the local -node. -The packet record contains the CER in question.</p> +<c>Caps</c> contains only values for the the local node. +<c>Pkt</c> contains the CER in question.</p> </item> <tag><c>{'CEA', Result, Caps, Pkt}</c></tag> @@ -669,11 +614,11 @@ ResultCode = integer() An incoming CEA has been rejected for the indicated reason. An integer-valued <c>Result</c> indicates the result code sent by the peer. -The capabilities record contains pairs of values for the the local -node and remote peer. -The packet record contains the CEA in question. +<c>Caps</c> contains pairs of values for the the local node and remote +peer. +<c>Pkt</c> contains the CEA in question. In the case of rejection by a capabilities callback, the tuple -indicates the rejecting callback.</p> +contains the rejecting callback.</p> </item> <tag><c>{'CEA', Caps, Pkt}</c></tag> @@ -684,9 +629,9 @@ Pkt = #diameter_packet{} </code> <p> -An incoming CER contained errors and has been rejected. -The capabilities record contains only values for the the local node. -The packet record contains the CEA in question.</p> +An incoming CEA contained errors and has been rejected. +<c>Caps</c> contains only values for the the local node. +<c>Pkt</c> contains the CEA in question.</p> </item> </taglist> @@ -695,8 +640,8 @@ The packet record contains the CEA in question.</p> <tag><c>{watchdog, Ref, PeerRef, {From, To}, Config}</c></tag> <item> <code> -Ref = transport_ref() -PeerRef = diameter_app:peer_ref() +Ref = <seealso marker="#transport_ref">transport_ref()</seealso> +PeerRef = <seealso marker="diameter_app#peer_ref">diameter_app:peer_ref()</seealso> From, To = initial | okay | suspect | down | reopen Config = {connect|listen, [transport_opt()]} </code> @@ -721,8 +666,8 @@ The name of a service as passed to <seealso marker="#start_service">start_service/2</seealso> and with which the service is identified. There can be at most one service with a given name on a given node. -Note that <c>erlang:make_ref/0</c> can be used to generate a service name -that is somewhat unique.</p> +Note that <seealso marker="erts:erlang#make_ref-0">erlang:make_ref/0</seealso> +can be used to generate a service name that is somewhat unique.</p> <marker id="service_opt"/> </item> @@ -730,29 +675,28 @@ that is somewhat unique.</p> <tag><c>service_opt()</c></tag> <item> <p> -Options accepted by <seealso +An option passed to <seealso marker="#start_service">start_service/2</seealso>. -Can be any <c>capability()</c> tuple as +Can be any <c><seealso marker="#capability">capability()</seealso></c> as well as the following.</p> <taglist> -<tag><c>{application, [application_opt()]}</c></tag> +<tag><c>{application, [<seealso marker="#application_opt">application_opt()</seealso>]}</c></tag> <item> <p> Defines a Diameter application supported by the service.</p> <p> -A service must define one application for each Diameter application it -intends to support. -For an outgoing Diameter request, the application is specified by -passing the desired application's <c>application_alias()</c> to -<seealso marker="#call">call/4</seealso>, while for an +A service must configure one <c>application</c> for each Diameter +application it intends to support. +For an outgoing Diameter request, the relevant <c><seealso +marker="#application_alias">application_alias()</seealso></c> is +passed to <seealso marker="#call">call/4</seealso>, while for an incoming request the application identifier in the message -header determines the application (and callback module), the -application identifier being specified in the <seealso -marker="diameter_dict">dictionary</seealso> file defining the -application.</p> +header determines the application, the identifier being specified in +the application's <seealso marker="diameter_dict">dictionary</seealso> +file.</p> </item> </taglist> @@ -763,8 +707,9 @@ application.</p> <tag><c>transport_opt()</c></tag> <item> <p> -Options accepted by <seealso -marker="#add_transport">add_transport/2</seealso>.</p> +An option passed to <seealso +marker="#add_transport">add_transport/2</seealso>. +Has one of the following types.</p> <taglist> <tag><c>{transport_module, atom()}</c></tag> @@ -775,10 +720,6 @@ marker="diameter_transport">diameter_transport(3)</seealso>. Defaults to <c>diameter_tcp</c> if unspecified.</p> <p> -The interface required of a transport module is documented in <seealso -marker="diameter_transport">diameter_transport(3)</seealso>.</p> - -<p> Multiple <c>transport_module</c> and <c>transport_config</c> options are allowed. The order of these is significant in this case (and only in this case), @@ -787,11 +728,11 @@ a <c>transport_module</c> being paired with the first default value for trailing modules. Transport starts will be attempted with each of the modules in order until one establishes a connection within the -corresponding timeout (see <c>transport_config</c> below) or all fail.</p> +corresponding timeout (see below) or all fail.</p> </item> <tag><c>{transport_config, term()}</c></tag> -<tag><c>{transport_config, term(), Unsigned32()}</c></tag> +<tag><c>{transport_config, term(), <seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>}</c></tag> <item> <p> A term passed as the third argument to the <seealso @@ -818,40 +759,38 @@ request a connection with one peer over SCTP or another To listen on both SCTP and TCP, define one transport for each.</p> </item> -<tag><c>{applications, [application_alias()]}</c></tag> +<tag><c>{applications, [<seealso marker="#application_alias">application_alias()</seealso>]}</c></tag> <item> <p> -The list of Diameter applications to which usage of the transport -should be restricted. -Defaults to all applications configured on the service -in question.</p> +The list of Diameter applications to which the transport should be +restricted. +Defaults to all applications configured on the service in question. +Applications not configured on the service in question are ignored.</p> </item> -<tag><c>{capabilities, [capability()]}</c></tag> +<tag><c>{capabilities, [<seealso marker="#capability">capability()</seealso>]}</c></tag> <item> <p> AVP's used to construct outgoing CER/CEA messages. -Any AVP specified takes precedence over a corresponding value specified -for the service in question.</p> +Values take precedence over any specified on the service in +question.</p> <p> Specifying a capability as a transport option -may be particularly appropriate for Inband-Security-Id in case +may be particularly appropriate for Inband-Security-Id, in case TLS is desired over TCP as implemented by -<seealso marker="diameter_tcp">diameter_tcp(3)</seealso> but -not over SCTP as implemented by -<seealso marker="diameter_sctp">diameter_sctp(3)</seealso>.</p> +<seealso marker="diameter_tcp">diameter_tcp(3)</seealso>.</p> </item> -<tag><c>{capabilities_cb, evaluable()}</c></tag> +<tag><c>{capabilities_cb, <seealso marker="#evaluable">evaluable()</seealso>}</c></tag> <item> <p> A callback invoked upon reception of CER/CEA during capabilities exchange in order to ask whether or not the connection should be accepted. -Applied to the transport reference (as returned by <seealso -marker="#add_transport">add_transport/2</seealso>) and -<c>diameter_caps</c> record of the connection. +Applied to the relevant <c><seealso +marker="#transport_ref">transport_ref()</seealso></c> and the +<c>#diameter_caps{}</c> record of the connection. Returning <c>ok</c> accepts the connection. Returning <c>integer()</c> causes an incoming CER to be answered with the specified Result-Code. @@ -866,12 +805,14 @@ code causes the transport connection to be broken.</p> Multiple <c>capabilities_cb</c> options can be specified, in which case the corresponding callbacks are applied until either all return <c>ok</c> or one does not.</p> + +<marker id="watchdog_timer"/> </item> <tag><c>{watchdog_timer, TwInit}</c></tag> <item> <code> -TwInit = Unsigned32() +TwInit = <seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso> | {M,F,A} </code> @@ -887,17 +828,19 @@ the callback.</p> <p> An integer value must be at least 6000 as required by RFC 3539. Defaults to 30000 if unspecified.</p> + +<marker id="reconnect_timer"/> </item> <tag><c>{reconnect_timer, Tc}</c></tag> <item> <code> -Tc = Unsigned32() +Tc = <seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso> </code> <p> For a connecting transport, the RFC 3588 Tc timer, in milliseconds. -Note that this timer determines the frequency with which the transport +Note that this timer determines the frequency with which a transport will attempt to establish a connection with its peer only <em>before</em> an initial connection is established: once there is an initial connection it's watchdog_timer that determines the frequency of @@ -910,12 +853,13 @@ regarded as an initial connection rather than a reestablishment, causing the RFC 3539 state machine to pass to state OPEN rather than REOPEN. Note that these semantics are not goverened by the RFC and -that a listening transport's reconnect_timer should be greater than its -peers's Tc plus jitter.</p> +that a listening transport's <c>reconnect_timer</c> should be greater +than its peer's Tw plus jitter.</p> <p> Defaults to 30000 for a connecting transport and 60000 for a listening transport.</p> + </item> </taglist> @@ -927,6 +871,15 @@ marker="#service_info">service_info/2</seealso> and can be referred to in predicate functions passed to <seealso marker="#remove_transport">remove_transport/2</seealso>.</p> +<marker id="transport_ref"/> +</item> + +<tag><c>transport_ref() = reference()</c></tag> +<item> +<p> +An reference returned by <seealso +marker="#add_transport">add_transport/2</seealso> that +identifies the configuration.</p> </item> </taglist> @@ -939,13 +892,13 @@ marker="#remove_transport">remove_transport/2</seealso>.</p> <!-- ===================================================================== --> <func> -<name>add_transport(SvcName, {connect|listen, Options}) +<name>add_transport(SvcName, {connect|listen, [Opt]}) -> {ok, Ref} | {error, Reason}</name> <fsummary>Add transport capability to a service.</fsummary> <type> -<v>SvcName = service_name()</v> -<v>Options = [transport_opt()]</v> -<v>Ref = ref()</v> +<v>SvcName = <seealso marker="#service_name">service_name()</seealso></v> +<v>Opt = <seealso marker="#transport_opt">transport_opt()</seealso></v> +<v>Ref = <seealso marker="#transport_ref">transport_ref()</seealso></v> <v>Reason = term()</v> </type> <desc> @@ -953,8 +906,8 @@ marker="#remove_transport">remove_transport/2</seealso>.</p> Add transport capability to a service.</p> <p> -The service will start a transport process(es) in order to establish a -connection with the peer, either by connecting to the peer +The service will start transport processes as required in order to +establish a connection with the peer, either by connecting to the peer (<c>connect</c>) or by accepting incoming connection requests (<c>listen</c>). A connecting transport establishes transport connections with at most @@ -969,16 +922,20 @@ marker="diameter_app#peer_up">peer_up/3</seealso> callback after which the caller can exchange Diameter messages with the peer over the transport. In addition to CER/CEA, the service takes responsibility for the -handling of DWR/DWA and required by RFC 3539 as well as for DPR/DPA.</p> +handling of DWR/DWA and required by RFC 3539, as well as for DPR/DPA.</p> <p> The returned reference uniquely identifies the transport within the scope of the service. Note that the function returns before a transport connection has been -established. +established.</p> + +<note> +<p> It is not an error to add a transport to a service that has not yet been configured: a service can be started after configuring -transports.</p> +its transports.</p> +</note> <marker id="call"/> </desc> @@ -987,48 +944,47 @@ transports.</p> <!-- ===================================================================== --> <func> -<name>call(SvcName, App, Request, Options) -> ok | Answer | {error, Reason}</name> +<name>call(SvcName, App, Request, [Opt]) -> Answer | ok | {error, Reason}</name> <fsummary>Send a Diameter request message.</fsummary> <type> -<v>SvcName = service_name()</v> -<v>App = application_alias()</v> -<v>Request = diameter_app:message() | term()</v> +<v>SvcName = <seealso marker="#service_name">service_name()</seealso></v> +<v>App = <seealso marker="#application_alias">application_alias()</seealso></v> +<v>Request = <seealso marker="diameter_app#message">diameter_app:message()</seealso></v> <v>Answer = term()</v> -<v>Options = [call_opt()]</v> +<v>Opt = <seealso marker="#call_opt">call_opt()</seealso></v> </type> <desc> <p> -Send a Diameter request message and possibly return the answer or error.</p> +Send a Diameter request message.</p> <p> -<c>App</c> identifies the Diameter application in which the request is +<c>App</c> specifies the Diameter application in which the request is defined and callbacks to the corresponding callback module will follow as described below and in <seealso marker="diameter_app">diameter_app(3)</seealso>. -Unless the <c>detach</c> option has been specified to cause an earlier -return, the call returns either when an answer message is received -from the peer or an error occurs. -In the case of an answer, the return value is as returned by a +Unless the <c>detach</c> option is specified, the call returns either +when an answer message is received from the peer or an error occurs. +In the answer case, the return value is as returned by a <seealso marker="diameter_app#handle_answer">handle_answer/4</seealso> callback. -In the case of an error, whether or not the error is returned directly +In the error case, whether or not the error is returned directly by diameter or from a <seealso marker="diameter_app#handle_error">handle_error/4</seealso> callback depends on whether or not the outgoing request is -successfully encoded for transmission from the peer, the cases being +successfully encoded for transmission to the peer, the cases being documented below.</p> <p> If there are no suitable peers, or if <seealso marker="diameter_app#pick_peer">pick_peer/4</seealso> -rejects them by returning 'false', then <c>{error, no_connection}</c> +rejects them by returning <c>false</c>, then <c>{error,no_connection}</c> is returned. Otherwise <seealso marker="diameter_app#pick_peer">pick_peer/4</seealso> is followed by a <seealso marker="diameter_app#prepare_request">prepare_request/3</seealso> -callback, the message is encoded and sent.</p> +callback, the message is encoded and then sent.</p> <p> There are several error cases which may prevent an @@ -1041,7 +997,7 @@ callback:</p> <item> <p> If the initial encode of the outgoing request -fails, then the request process fails and <c>{error, encode}</c> +fails, then the request process fails and <c>{error,encode}</c> is returned.</p> </item> @@ -1058,7 +1014,7 @@ callback takes place with <c>Reason = timeout</c>.</p> If the request is successfully encoded and sent but the service in question is stopped before an answer is received then a <seealso marker="diameter_app#handle_error">handle_error/4</seealso> -callback takes place <c>Reason = cancel</c>.</p> +callback takes place with <c>Reason = cancel</c>.</p> </item> <item> @@ -1085,7 +1041,7 @@ callback.</p> <p> If an encode error takes place during retransmission then the request process fails and -<c>{error, failure}</c> is returned.</p> +<c>{error,failure}</c> is returned.</p> </item> <item> @@ -1093,7 +1049,7 @@ retransmission then the request process fails and If an application callback made in processing the request fails (pick_peer, prepare_request, prepare_retransmit, handle_answer or handle_error) then either -<c>{error, encode}</c> or <c>{error, failure}</c> +<c>{error,encode}</c> or <c>{error,failure}</c> is returned depending on whether or not there has been an attempt to send the request over the transport.</p> </item> @@ -1101,9 +1057,9 @@ attempt to send the request over the transport.</p> </list> <p> -Note that <c>{error, encode}</c> is the only return value which +Note that <c>{error,encode}</c> is the only return value which guarantees that the request has <em>not</em> been sent over the -transport.</p> +transport connection.</p> <marker id="origin_state_id"/> </desc> @@ -1112,7 +1068,7 @@ transport.</p> <!-- ===================================================================== --> <func> -<name>origin_state_id() -> Unsigned32()</name> +<name>origin_state_id() -> <seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso></name> <fsummary>Returns a reasonable Origin-State-Id.</fsummary> <desc> <p> @@ -1121,7 +1077,7 @@ outgoing messages.</p> <p> The value returned is the number of seconds since 19680120T031408Z, -the first value that can be encoded as a Diameter Time(), +the first value that can be encoded as a Diameter <c><seealso marker="diameter_dict#DATA_TYPES">Time()</seealso></c>, at the time the diameter application was started.</p> <marker id="remove_transport"/> @@ -1134,11 +1090,11 @@ at the time the diameter application was started.</p> <name>remove_transport(SvcName, Pred) -> ok</name> <fsummary>Remove previously added transports.</fsummary> <type> -<v>SvcName = service_name()</v> -<v>Pred = Fun | MFA | ref() | list() | true | false</v> +<v>SvcName = <seealso marker="#service_name">service_name()</seealso></v> +<v>Pred = Fun | MFA | <seealso marker="#transport_ref">transport_ref()</seealso> | list() | true | false</v> <v></v> -<v>Fun = fun((reference(), connect|listen, list()) -> boolean())</v> -<v> | fun((reference(), list()) -> boolean())</v> +<v>Fun = fun((<seealso marker="#transport_ref">transport_ref()</seealso>, connect|listen, list()) -> boolean())</v> +<v> | fun((<seealso marker="#transport_ref">transport_ref()</seealso>, list()) -> boolean())</v> <v> | fun((list()) -> boolean())</v> <v>MFA = {atom(), atom(), list()}</v> </type> @@ -1152,23 +1108,23 @@ An arity-3-valued <c>Pred</c> removes all transports for which <c>Pred(Ref, Type, Opts)</c> returns <c>true</c>, where <c>Type</c> and <c>Opts</c> are as passed to <seealso marker="#add_transport">add_transport/2</seealso> and <c>Ref</c> is -as returned by the corresponding call. +as returned by it. The remaining forms are equivalent to an arity-3 fun as follows.</p> <code> -Pred = fun(reference(), list()): fun(Ref, _, Opts) -> Pred(Ref, Opts) end -Pred = fun(list()): fun(_, _, Opts) -> Pred(Opts) end -Pred = reference(): fun(Ref, _, _) -> Pred == Ref end -Pred = list(): fun(_, _, Opts) -> [] == Pred -- Opts end -Pred = true: fun(_, _, _) -> true end -Pred = false: fun(_, _, _) -> false end +Pred = fun(transport_ref(), list()): fun(Ref, _, Opts) -> Pred(Ref, Opts) end +Pred = fun(list()): fun(_, _, Opts) -> Pred(Opts) end +Pred = transport_ref(): fun(Ref, _, _) -> Pred == Ref end +Pred = list(): fun(_, _, Opts) -> [] == Pred -- Opts end +Pred = true: fun(_, _, _) -> true end +Pred = false: fun(_, _, _) -> false end Pred = {M,F,A}: fun(Ref, Type, Opts) -> apply(M, F, [Ref, Type, Opts | A]) end </code> <p> Removing a transport causes all associated transport connections to be broken. -A base application DPR message with +A DPR message with Disconnect-Cause <c>DO_NOT_WANT_TO_TALK_TO_YOU</c> will be sent to each connected peer before disassociating the transport configuration from the service and terminating the transport upon reception of @@ -1183,15 +1139,293 @@ DPA or timeout.</p> <!-- ===================================================================== --> <func> -<name>service_info(SvcName, Item) -> Value</name> -<fsummary>Return specific information about a started service.</fsummary> +<name>service_info(SvcName, Info) -> term()</name> +<fsummary>Return information about a started service.</fsummary> <type> -<v>SvcName = service_name()</v> -<v>Value = term()</v> +<v>SvcName = <seealso marker="#service_name">service_name()</seealso></v> +<v>Info = Item | [Info]</v> +<v>Item = atom()</v> </type> <desc> <p> -Return information about a started service.</p> +Return information about a started service. +<c>Item</c> can be one of the following.</p> + +<taglist> + +<tag><c>'Origin-Host'</c></tag> +<tag><c>'Origin-Realm'</c></tag> +<tag><c>'Vendor-Id'</c></tag> +<tag><c>'Product-Name'</c></tag> +<tag><c>'Origin-State-Id'</c></tag> +<tag><c>'Host-IP-Address'</c></tag> +<tag><c>'Supported-Vendor'</c></tag> +<tag><c>'Auth-Application-Id'</c></tag> +<tag><c>'Inband-Security-Id'</c></tag> +<tag><c>'Acct-Application-Id'</c></tag> +<tag><c>'Vendor-Specific-Application-Id'</c></tag> +<tag><c>'Firmware-Revision'</c></tag> +<item> +<p> +Return a capability value as configured with <seealso +marker="#start_service">start_service/2</seealso>.</p> +</item> + +<tag><c>applications</c></tag> +<item> +<p> +Return the list of applications as configured with <seealso +marker="#start_service">start_service/2</seealso>. +</p> +</item> + +<tag><c>capabilities</c></tag> +<item> +<p> +Return a tagged list of all capabilities values as configured with +<seealso +marker="#start_service">start_service/2</seealso>.</p> +</item> + +<tag><c>transport</c></tag> +<item> +<p> +Return a list containing one entry for each of the service's transport +as configured with <seealso +marker="#add_transport">add_transport/2</seealso>. +Each entry is a tagged list containing both configuration and +information about established peer connections. +An example return value with for a client service with Origin-Host +"client.example.com" configured with a single transport connected to +"server.example.com" might look as follows.</p> + +<code> +[[{ref,#Ref<0.0.0.93>}, + {type,connect}, + {options,[{transport_module,diameter_tcp}, + {transport_config,[{ip,{127,0,0,1}}, + {raddr,{127,0,0,1}}, + {rport,3868}, + {reuseaddr,true}]}]}, + {watchdog,{<0.66.0>,{1346,171491,996448},okay}}, + {peer,{<0.67.0>,{1346,171491,999906}}}, + {apps,[{0,common}]}, + {caps,[{origin_host,{"client.example.com","server.example.com"}}, + {origin_realm,{"example.com","example.com"}}, + {host_ip_address,{[{127,0,0,1}],[{127,0,0,1}]}}, + {vendor_id,{0,193}}, + {product_name,{"Client","Server"}}, + {origin_state_id,{[],[]}}, + {supported_vendor_id,{[],[]}}, + {auth_application_id,{[0],[0]}}, + {inband_security_id,{[],[0]}}, + {acct_application_id,{[],[]}}, + {vendor_specific_application_id,{[],[]}}, + {firmware_revision,{[],[]}}, + {avp,{[],[]}}]}, + {port,[{owner,<0.69.0>}, + {module,diameter_tcp}, + {socket,{{127,0,0,1},48758}}, + {peer,{{127,0,0,1},3868}}, + {statistics,[{recv_oct,656}, + {recv_cnt,6}, + {recv_max,148}, + {recv_avg,109}, + {recv_dvi,19}, + {send_oct,836}, + {send_cnt,6}, + {send_max,184}, + {send_avg,139}, + {send_pend,0}]}]}, + {statistics,[{{{0,258,0},recv},3}, + {{{0,258,1},send},3}, + {{{0,257,0},recv},1}, + {{{0,257,1},send},1}, + {{{0,258,0},recv,{'Result-Code',2001}},3}, + {{{0,280,1},recv},2}, + {{{0,280,0},send},2}]}]] +</code> + +<p> +Here <c>ref</c> is a <c><seealso +marker="#transport_ref">transport_ref()</seealso></c> and <c>options</c> +the corresponding <c><seealso +marker="#transport_opt">transport_opt()</seealso></c> list passed to <seealso +marker="#add_transport">add_transport/2</seealso>. +The <c>watchdog</c> entry shows the state of a connection's RFC 3539 watchdog +state machine. +The <c>peer</c> entry identifies the <c><seealso +marker="diameter_app#peer_ref">diameter_app:peer_ref()</seealso></c> for +which there will have been <seealso +marker="diameter_app#peer_up">peer_up</seealso> callbacks for the +Diameter applications identified by the <c>apps</c> entry, +<c>common</c> being the <c><seealso +marker="#application_alias">application_alias()</seealso></c>. +The <c>caps</c> entry identifies the capabilities sent by the local +node and received from the peer during capabilities exchange. +The <c>port</c> entry displays socket-level information about the +transport connection. +The <c>statistics</c> entry presents Diameter-level counters, +an entry like <c>{{{0,280,1},recv},2}</c> saying that the client has +received 2 DWR messages: <c>{0,280,1} = {Application_Id, Command_Code, +R_Flag}</c>.</p> + +<p> +Note that <c>watchdog</c>, <c>peer</c>, <c>apps</c>, <c>caps</c> +and <c>port</c> entries depend on connectivity +with the peer and may not be present. +Note also that the <c>statistics</c> entry presents values acuumulated +during the lifetime of the transport configuration.</p> + +<p> +A listening transport presents its information slightly differently +since there may be multiple accepted connections for the same <c><seealso +marker="#transport_ref">transport_ref()</seealso></c>. +The <c>transport</c> info returned by a server with a single client +connection might look as follows.</p> + +<code> +[[{ref,#Ref<0.0.0.61>}, + {type,listen}, + {options,[{transport_module,diameter_tcp}, + {transport_config,[{reuseaddr,true}, + {ip,{127,0,0,1}}, + {port,3868}]}]}, + {accept,[[{watchdog,{<0.56.0>,{1346,171481,226895},okay}}, + {peer,{<0.58.0>,{1346,171491,999511}}}, + {apps,[{0,common}]}, + {caps,[{origin_host,{"server.example.com","client.example.com"}}, + {origin_realm,{"example.com","example.com"}}, + {host_ip_address,{[{127,0,0,1}],[{127,0,0,1}]}}, + {vendor_id,{193,0}}, + {product_name,{"Server","Client"}}, + {origin_state_id,{[],[]}}, + {supported_vendor_id,{[],[]}}, + {auth_application_id,{[0],[0]}}, + {inband_security_id,{[],[]}}, + {acct_application_id,{[],[]}}, + {vendor_specific_application_id,{[],[]}}, + {firmware_revision,{[],[]}}, + {avp,{[],[]}}]}, + {port,[{owner,<0.62.0>}, + {module,diameter_tcp}, + {socket,{{127,0,0,1},3868}}, + {peer,{{127,0,0,1},48758}}, + {statistics,[{recv_oct,1576}, + {recv_cnt,16}, + {recv_max,184}, + {recv_avg,98}, + {recv_dvi,26}, + {send_oct,1396}, + {send_cnt,16}, + {send_max,148}, + {send_avg,87}, + {send_pend,0}]}]}], + [{watchdog,{<0.72.0>,{1346,171491,998404},initial}}]]}, + {statistics,[{{{0,280,0},recv},7}, + {{{0,280,1},send},7}, + {{{0,258,0},send,{'Result-Code',2001}},3}, + {{{0,258,1},recv},3}, + {{{0,258,0},send},3}, + {{{0,280,1},recv},5}, + {{{0,280,0},send},5}, + {{{0,257,1},recv},1}, + {{{0,257,0},send},1}]}]] +</code> + +<p> +The information presented here is as in the <c>connect</c> case except +that the client connections are grouped under an <c>accept</c> tuple.</p> + +</item> + +<tag><c>connections</c></tag> +<item> +<p> +Return a list containing one entry for every established transport +connection whose watchdog state machine is not in the <c>down</c> +state. +This is a flat view of <c>transport</c> info which lists only active +connections and for which Diameter-level statistics are accumulated +only for the lifetime of the transport connection. +A return value for the server above might look as follows.</p> + +<code> +[[{ref,#Ref<0.0.0.61>}, + {type,accept}, + {options,[{transport_module,diameter_tcp}, + {transport_config,[{reuseaddr,true}, + {ip,{127,0,0,1}}, + {port,3868}]}]}, + {watchdog,{<0.56.0>,{1346,171481,226895},okay}}, + {peer,{<0.58.0>,{1346,171491,999511}}}, + {apps,[{0,common}]}, + {caps,[{origin_host,{"server.example.com","client.example.com"}}, + {origin_realm,{"example.com","example.com"}}, + {host_ip_address,{[{127,0,0,1}],[{127,0,0,1}]}}, + {vendor_id,{193,0}}, + {product_name,{"Server","Client"}}, + {origin_state_id,{[],[]}}, + {supported_vendor_id,{[],[]}}, + {auth_application_id,{[0],[0]}}, + {inband_security_id,{[],[]}}, + {acct_application_id,{[],[]}}, + {vendor_specific_application_id,{[],[]}}, + {firmware_revision,{[],[]}}, + {avp,{[],[]}}]}, + {port,[{owner,<0.62.0>}, + {module,diameter_tcp}, + {socket,{{127,0,0,1},3868}}, + {peer,{{127,0,0,1},48758}}, + {statistics,[{recv_oct,10124}, + {recv_cnt,132}, + {recv_max,184}, + {recv_avg,76}, + {recv_dvi,9}, + {send_oct,10016}, + {send_cnt,132}, + {send_max,148}, + {send_avg,75}, + {send_pend,0}]}]}, + {statistics,[{{{0,280,0},recv},62}, + {{{0,280,1},send},62}, + {{{0,258,0},send,{'Result-Code',2001}},3}, + {{{0,258,1},recv},3}, + {{{0,258,0},send},3}, + {{{0,280,1},recv},66}, + {{{0,280,0},send},66}, + {{{0,257,1},recv},1}, + {{{0,257,0},send},1}]}]] +</code> + +<p> +Note that there may be multiple entries with the same <c>ref</c>, in +contrast to <c>transport</c> info.</p> +</item> + +<tag><c>statistics</c></tag> +<item> +<p> +Return a <c>{{Counter, Ref}, non_neg_integer()}</c> list of counter values. +<c>Ref</c> can be either a <c><seealso +marker="#transport_ref">transport_ref()</seealso></c> +or a <c><seealso +marker="diameter_app#peer_ref">diameter_app:peer_ref()</seealso></c>. +Entries for the latter are folded into corresponding entries for the +former as peer connections go down. +Entries for both are removed at <seealso +marker="#remove_transport">remove_transport/2</seealso>. +The Diameter-level statistics returned by <c>transport</c> and +<c>connections</c> info are based upon these entries.</p> +</item> + +</taglist> + +<p> +Requesting info for an unknown service causes <c>undefined</c> to be +returned. +Requesting a list of items causes a tagged list to be +returned.</p> <marker id="services"/> </desc> @@ -1203,7 +1437,7 @@ Return information about a started service.</p> <name>services() -> [SvcName]</name> <fsummary>Return the list of started services.</fsummary> <type> -<v>SvcName = service_name()</v> +<v>SvcName = <seealso marker="#service_name">service_name()</seealso></v> </type> <desc> <p> @@ -1216,10 +1450,10 @@ Return the list of started services.</p> <!-- ===================================================================== --> <func> -<name>session_id(Ident) -> OctetString()</name> +<name>session_id(Ident) -> <seealso marker="diameter_dict#DATA_TYPES">OctetString()</seealso></name> <fsummary>Return a value for a Session-Id AVP.</fsummary> <type> -<v>Ident = DiameterIdentity()</v> +<v>Ident = <seealso marker="diameter_dict#DATA_TYPES">DiameterIdentity()</seealso></v> </type> <desc> <p> @@ -1244,7 +1478,7 @@ Start the diameter application.</p> <p> The diameter application must be started before starting a service. -In a production system this will typically be accomplished by a boot +In a production system this is typically accomplished by a boot file, not by calling <c>start/0</c> explicitly.</p> <marker id="start_service"/> @@ -1256,8 +1490,8 @@ file, not by calling <c>start/0</c> explicitly.</p> <name>start_service(SvcName, Options) -> ok | {error, Reason}</name> <fsummary>Start a Diameter service.</fsummary> <type> -<v>SvcName = service_name()</v> -<v>Options = [service_opt()]</v> +<v>SvcName = <seealso marker="#service_name">service_name()</seealso></v> +<v>Options = [<seealso marker="#service_opt">service_opt()</seealso>]</v> <v>Reason = term()</v> </type> <desc> @@ -1265,11 +1499,19 @@ file, not by calling <c>start/0</c> explicitly.</p> Start a diameter service.</p> <p> -A service defines a locally-implemented Diameter peer, specifying the -capabilities of the peer to be used during capabilities exchange and -the Diameter applications that it supports. +A service defines a locally-implemented Diameter node, specifying the +capabilities to be advertised during capabilities exchange. Transports are added to a service using <seealso -marker="#add_transport">add_transport/2</seealso>.</p> +marker="#add_transport">add_transport/2</seealso>. +</p> + +<note> +<p> +A transport can both override its service's +capabilities and restrict its supported Diameter applications so +"service = Diameter node as identified by Origin-Host" is not +necessarily the case.</p> +</note> <marker id="stop_service"/> </desc> @@ -1295,13 +1537,26 @@ Stop the diameter application.</p> <name>stop_service(SvcName) -> ok | {error, Reason}</name> <fsummary>Stop a Diameter service.</fsummary> <type> -<v>SvcName = service_name()</v> +<v>SvcName = <seealso marker="#service_name">service_name()</seealso></v> <v>Reason = term()</v> </type> <desc> <p> Stop a diameter service.</p> +<p> +Stopping a service causes all associated transport connections to be +broken. +A DPR message with be sent as in the case of <seealso +marker="#remove_transport">remove_transport/2</seealso>.</p> + +<note> +<p> +Stopping a transport does not remove any associated transports: +<seealso marker="#remove_transport">remove_transport/2</seealso> must +be called to remove transport configuration.</p> +</note> + <marker id="subscribe"/> </desc> </func> @@ -1312,15 +1567,19 @@ Stop a diameter service.</p> <name>subscribe(SvcName) -> true</name> <fsummary>Subscribe to event messages.</fsummary> <type> -<v>SvcName = service_name()</v> +<v>SvcName = <seealso marker="#service_name">service_name()</seealso></v> </type> <desc> <p> -Subscribe to <c>service_event()</c> messages from a service.</p> +Subscribe to <c><seealso +marker="#service_event">service_event()</seealso></c> messages from +a service.</p> <p> It is not an error to subscribe to events from a service -that does not yet exist.</p> +that does not yet exist. +Doing so before adding transports is required to guarantee the +reception of all related events.</p> <marker id="unsubscribe"/> </desc> @@ -1332,7 +1591,7 @@ that does not yet exist.</p> <name>unsubscribe(SvcName) -> true</name> <fsummary>Unsubscribe to event messages.</fsummary> <type> -<v>SvcName = service_name()</v> +<v>SvcName = <seealso marker="#service_name">service_name()</seealso></v> </type> <desc> <p> diff --git a/lib/diameter/doc/src/diameter_app.xml b/lib/diameter/doc/src/diameter_app.xml index a9ae0ebbec..4a4b212787 100644 --- a/lib/diameter/doc/src/diameter_app.xml +++ b/lib/diameter/doc/src/diameter_app.xml @@ -5,7 +5,7 @@ <header> <copyright> -<year>2011</year> +<year>2011</year><year>2012</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -45,8 +45,8 @@ A diameter service as started by <seealso marker="diameter#start_service">diameter:start_service/2</seealso> configures one of more Diameter applications, each of whose configuration specifies a callback that handles messages specific to -its application. -The messages and AVPs of the Diameter application are defined in a +the application. +The messages and AVPs of the application are defined in a dictionary file whose format is documented in <seealso marker="diameter_dict">diameter_dict(4)</seealso> while the callback module is documented here. @@ -106,11 +106,13 @@ and, for the call-specific callbacks, any extra arguments passed to <taglist> +<marker id="capabilities"/> + <tag><c>capabilities() = #diameter_caps{}</c></tag> <item> <p> A record containing the identities of -the local and remote Diameter peers having an established transport +the local Diameter node and the remote Diameter peer having an established transport connection, as well as the capabilities as determined by capabilities exchange. Each field of the record is a 2-tuple consisting of @@ -119,6 +121,8 @@ Optional or possibly multiple values are encoded as lists of values, mandatory values as the bare value.</p> </item> +<marker id="message"/> + <tag><c>message() = record() | list()</c></tag> <item> <p> @@ -136,8 +140,8 @@ list of <c>{FieldName, FieldValue}</c> pairs.</p> <p> A third representation allows a message to be specified as a list -whose head is a <c>diameter_header</c> record and whose tail is a list -of <c>diameter_avp</c> records. +whose head is a <c>#diameter_header{}</c> record and whose tail is a list +of <c>#diameter_avp{}</c> records. This representation is used by diameter itself when relaying requests as directed by the return value of a <seealso marker="#handle_request">handle_request/3</seealso> @@ -149,15 +153,18 @@ are sent exactly as specified.</p> </item> +<marker id="packet"/> + <tag><c>packet() = #diameter_packet{}</c></tag> <item> <p> -A container for incoming and outgoing Diameters message that's passed +A container for incoming and outgoing Diameter messages that's passed through encode/decode and transport. -Fields of a packet() record should not be set in return values except -as documented.</p> +Fields should not be set in return values except as documented.</p> </item> +<marker id="peer_ref"/> + <tag><c>peer_ref() = term()</c></tag> <item> <p> @@ -165,20 +172,15 @@ A term identifying a transport connection with a Diameter peer. Should be treated opaquely.</p> </item> -<tag><c>peer() = {peer_ref(), capabilities()}</c></tag> +<marker id="peer"/> + +<tag><c>peer() = {<seealso marker="#peer_ref">peer_ref()</seealso>, <seealso marker="#capabilities">capabilities()</seealso>}</c></tag> <item> <p> A tuple representing a Diameter peer connection.</p> </item> -<tag><c>service_name() = term()</c></tag> -<item> -<p> -The service supporting the Diameter application. -Specified to <seealso -marker="diameter#start_service">diameter:start_service/2</seealso> -when starting the service.</p> -</item> +<marker id="state"/> <tag><c>state() = term()</c></tag> <item> @@ -211,9 +213,9 @@ process.</p> <name>Mod:peer_up(SvcName, Peer, State) -> NewState</name> <fsummary>Invoked when a transport connection has been established</fsummary> <type> -<v>SvcName = service_name()</v> -<v>Peer = peer()</v> -<v>State = NewState = state()</v> +<v>SvcName = <seealso marker="diameter#service_name">diameter:service_name()</seealso></v> +<v>Peer = <seealso marker="#peer">peer()</seealso></v> +<v>State = NewState = <seealso marker="#state">state()</seealso></v> </type> <desc> <p> @@ -230,9 +232,9 @@ the callback module in question has been configured.</p> <name>Mod:peer_down(SvcName, Peer, State) -> NewState</name> <fsummary>Invoked when a transport connection has been lost.</fsummary> <type> -<v>SvcName = service_name()</v> -<v>Peer = peer()</v> -<v>State = NewState = state()</v> +<v>SvcName = <seealso marker="diameter#service_name">diameter:service_name()</seealso></v> +<v>Peer = <seealso marker="#peer">peer()</seealso></v> +<v>State = NewState = <seealso marker="#state">state()</seealso></v> </type> <desc> <p> @@ -248,21 +250,17 @@ call to <seealso marker="#peer_up">peer_up/3</seealso>.</p> -> {ok, Peer} | {Peer, NewState} | false</name> <fsummary>Select a target peer for an outgoing request.</fsummary> <type> -<v>Candidates = [peer()]</v> -<v>Peer = peer() | false</v> -<v>SvcName = service_name()</v> -<v>State = NewState = state()</v> +<v>Candidates = [<seealso marker="#peer">peer()</seealso>]</v> +<v>Peer = <seealso marker="#peer">peer()</seealso> | false</v> +<v>SvcName = <seealso marker="diameter#service_name">diameter:service_name()</seealso></v> +<v>State = NewState = <seealso marker="#state">state()</seealso></v> </type> <desc> <p> Invoked as a consequence of a call to <seealso marker="diameter#call">diameter:call/4</seealso> to select a destination -peer for an outgoing request, the return value indicating the selected peer. -A new application state can also be returned but only if the Diameter -application in question was -configured with the option <c>call_mutates_state</c> set to -<c>true</c>, as documented for <seealso -marker="diameter#start_service">diameter:start_service/2</seealso>.</p> +peer for an outgoing request, the return value indicating the selected +peer.</p> <p> The candidate peers list will only include those @@ -282,7 +280,8 @@ equivalent when callback state is mutable, as are <c>{ok, Peer}</c> and <c>{Peer, State}</c>. Returning a peer as <c>false</c> causes <c>{error, no_connection}</c> to be returned from <seealso marker="diameter#call">diameter:call/4</seealso>. -Returning a peer() from an initial pick_peer/4 callback will result in a +Returning a <seealso marker="#peer">peer()</seealso> from an initial +pick_peer/4 callback will result in a <seealso marker="#prepare_request">prepare_request/3</seealso> callback followed by either <seealso marker="#handle_answer">handle_answer/4</seealso> @@ -301,6 +300,19 @@ marker="#pick_peer">pick_peer/4</seealso> will be, since a retransmission to an alternate peer is abandoned if an answer is received from a previously selected peer.</p> +<note> +<p> +<c>{Peer, NewState}</c> and its equivalents can only be returned if +the Diameter application in question was +configured with the <seealso +marker="diameter#application_opt">diameter:application_opt()</seealso> +<c>{call_mutates_state, true}</c>. +Otherwise, the <c>State</c> argument is always +the intial value as configured on the application, not any subsequent +value returned by a <seealso marker="#peer_up">peer_up/3</seealso> +or <seealso marker="#peer_down">peer_down/3</seealso> callback.</p> +</note> + <marker id="prepare_request"/> </desc> @@ -310,10 +322,10 @@ received from a previously selected peer.</p> <name>Mod:prepare_request(Packet, SvcName, Peer) -> Action</name> <fsummary>Return a request for encoding and transport.</fsummary> <type> -<v>Packet = packet()</v> -<v>SvcName = service_name()</v> -<v>Peer = peer()</v> -<v>Action = {send, packet() | message()} | {discard, Reason} | discard</v> +<v>Packet = <seealso marker="#packet">packet()</seealso></v> +<v>SvcName = <seealso marker="diameter#service_name">diameter:service_name()</seealso></v> +<v>Peer = <seealso marker="#peer">peer()</seealso></v> +<v>Action = {send, <seealso marker="#packet">packet()</seealso> | <seealso marker="#message">message()</seealso>} | {discard, Reason} | discard</v> </type> <desc> <p> @@ -325,14 +337,14 @@ callback need not be limited to this usage. Many implementations may simply want to return <c>{send, Packet}</c></p> <p> -A returned packet() should set the request to be encoded in its +A returned <seealso marker="#packet">packet()</seealso> should set the request to be encoded in its <c>msg</c> field and can set the <c>transport_data</c> field in order to pass information to the transport module. Extra arguments passed to <seealso marker="diameter#call">diameter:call/4</seealso> can be used to communicate transport data to the callback. -A returned packet() can also set the <c>header</c> field to a -<c>diameter_header</c> record in order to specify values that should +A returned <seealso marker="#packet">packet()</seealso> can also set the <c>header</c> field to a +<c>#diameter_header{}</c> record in order to specify values that should be preserved in the outgoing request, although this should typically not be necessary and allows the callback to set header values inappropriately. @@ -355,10 +367,10 @@ discarded}</c>.</p> <name>Mod:prepare_retransmit(Packet, SvcName, Peer) -> Result</name> <fsummary>Return a request for encoding and retransmission.</fsummary> <type> -<v>Packet = packet()</v> -<v>SvcName = service_name()</v> -<v>Peer = peer()</v> -<v>Result = {send, packet() | message()} | {discard, Reason} | discard</v> +<v>Packet = <seealso marker="#packet">packet()</seealso></v> +<v>SvcName = <seealso marker="diameter#service_name">diameter:service_name()</seealso></v> +<v>Peer = <seealso marker="#peer">peer()</seealso></v> +<v>Result = {send, <seealso marker="#packet">packet()</seealso> | <seealso marker="#message">message()</seealso>} | {discard, Reason} | discard</v> </type> <desc> <p> @@ -366,7 +378,7 @@ Invoked to return a request for encoding and retransmission. Has the same role as <seealso marker="#prepare_request">prepare_request/3</seealso> in the case that a peer connection is lost an an alternate peer selected but the -argument packet() is as returned by the initial +argument <seealso marker="#packet">packet()</seealso> is as returned by the initial <c>prepare_request/3</c>.</p> <p> @@ -385,10 +397,10 @@ discarded}</c>.</p> <name>Mod:handle_answer(Packet, Request, SvcName, Peer) -> Result</name> <fsummary>Receive an answer message from a peer.</fsummary> <type> -<v>Packet = packet()</v> -<v>Request = message()</v> -<v>SvcName = service_name()</v> -<v>Peer = peer()</v> +<v>Packet = <seealso marker="#packet">packet()</seealso></v> +<v>Request = <seealso marker="#message">message()</seealso></v> +<v>SvcName = <seealso marker="diameter#service_name">diameter:service_name()</seealso></v> +<v>Peer = <seealso marker="#peer">peer()</seealso></v> <v>Result = term()</v> </type> <desc> @@ -401,7 +413,7 @@ specified.</p> <p> The decoded answer record is in the <c>msg</c> field of the argument -packet(), +<seealso marker="#packet">packet()</seealso>, the undecoded binary in the <c>packet</c> field. <c>Request</c> is the outgoing request message as was returned from <seealso marker="#prepare_request">prepare_request/3</seealso> or @@ -438,9 +450,9 @@ marker="diameter#start_service">diameter:start_service/2</seealso>.</p> <fsummary>Return an error from a outgoing request.</fsummary> <type> <v>Reason = timeout | failover | term()</v> -<v>Request = message()</v> -<v>SvcName = service_name()</v> -<v>Peer = peer()</v> +<v>Request = <seealso marker="#message">message()</seealso></v> +<v>SvcName = <seealso marker="diameter#service_name">diameter:service_name()</seealso></v> +<v>Peer = <seealso marker="#peer">peer()</seealso></v> <v>Result = term()</v> </type> <desc> @@ -469,14 +481,14 @@ callback returned false.</p> <name>Mod:handle_request(Packet, SvcName, Peer) -> Action</name> <fsummary>Receive an incoming request.</fsummary> <type> -<v>Packet = packet()</v> +<v>Packet = <seealso marker="#packet">packet()</seealso></v> <v>SvcName = term()</v> -<v>Peer = peer()</v> -<v>Action = Reply | {relay, Opts} | discard | {eval, Action, PostF}</v> -<v>Reply = {reply, message()} +<v>Peer = <seealso marker="#peer">peer()</seealso></v> +<v>Action = Reply | {relay, [Opt]} | discard | {eval, Action, PostF}</v> +<v>Reply = {reply, <seealso marker="#message">message()</seealso>} | {protocol_error, 3000..3999}</v> -<v>Opts = diameter:call_opts()</v> -<v>PostF = diameter:evaluable()</v> +<v>Opt = <seealso marker="diameter#call_opt">diameter:call_opt()</seealso></v> +<v>PostF = <seealso marker="diameter#evaluable">diameter:evaluable()</seealso></v> </type> <desc> <p> @@ -492,13 +504,13 @@ itself as defining either the application in question or the Relay application.</p> <p> -The argument packet() has the following signature.</p> +The argument <seealso marker="#packet">packet()</seealso> has the following signature.</p> <code> #diameter_packet{header = #diameter_header{}, avps = [#diameter_avp{}], msg = record() | undefined, - errors = ['Unsigned32'() | {'Unsigned32'(), #diameter_avp{}}], + errors = [<seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso> | {<seealso marker="diameter_dict#DATA_TYPES">Unsigned32()</seealso>, #diameter_avp{}}], bin = binary(), transport_data = term()} </code> @@ -515,8 +527,8 @@ The <c>errors</c> field specifies any Result-Code's identifying errors that were encountered in decoding the request. In this case diameter will set both Result-Code and Failed-AVP AVP's in a returned -answer message() before sending it to the peer: -the returned message() need only set any other required AVP's. +answer <seealso marker="#message">message()</seealso> before sending it to the peer: +the returned <seealso marker="#message">message()</seealso> need only set any other required AVP's. Note that the errors detected by diameter are all of the 5xxx series (Permanent Failures). The <c>errors</c> list is empty if the request has been received in @@ -526,7 +538,7 @@ the relay application.</p> The <c>transport_data</c> field contains an arbitrary term passed into diameter from the transport module in question, or the atom <c>undefined</c> if the transport specified no data. -The term is preserved in the packet() containing any answer message +The term is preserved in the <seealso marker="#packet">packet()</seealso> containing any answer message sent back to the transport process unless another value is explicitly specified.</p> @@ -535,7 +547,7 @@ The semantics of each of the possible return values are as follows.</p> <taglist> -<tag><c>{reply, message()}</c></tag> +<tag><c>{reply, <seealso marker="#message">message()</seealso>}</c></tag> <item> <p> Send the specified answer message to the peer.</p> @@ -579,7 +591,7 @@ header of the relayed request.</p> The returned <c>Opts</c> should not specify <c>detach</c>. A subsequent <seealso marker="#handle_answer">handle_answer/4</seealso> callback for the relayed request must return its first -argument, the <c>diameter_packet</c> record containing the answer +argument, the <c>#diameter_packet{}</c> record containing the answer message. Note that the <c>extra</c> option can be specified to supply arguments that can distinguish the relay case from others if so desired. diff --git a/lib/diameter/doc/src/diameter_compile.xml b/lib/diameter/doc/src/diameter_compile.xml index 60e08d41da..7a6ca48798 100644 --- a/lib/diameter/doc/src/diameter_compile.xml +++ b/lib/diameter/doc/src/diameter_compile.xml @@ -4,7 +4,7 @@ <comref> <header> <copyright> -<year>2011</year> +<year>2011</year><year>2012</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -31,7 +31,7 @@ supplied. <description> <p> -The diameterc utility is used to transform diameter +The diameterc utility is used to compile diameter <seealso marker="diameter_dict">dictionary files</seealso> into Erlang source. The resulting source implements the interface diameter requires @@ -47,7 +47,7 @@ to encode and decode the dictionary's messages and AVP's.</p> <tag><![CDATA[diameterc [<options>] <file>]]></tag> <item> <p> -Transforms a single dictionary file. Valid options are as follows.</p> +Compiles a single dictionary file. Valid options are as follows.</p> <!-- Leave -h/d/v undocumented, except for the usage message from the utility itself. --> @@ -64,47 +64,36 @@ Defaults to the current working directory.</p> <item> <p> Specifies a directory to add to the code path. -Use to point at beam files corresponding to dictionaries -inherited by the one being compiled using <c>@inherits</c> or -<c>--inherits</c>. -Inheritance is a beam dependency, not an erl/hrl dependency.</p> +Use to point at beam files compiled from inherited dictionaries, +<c>@inherits</c> in a dictionary file creating a beam dependency, not +an erl/hrl dependency.</p> <p> Multiple <c>-i</c> options can be specified.</p> </item> <tag><![CDATA[-E]]></tag> -<item> -<p> -Supresses erl generation.</p> -</item> - <tag><![CDATA[-H]]></tag> <item> <p> -Supresses hrl generation.</p> +Supresses erl and hrl generation, respectively.</p> </item> <tag><![CDATA[--name <name>]]></tag> -<item> -<p> -Set <c>@name</c> in the dictionary file. -Overrides any setting in the file itself.</p> -</item> - <tag><![CDATA[--prefix <prefix>]]></tag> <item> <p> -Set <c>@prefix</c> in the dictionary file. +Set <c>@name</c> and <c>@prefix</c> in the dictionary, +respectively. Overrides any setting in the file itself.</p> </item> <tag><![CDATA[--inherits <dict>]]></tag> <item> <p> -Append an <c>@inherits</c> to the dictionary file. -Specifying <c>'-'</c> as the dictionary has the effect of clearing -any previous inherits, effectively ignoring previous inherits.</p> +Append an <c>@inherits</c> to the dictionary before compiling. +Specifying <c>'-'</c> as the dictionary has the effect of clearing any +previous inherits, causing them to be ignored.</p> <p> Multiple <c>--inherits</c> options can be specified.</p> @@ -130,16 +119,6 @@ Returns 0 on success, non-zero on failure.</p> <!-- ===================================================================== --> <section> -<title>BUGS</title> - -<p> -The identification of errors in the source file is poor.</p> - -</section> - -<!-- ===================================================================== --> - -<section> <title>SEE ALSO</title> <p> diff --git a/lib/diameter/doc/src/diameter_dict.xml b/lib/diameter/doc/src/diameter_dict.xml index cc638dbc18..26d6ad4e56 100644 --- a/lib/diameter/doc/src/diameter_dict.xml +++ b/lib/diameter/doc/src/diameter_dict.xml @@ -275,10 +275,12 @@ Location-Information 350 Grouped MV Requested-Information 353 Enumerated V </code> +<warning> <p> -Note that the P flag has been deprecated by the Diameter Maintenance -and Extensions Working Group of the IETF: diameter will set the P flag -to 0 as mandated by the current draft standard.</p> +The P flag has been deprecated by the Diameter Maintenance +and Extensions Working Group of the IETF and should be omitted +to conform to the current draft standard.</p> +</warning> </item> diff --git a/lib/diameter/doc/src/diameter_examples.xml b/lib/diameter/doc/src/diameter_examples.xml index 966d1f1eee..1fd7755695 100644 --- a/lib/diameter/doc/src/diameter_examples.xml +++ b/lib/diameter/doc/src/diameter_examples.xml @@ -5,7 +5,7 @@ <header> <copyright> -<year>2011</year> +<year>2011</year><year>2012</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> @@ -37,7 +37,6 @@ under the License. <!-- ===================================================================== --> <p> -To be written. Example code can be found in the diameter application's <c>examples</c> subdirectory.</p> diff --git a/lib/diameter/doc/src/diameter_intro.xml b/lib/diameter/doc/src/diameter_intro.xml index ef08002a8b..bc2afbd453 100644 --- a/lib/diameter/doc/src/diameter_intro.xml +++ b/lib/diameter/doc/src/diameter_intro.xml @@ -4,7 +4,7 @@ <chapter> <header> <copyright> -<year>2011</year> +<year>2011</year><year>2012</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> @@ -44,11 +44,11 @@ agent. This chapter provides a short overview of the application.</p> <p> -A Diameter peer is implemented by configuring a <em>service</em> and +A Diameter node is implemented by configuring a <em>service</em> and one or more <em>transports</em> using the interface module <seealso marker="diameter">diameter</seealso>. The service configuration defines the Diameter applications to be -supported by the peer and, typically, the capabilities that it should +supported by the node and, typically, the capabilities that it should send to remote peers at capabilities exchange upon the establishment of transport connections. A transport is configured on a service and provides protocol-specific @@ -57,16 +57,17 @@ diameter and implemented by a transport module. The diameter application provides two transport modules: <seealso marker="diameter_tcp">diameter_tcp</seealso> and <seealso marker="diameter_sctp">diameter_sctp</seealso> for transport over TCP -(using <c>gen_tcp</c>) and SCTP (using <c>gen_sctp</c>) respectively. +(using <seealso marker="kernel:gen_tcp">gen_tcp</seealso>) and SCTP +(using <seealso marker="kernel:gen_sctp">gen_sctp</seealso>) respectively. Other transports can be provided by any module that implements diameter's <seealso marker="diameter_transport">transport interface</seealso>.</p> <p> -While a service typically implements a single Diameter peer (as +While a service typically implements a single Diameter node (as identified by an Origin-Host AVP), transports can themselves be -associated with capabilities AVP's so that a single service be used to -implement more than one Diameter peer.</p> +associated with capabilities AVP's so that a single service can be +used to implement more than one Diameter node.</p> <p> Each Diameter application defined on a service is configured with a @@ -76,19 +77,19 @@ diameter communicates the connectivity of remote peers, requests peer selection for outgoing requests, and communicates the reception of incoming Diameter request and answer messages. An application using diameter implements these application callback -modules to provide the functionality of the Diameter peer(s) it +modules to provide the functionality of the Diameter node(s) it implements.</p> <p> -Each Diameter application is also configured with one or more -dictionary modules +Each Diameter application is also configured with a +dictionary module that provide encode/decode functionality for outgoing/incoming -Diameter messages. -A module is generated from a <seealso +Diameter messages belonging to the application. +A dictionary module is generated from a <seealso marker="diameter_dict">specification file</seealso> using the <seealso marker="diameterc">diameterc</seealso> utility. Dictionaries for the RFC 3588 Diameter Common Messages, Base -Accounting and Relay applications are provided by the diameter +Accounting and Relay applications are provided with the diameter application.</p> </chapter> diff --git a/lib/diameter/doc/src/diameter_sctp.xml b/lib/diameter/doc/src/diameter_sctp.xml index c1e839b8e1..955169349c 100644 --- a/lib/diameter/doc/src/diameter_sctp.xml +++ b/lib/diameter/doc/src/diameter_sctp.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> -<year>2011</year> +<year>2011</year><year>2012</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -58,11 +58,11 @@ and implements the behaviour documented in <fsummary>Start a transport process.</fsummary> <type> <v>Type = connect | accept</v> -<v>Ref = reference()</v> +<v>Ref = <seealso marker="diameter#transport_ref">diameter:transport_ref()</seealso></v> <v>Svc = #diameter_service{}</v> -<v>Opt = {raddr, ip_address()} | {rport, integer()} | term()</v> +<v>Opt = {raddr, <seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>} | {rport, integer()} | term()</v> <v>Pid = pid()</v> -<v>LAddr = ip_address()</v> +<v>LAddr = <seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso></v> <v>Reason = term()</v> </type> <desc> @@ -75,12 +75,13 @@ marker="diameter_transport#start">diameter_transport(3)</seealso>.</p> The only diameter_sctp-specific argument is the options list. Options <c>raddr</c> and <c>rport</c> specify the remote address and port for a connecting transport and not valid for a listening -transport. -The former is required while latter defaults to 3868 if unspecified. +transport: the former is required while latter defaults to 3868 if +unspecified. More than one <c>raddr</c> option can be specified, in which case the connecting transport in question attempts each in sequence until an association is established. -Remaining options are any accepted by gen_sctp:open/1, with the exception +Remaining options are any accepted by <seealso +marker="kernel:gen_sctp#open-1">gen_sctp:open/1</seealso>, with the exception of options <c>mode</c>, <c>binary</c>, <c>list</c>, <c>active</c> and <c>sctp_events</c>. Note that options <c>ip</c> and <c>port</c> specify the local address @@ -88,30 +89,45 @@ and port respectively.</p> <p> Multiple <c>ip</c> options can be specified for a multihomed peer. -If none are specified then the values of Host-IP-Address -on the service are used. (In particular, one of these must be specified.) +If none are specified then the values of <c>Host-IP-Address</c> +in the <c>#diameter_service{}</c> record are used. +(In particular, one of these must be specified.) Option <c>port</c> defaults to 3868 for a listening transport and 0 for a connecting transport.</p> +<warning> +<p> +An insufficiently large receive buffer may result in a peer having to +resend incoming messages: set the <seealso +marker="kernel:inet">inet(3)</seealso> option <c>recbuf</c> to increase +the buffer size.</p> + +<p> +An insufficiently large send buffer may result in outgoing messages +being discarded: set the <seealso +marker="kernel:inet">inet(3)</seealso> option <c>sndbuf</c> to increase +the buffer size.</p> +</warning> + <p> diameter_sctp uses the <c>transport_data</c> field of -the <c>diameter_packet</c> record to communicate the stream on which an +the <c>#diameter_packet{}</c> record to communicate the stream on which an inbound message has been received, or on which an outbound message should be sent: the value will be of the form <c>{stream, Id}</c> on an inbound message passed to a <seealso marker="diameter_app#handle_request">handle_request</seealso> or <seealso marker="diameter_app#handle_answer">handle_answer</seealso> callback. -For an outbound message, either <c>undefined</c> (explicitly of -by specifying the outbound message as a <c>binary()</c>) or a tuple +For an outbound message, either <c>undefined</c> (explicitly or +by receiving the outbound message as a <c>binary()</c>) or a tuple should be set in the return value of <seealso marker="diameter_app#handle_request">handle_request</seealso> (typically by retaining the value passed into this function) or <seealso marker="diameter_app#prepare_request">prepare_request</seealso>. -The value <c>undefined</c> uses a "next outbound stream" id and then -increments this modulo the total number outbound streams. That -is, successive values of <c>undefined</c> cycle through all outbound -streams.</p> +The value <c>undefined</c> uses a "next outbound stream" id and +increments this modulo the total number outbound streams. +That is, successive values of <c>undefined</c> cycle through all +outbound streams.</p> <!-- TODO: Some way of getting at the number of available outbound --> <!-- streams. --> @@ -128,7 +144,9 @@ streams.</p> <title>SEE ALSO</title> <p> -<seealso marker="diameter_transport">diameter_transport(3)</seealso></p> +<seealso marker="diameter_transport">diameter_transport(3)</seealso>, +<seealso marker="kernel:gen_sctp">gen_sctp(3)</seealso>, +<seealso marker="kernel:inet">inet(3)</seealso></p> </section> diff --git a/lib/diameter/doc/src/diameter_tcp.xml b/lib/diameter/doc/src/diameter_tcp.xml index e6b53383c0..3ffcebfd90 100644 --- a/lib/diameter/doc/src/diameter_tcp.xml +++ b/lib/diameter/doc/src/diameter_tcp.xml @@ -4,7 +4,7 @@ <erlref> <header> <copyright> -<year>2011</year> +<year>2011</year><year>2012</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> <legalnotice> @@ -38,8 +38,9 @@ under the License. <description> <p> -This module implements diameter transport over TCP using gen_tcp. -It can be specified as the value of a transport_module option to +This module implements diameter transport over TCP using <seealso +marker="kernel:gen_tcp">gen_tcp</seealso>. +It can be specified as the value of a <c>transport_module</c> option to <seealso marker="diameter#add_transport">diameter:add_transport/2</seealso> and implements the behaviour documented in @@ -65,17 +66,17 @@ before configuring TLS capability on diameter transports.</p> <fsummary>Start a transport process.</fsummary> <type> <v>Type = connect | accept</v> -<v>Ref = reference()</v> +<v>Ref = <seealso marker="diameter#transport_ref">diameter:transport_ref()</seealso></v> <v>Svc = #diameter_service{}</v> -<v>Opt = OwnOpt | SslOpt | OtherOpt</v> +<v>Opt = OwnOpt | SslOpt | TcpOpt</v> <v>Pid = pid()</v> -<v>LAddr = ip_address()</v> +<v>LAddr = <seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso></v> <v>Reason = term()</v> -<v>OwnOpt = {raddr, ip_address()} +<v>OwnOpt = {raddr, <seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>} | {rport, integer()} | {port, integer()}</v> <v>SslOpt = {ssl_options, true | list()}</v> -<v>OtherOpt = term()</v> +<v>TcpOpt = term()</v> </type> <desc> @@ -89,25 +90,32 @@ Options <c>raddr</c> and <c>rport</c> specify the remote address and port for a connecting transport and are not valid for a listening transport. Option <c>ssl_options</c> must be specified for a transport -that must be able to support TLS: a value of <c>true</c> results in a +that should support TLS: a value of <c>true</c> results in a TLS handshake immediately upon connection establishment while -list() specifies options to be passed to ssl:connect/2 of ssl:ssl_accept/2 +<c>list()</c> specifies options to be passed to <seealso +marker="ssl:ssl#connect-2">ssl:connect/2</seealso> or +<seealso marker="ssl:ssl#ssl_accept-2">ssl:ssl_accept/2</seealso> after capabilities exchange if TLS is negotiated. -Remaining options are any accepted by ssl:connect/3 or gen_tcp:connect/3 for -a connecting transport, or ssl:listen/3 or gen_tcp:listen/2 for +Remaining options are any accepted by <seealso +marker="ssl:ssl#connect-3">ssl:connect/3</seealso> or <seealso +marker="kernel:gen_tcp#connect-3">gen_tcp:connect/3</seealso> for +a connecting transport, or <seealso +marker="ssl:ssl#listen-2">ssl:listen/2</seealso> or <seealso +marker="kernel:gen_tcp#listen-2">gen_tcp:listen/2</seealso> for a listening transport, depending on whether or not <c>{ssl_options, true}</c> has been specified. -Options <c>binary</c>, <c>packet</c> and <c>active</c> cannot be specified. +Options <c>binary</c>, +<c>packet</c> and <c>active</c> cannot be specified. Also, option <c>port</c> can be specified for a listening transport to specify the local listening port, the default being the standardized 3868 if unspecified. -Note that option <c>ip</c> specifies the local address.</p> +Note that the option <c>ip</c> specifies the local address.</p> <p> An <c>ssl_options</c> list must be specified if and only if -the transport in question has specified an Inband-Security-Id -AVP with value TLS on the relevant call to -<seealso +the transport in question has set <c>Inband-Security-Id</c> to +1 (<c>TLS</c>), as +specified to either <seealso marker="diameter#start_service">start_service/2</seealso> or <seealso marker="diameter#add_transport">add_transport/2</seealso>, @@ -122,9 +130,9 @@ that will not be forthcoming, which will eventually cause the RFC 3539 watchdog to take down the connection.</p> <p> -If the service specifies more than one Host-IP-Address and -option <c>ip</c> is unspecified then then the -first of the service's addresses is used as the local address.</p> +If the <c>#diameter_service{}</c> record has more than one +<c>Host-IP-Address</c> and option <c>ip</c> is unspecified then the +first of the these addresses is used as the local address.</p> <p> The returned local address list has length one.</p> @@ -142,7 +150,10 @@ The returned local address list has length one.</p> <p> <seealso marker="diameter">diameter(3)</seealso>, -<seealso marker="diameter_transport">diameter_transport(3)</seealso></p> +<seealso marker="diameter_transport">diameter_transport(3)</seealso>, +<seealso marker="kernel:gen_tcp">gen_tcp(3)</seealso>, +<seealso marker="kernel:inet">inet(3)</seealso>, +<seealso marker="ssl:ssl">ssl(3)</seealso></p> </section> diff --git a/lib/diameter/doc/src/diameter_transport.xml b/lib/diameter/doc/src/diameter_transport.xml index 087a90b099..1bd45d9ce8 100644 --- a/lib/diameter/doc/src/diameter_transport.xml +++ b/lib/diameter/doc/src/diameter_transport.xml @@ -59,11 +59,11 @@ parent).</p> <fsummary>Start a transport process.</fsummary> <type> <v>Type = connect | accept</v> -<v>Ref = reference()</v> +<v>Ref = <seealso marker="diameter#transport_ref">diameter:transport_ref()</seealso></v> <v>Svc = #diameter_service{}</v> <v>Opts = term()</v> <v>Pid = pid()</v> -<v>LAddrs = [ip_address()]</v> +<v>LAddrs = [<seealso marker="kernel:inet#type-ip_address">inet:ip_address()</seealso>]</v> <v>Reason = term()</v> </type> <desc> @@ -93,16 +93,19 @@ It should not link to the parent. It should exit if its transport connection with its peer is lost.</p> <p> -Transport processes for a given service are started sequentially.</p> - -<p> -The start function should use the 'Host-IP-Address' list on the service, -namely <c>Svc#diameter_service.host_ip_address</c>, and/or +The capabilities in the <c>#diameter_service{}</c> record are as +passed to <seealso +marker="diameter#start_service">diameter:start_service/2</seealso> and +<seealso +marker="diameter#add_transport">diameter:add_transport/2</seealso>, +values passed to the latter overriding those passed to the former. +The start function should use the <c>Host-IP-Address</c> list and/or <c>Opts</c> to select an appropriate list of local IP addresses, -and should return this list if different from the service addresses. -The returned list is used to populate 'Host-IP-Address' AVPs in outgoing -capabilities exchange messages, the service addresses being used -otherwise.</p> +and should return this list if different from the +<c>#diameter_service{}</c> addresses. +The returned list is used to populate <c>Host-IP-Address</c> AVPs in +outgoing capabilities exchange messages, the +<c>#diameter_service{}</c> addresses being used otherwise.</p> <marker id="MESSAGES"/> </desc> @@ -129,9 +132,10 @@ diameter.</p> <item> <p> An outbound Diameter message. -Packet can be either <c>binary()</c> (the message to be sent) -or a <c>#diameter_packet{}</c> whose <c>transport_data</c> field -containes a value other than undefined.</p> +<c>Packet</c> can be either binary() (the message to be sent) +or a <c>#diameter_packet{}</c> record whose <c>transport_data</c> +field contains a value other than undefined and whose <c>bin</c> field +contains the binary to send.</p> </item> <tag><c>{diameter, {close, Pid}}</c></tag> @@ -140,7 +144,7 @@ containes a value other than undefined.</p> A request to close the transport connection. The transport process should terminate after closing the connection. -Pid is the pid() of the parent process.</p> +<c>Pid</c> is the pid() of the parent process.</p> </item> <tag><c>{diameter, {tls, Ref, Type, Bool}}</c></tag> @@ -148,17 +152,17 @@ Pid is the pid() of the parent process.</p> <p> Indication of whether or not capabilities exchange has selected inband security using TLS. -Ref is a reference() that must be included in the +<c>Ref</c> is a reference() that must be included in the <c>{diameter, {tls, Ref}}</c> reply message to the transport's parent process (see below). -Type is either <c>connect</c> or <c>accept</c> depending on +<c>Type</c> is either <c>connect</c> or <c>accept</c> depending on whether the process has been started for a connecting or listening transport respectively. -Bool is a boolean() indicating whether or not the transport connection -should be upgraded to TLS.</p> +<c>Bool</c> is a boolean() indicating whether or not the transport +connection should be upgraded to TLS.</p> <p> -If TLS is requested (Bool = true) then a connecting process should +If TLS is requested (<c>Bool=true</c>) then a connecting process should initiate a TLS handshake with the peer and an accepting process should prepare to accept a handshake. A successful handshake should be followed by a <c>{diameter, {tls, Ref}}</c> @@ -182,18 +186,18 @@ to its parent.</p> <tag><c>{diameter, {self(), connected}}</c></tag> <item> <p> -Inform the parent that the transport process with Type = accept has +Inform the parent that the transport process with <c>Type=accept</c> has established a connection with the peer. -Not sent if the transport process has Type = connect.</p> +Not sent if the transport process has <c>Type=connect</c>.</p> </item> <tag><c>{diameter, {self(), connected, Remote}}</c></tag> <item> <p> -Inform the parent that the transport process with Type = connect +Inform the parent that the transport process with <c>Type=connect</c> has established a connection with a peer. -Not sent if the transport process has Type = accept. -Remote is an arbitrary term that uniquely identifies the remote +Not sent if the transport process has <c>Type=accept</c>. +<c>Remote</c> is an arbitrary term that uniquely identifies the remote endpoint to which the transport has connected.</p> </item> @@ -201,14 +205,14 @@ endpoint to which the transport has connected.</p> <item> <p> An inbound Diameter message. -Packet can be either <c>binary()</c> (the message to be sent) -or <c>#diameter_packet{}</c> -whose <c>packet</c> field contains a <c>binary()</c>. -Any value (other than undefined) set in +<c>Packet</c> can be either binary() (the received message) +or a <c>#diameter_packet{}</c> record +whose <c>bin</c> field contains the received binary(). +Any value (other than <c>undefined</c>) set in the <c>transport_data</c> field will be passed back with a corresponding answer message in the case that the inbound message is a request unless the sender sets another value. -How the <c>transport_data</c> is used/interpreted is up to the +How <c>transport_data</c> is used/interpreted is up to the transport module.</p> </item> @@ -216,7 +220,7 @@ transport module.</p> <item> <p> Acknowledgment of a successful TLS handshake. -Ref is the reference() received in the +<c>Ref</c> is the reference() received in the <c>{diameter, {tls, Ref, Type, Bool}}</c> message in response to which the reply is sent. A transport must exit if a handshake is not successful.</p> diff --git a/lib/diameter/doc/src/diameter_using.xml b/lib/diameter/doc/src/diameter_using.xml index 809b76bdf3..7d9c0cd492 100644 --- a/lib/diameter/doc/src/diameter_using.xml +++ b/lib/diameter/doc/src/diameter_using.xml @@ -5,7 +5,7 @@ <header> <copyright> -<year>2011</year> +<year>2011</year><year>2012</year> <holder>Ericsson AB. All Rights Reserved.</holder> </copyright> @@ -23,7 +23,7 @@ under the License. </legalnotice> -<title>Using the stack</title> +<title>Usage</title> <prepared></prepared> <responsible></responsible> <docno></docno> diff --git a/lib/diameter/src/base/diameter.erl b/lib/diameter/src/base/diameter.erl index 6703841f80..4f90b741ae 100644 --- a/lib/diameter/src/base/diameter.erl +++ b/lib/diameter/src/base/diameter.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2011. All Rights Reserved. +%% Copyright Ericsson AB 2010-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -312,7 +312,7 @@ call(SvcName, App, Message) -> -type transport_opt() :: {transport_module, atom()} | {transport_config, any()} - | {transport_timeout, non_neg_integer() | infinity} + | {transport_config, any(), non_neg_integer() | infinity} | {applications, [app_alias()]} | {capabilities, [capability()]} | {capabilities_cb, evaluable()} @@ -323,10 +323,11 @@ call(SvcName, App, Message) -> %% Predicate passed to remove_transport/2 -type transport_pred() - :: fun((reference(), connect|listen, list()) -> boolean()) - | fun((reference(), list()) -> boolean()) + :: fun((transport_ref(), connect|listen, list()) -> boolean()) + | fun((transport_ref(), list()) -> boolean()) | fun((list()) -> boolean()) - | reference() + | transport_ref() + | boolean() | list() | {connect|listen, transport_pred()} | {atom(), atom(), list()}. diff --git a/lib/diameter/src/base/diameter_peer.erl b/lib/diameter/src/base/diameter_peer.erl index a2a1c567d8..74ba709aac 100644 --- a/lib/diameter/src/base/diameter_peer.erl +++ b/lib/diameter/src/base/diameter_peer.erl @@ -91,10 +91,21 @@ start(_T, _Opts, #diameter_service{}) -> Opt :: diameter:transport_opt(), TPid :: pid(), Addr :: inet:ip_address(), - Tmo :: non_neg_integer(), + Tmo :: non_neg_integer() | infinity, Data :: {{T, Mod, Cfg}, [Mod], [{T, [Mod], Cfg}], [Err]}, Mod :: module(), Cfg :: term(), + Err :: term() + ; ({#diameter_service{}, Tmo, Data}) + -> {TPid, [Addr], Tmo, Data} + | {error, [term()]} + when TPid :: pid(), + Addr :: inet:ip_address(), + Tmo :: non_neg_integer() | infinity, + Data :: {{T, Mod, Cfg}, [Mod], [{T, [Mod], Cfg}], [Err]}, + T :: {connect|accept, diameter:transport_ref()}, + Mod :: module(), + Cfg :: term(), Err :: term(). %% Initial start. diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl index 5b8a399758..54594db292 100644 --- a/lib/diameter/src/base/diameter_service.erl +++ b/lib/diameter/src/base/diameter_service.erl @@ -2951,7 +2951,7 @@ info_stats(#state{peerT = PeerT}) -> %% the accumulated values for the ref and associated peer pids. info_transport(S) -> - PeerD = peer_dict(S), + PeerD = peer_dict(S, config_dict(S)), RefsD = dict:map(fun(_, Ls) -> [P || L <- Ls, {peer, {P,_}} <- L] end, PeerD), Refs = lists:append(dict:fold(fun(R, Ps, A) -> [[R|Ps] | A] end, @@ -2966,18 +2966,29 @@ info_transport(S) -> [], PeerD). +%% Only a config entry for a listening transport: use it. +transport([[{type, listen}, _] = L]) -> + L ++ [{accept, []}]; + +%% Only one config or peer entry for a connecting transport: use it. transport([[{type, connect} | _] = L]) -> L; +%% Peer entries: discard config. Note that the peer entries have +%% length at least 3. +transport([[_,_] | L]) -> + transport(L); + +%% Possibly many peer entries for a listening transport. Note that all +%% have the same options by construction, which is not terribly space +%% efficient. (TODO: all entries for the same Ref should share options.) transport([[{type, accept}, {options, Opts} | _] | _] = Ls) -> [{type, listen}, {options, Opts}, {accept, [lists:nthtail(2,L) || L <- Ls]}]. -%% Note that all peer records for a listening transport (ie. same Ref) -%% have the same options. (TODO) -peer_dict(#state{peerT = PeerT, connT = ConnT}) -> - ets:foldl(fun(T,A) -> peer_acc(ConnT, A, T) end, dict:new(), PeerT). +peer_dict(#state{peerT = PeerT, connT = ConnT}, Dict0) -> + ets:foldl(fun(T,A) -> peer_acc(ConnT, A, T) end, Dict0, PeerT). peer_acc(ConnT, Acc, #peer{pid = Pid, type = Type, @@ -3000,6 +3011,22 @@ info_conn(ConnT, TPid, true) info_conn(_, _, _) -> []. +%% The point of extracting the config here is so that 'transport' info +%% has one entry for each transport ref, the peer table only +%% containing entries that have a living watchdog. + +config_dict(#state{service_name = SvcName}) -> + lists:foldl(fun config_acc/2, + dict:new(), + diameter_config:lookup(SvcName)). + +config_acc({Ref, T, Opts}, Dict) + when T == listen; + T == connect -> + dict:store(Ref, [[{type, T}, {options, Opts}]], Dict); +config_acc(_, Dict) -> + Dict. + wd_state({_,S}) -> S; wd_state(?STATE_UP) -> @@ -3023,7 +3050,9 @@ info_port(Pid) -> {TPid, {_Type, TMod, _Cfg}} = T, {_, TD} = process_info(TPid, dictionary), {_, Data} = lists:keyfind({TMod, info}, 1, TD), - [{owner, TPid}, {module, TMod} | [_|_] = TMod:info(Data)]. + [{owner, TPid}, + {module, TMod} + | try TMod:info(Data) catch _:_ -> [] end]. %% Use the fields names from diameter_caps instead of %% diameter_base_CER to distinguish between the 2-tuple values @@ -3036,14 +3065,8 @@ info_caps(#diameter_caps{} = C) -> info_apps(#state{service = #diameter_service{applications = Apps}}) -> lists:map(fun mk_app/1, Apps). -mk_app(#diameter_app{alias = Alias, - dictionary = Dict, - module = ModX, - id = Id}) -> - [{alias, Alias}, - {dictionary, Dict}, - {module, ModX}, - {id, Id}]. +mk_app(#diameter_app{} = A) -> + lists:zip(record_info(fields, diameter_app), tl(tuple_to_list(A))). %% info_pending/1 %% @@ -3074,7 +3097,7 @@ info_connections(S) -> [L ++ [stats([P], Stats)] || L <- ConnL, {peer, {P,_}} <- L]. conn_list(S) -> - lists:append(dict:fold(fun conn_acc/3, [], peer_dict(S))). + lists:append(dict:fold(fun conn_acc/3, [], peer_dict(S, dict:new()))). conn_acc(Ref, Peers, Acc) -> [[[{ref, Ref} | L] || L <- Peers, lists:keymember(peer, 1, L)] @@ -3095,26 +3118,24 @@ stats_acc(Ref, Dict, Stats) -> %% info_peers/1 %% %% One entry per peer Origin-Host. Statistics for each entry are -%% accumulated values for all associated transport refs and peer pids. +%% accumulated values for all peer pids. info_peers(S) -> - ConnL = conn_list(S), {PeerD, RefD} = lists:foldl(fun peer_acc/2, {dict:new(), dict:new()}, - ConnL), - Refs = lists:append(dict:fold(fun(_, Rs, A) -> [lists:append(Rs) | A] end, + conn_list(S)), + Refs = lists:append(dict:fold(fun(_, Rs, A) -> [Rs|A] end, [], RefD)), Stats = diameter_stats:read(Refs), dict:fold(fun(OH, Cs, A) -> - Rs = lists:append(dict:fetch(OH, RefD)), - [{OH, [{connections, Cs}, stats(Rs, Stats)]} - | A] + Rs = dict:fetch(OH, RefD), + [{OH, [{connections, Cs}, stats(Rs, Stats)]} | A] end, [], PeerD). peer_acc(Peer, {PeerD, RefD}) -> - [Ref, {TPid, _}, [{origin_host, {_, OH}} | _]] - = [proplists:get_value(K, Peer) || K <- [ref, peer, caps]], - {dict:append(OH, Peer, PeerD), dict:append(OH, [Ref, TPid], RefD)}. + [{TPid, _}, [{origin_host, {_, OH}} | _]] + = [proplists:get_value(K, Peer) || K <- [peer, caps]], + {dict:append(OH, Peer, PeerD), dict:append(OH, TPid, RefD)}. diff --git a/lib/diameter/src/transport/diameter_tcp.erl b/lib/diameter/src/transport/diameter_tcp.erl index 597f2f14d7..f3fbbee609 100644 --- a/lib/diameter/src/transport/diameter_tcp.erl +++ b/lib/diameter/src/transport/diameter_tcp.erl @@ -80,7 +80,7 @@ %% Accepting/connecting transport process state. -record(transport, - {socket :: inet:socket(), %% accept or connect socket + {socket :: inet:socket() | ssl:sslsock(), %% accept or connect socket parent :: pid(), %% of process that started us module :: module(), %% gen_tcp-like module frag = <<>> :: binary() | {tref(), frag()}, %% message fragment diff --git a/lib/diameter/test/diameter_ct.erl b/lib/diameter/test/diameter_ct.erl index f8ee3dc1d7..ded50bf6c5 100644 --- a/lib/diameter/test/diameter_ct.erl +++ b/lib/diameter/test/diameter_ct.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2011. All Rights Reserved. +%% Copyright Ericsson AB 2010-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -25,15 +25,14 @@ -export([run/1]). -%% ct:run_test/1 is currently documented as returning a list of test -%% results ... but no. Instead it returns 'ok' regardless of whether -%% or not the suite in question has failed testcases. +%% The makefile looks for signs of failure so ignore the ct:run_test/1 +%% return value. run([Suite]) -> Start = info(), - ok = ct:run_test([{suite, Suite}, - {logdir, "./log"}, - {auto_compile, false}]), + ct:run_test([{suite, Suite}, + {logdir, "./log"}, + {auto_compile, false}]), info(Start , info()). info() -> diff --git a/lib/diameter/test/diameter_gen_sctp_SUITE.erl b/lib/diameter/test/diameter_gen_sctp_SUITE.erl index 5e65b84b56..2fde7b9fdb 100644 --- a/lib/diameter/test/diameter_gen_sctp_SUITE.erl +++ b/lib/diameter/test/diameter_gen_sctp_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2011. All Rights Reserved. +%% Copyright Ericsson AB 2010-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -175,7 +175,8 @@ send(Sock, Id) -> send_from_multiple_clients(_) -> {S, Rs} = T = send_from_multiple_clients(8, 1024), - {false, [], _} = {?FOREVER < S, + Max = ?FOREVER*1000, + {false, [], _} = {Max < S, Rs -- [OI || {O,_} = OI <- Rs, is_integer(O)], T}. @@ -223,6 +224,11 @@ send_from_multiple_clients(_) -> %% {134,100}, %% {117,98}, %% {149,125}]} +%% +%% This turns out to have been due to SCTP resends as a consequence of +%% the listener having an insufficient recbuf. Increasing the size +%% solves the problem. +%% send_from_multiple_clients(N, Sz) when is_integer(N), 0 < N, is_integer(Sz), 0 < Sz -> diff --git a/lib/erl_docgen/src/docgen_edoc_xml_cb.erl b/lib/erl_docgen/src/docgen_edoc_xml_cb.erl index 20daae8215..cbaa93a15d 100644 --- a/lib/erl_docgen/src/docgen_edoc_xml_cb.erl +++ b/lib/erl_docgen/src/docgen_edoc_xml_cb.erl @@ -338,7 +338,7 @@ otp_xmlify_e(#xmlElement{name=code} = E) -> % 4) end; otp_xmlify_e(#xmlElement{name=Tag} = E) % 5a when Tag==h1; Tag==h2; Tag==h3; Tag==h4; Tag==h5 -> - Content = text_only(E#xmlElement.content), + Content = text_and_a_name_only(E#xmlElement.content), [E#xmlElement{name=b, content=Content}]; otp_xmlify_e(#xmlElement{name=Tag} = E) % 5b-c) when Tag==center; @@ -1161,6 +1161,18 @@ get_text(#xmlElement{content=[#xmlText{value=Text}]}) -> get_text(#xmlElement{content=[E]}) -> get_text(E). +%% text_and_name_only(Es) -> Ts +text_and_a_name_only([#xmlElement{ + name = a, + attributes = [#xmlAttribute{name=name}]} = Name|Es]) -> + [Name|text_and_a_name_only(Es)]; +text_and_a_name_only([#xmlElement{content = Content}|Es]) -> + text_and_a_name_only(Content) ++ text_and_a_name_only(Es); +text_and_a_name_only([#xmlText{} = E |Es]) -> + [E | text_and_a_name_only(Es)]; +text_and_a_name_only([]) -> + []. + %% text_only(Es) -> Ts %% Takes a list of xmlElement and xmlText and return a lists of xmlText. text_only([#xmlElement{content = Content}|Es]) -> diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl index 1ef73da1be..fbb77b6a42 100644 --- a/lib/hipe/cerl/erl_bif_types.erl +++ b/lib/hipe/cerl/erl_bif_types.erl @@ -1483,6 +1483,8 @@ type(erlang, statistics, 1, Xs) -> t_tuple([t_non_neg_integer(), t_integer(0)]); ['wall_clock'] -> t_tuple([t_non_neg_integer(), t_integer(0)]); + ['scheduler_wall_time'] -> + t_list(t_tuple([t_integer(), t_number(), t_number()])); List when is_list(List) -> T_statistics_1; unknown -> @@ -1532,6 +1534,8 @@ type(erlang, system_flag, 2, Xs) -> t_sequential_tracer(); ['trace_control_word'] -> t_integer(); + ['scheduler_wall_time'] -> + t_boolean(); List when is_list(List) -> T_system_flag_2; unknown -> @@ -3901,6 +3905,7 @@ arg_types(erlang, statistics, 1) -> t_atom('reductions'), t_atom('run_queue'), t_atom('runtime'), + t_atom('scheduler_wall_time'), t_atom('wall_clock')])]; arg_types(erlang, subtract, 2) -> arg_types(erlang, '--', 2); @@ -3925,6 +3930,7 @@ arg_types(erlang, system_flag, 2) -> t_atom('trace_control_word'), %% 'internal_cpu_topology' is an undocumented internal feature. t_atom('internal_cpu_topology'), + t_atom('scheduler_wall_time'), t_integer()]), t_sup([t_integer(), %% 'cpu_topology' @@ -3940,6 +3946,9 @@ arg_types(erlang, system_flag, 2) -> %% The following two are for 'multi_scheduling' t_atom('block'), t_atom('unblock'), + %% For 'scheduler_wall_time' + t_atom('true'), + t_atom('false'), %% The following is for 'internal_cpu_topology' t_internal_cpu_topology()])]; arg_types(erlang, system_info, 1) -> @@ -4267,7 +4276,7 @@ arg_types(hipe_bifs, ref_get, 1) -> arg_types(hipe_bifs, ref_set, 2) -> [t_hiperef(), t_immediate()]; arg_types(hipe_bifs, remove_refs_from, 1) -> - [t_mfa()]; + [t_sup([t_mfa(), t_atom('all')])]; arg_types(hipe_bifs, set_funinfo_native_address, 3) -> arg_types(hipe_bifs, set_native_address, 3); arg_types(hipe_bifs, set_native_address, 3) -> diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl index 6fe05dec80..923213d34d 100644 --- a/lib/inets/src/http_client/httpc_handler.erl +++ b/lib/inets/src/http_client/httpc_handler.erl @@ -55,7 +55,7 @@ status_line, % {Version, StatusCode, ReasonPharse} headers, % #http_response_h{} body, % binary() - mfa, % {Moduel, Function, Args} + mfa, % {Module, Function, Args} pipeline = queue:new(), % queue() keep_alive = queue:new(), % queue() status, % undefined | new | pipeline | keep_alive | close | ssl_tunnel diff --git a/lib/inets/src/http_server/httpd_log.erl b/lib/inets/src/http_server/httpd_log.erl index 60ab326a20..a34435e0e8 100644 --- a/lib/inets/src/http_server/httpd_log.erl +++ b/lib/inets/src/http_server/httpd_log.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2008-2011. All Rights Reserved. +%% Copyright Ericsson AB 2008-2012. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -36,8 +36,8 @@ AuthUser :: string(), Date :: string(), StatusCode :: pos_integer(), - Size :: pos_integer() | string()) -> - {Log :: atom() | pid(), Entry :: string()}. + Size :: 0 | pos_integer() | string()) -> + {Log :: atom() | pid(), Entry :: string()} | term() . access_entry(Log, NoLog, Info, RFC931, AuthUser, Date, StatusCode, SizeStr) when is_list(SizeStr) -> @@ -69,7 +69,7 @@ access_entry(Log, NoLog, Info :: #mod{}, Date :: string(), Reason :: term()) -> - {Log :: atom() | pid(), Entry :: string()}. + {Log :: atom() | pid(), Entry :: string()} | term(). error_entry(Log, NoLog, #mod{config_db = ConfigDB, @@ -87,7 +87,7 @@ error_entry(Log, NoLog, ConfigDB :: term(), Date :: string(), ErrroStr :: string()) -> - {Log :: atom() | pid(), Entry :: string()}. + {Log :: atom() | pid(), Entry :: string()} | term(). error_report_entry(Log, NoLog, ConfigDb, Date, ErrorStr) -> MakeEntry = fun() -> io_lib:format("[~s], ~s~n", [Date, ErrorStr]) end, @@ -99,7 +99,7 @@ error_report_entry(Log, NoLog, ConfigDb, Date, ErrorStr) -> ConfigDB :: term(), Date :: string(), Reason :: term()) -> - {Log :: atom() | pid(), Entry :: string()}. + {Log :: atom() | pid(), Entry :: string()} | term(). security_entry(Log, NoLog, #mod{config_db = ConfigDB}, Date, Reason) -> MakeEntry = fun() -> io_lib:format("[~s] ~s~n", [Date, Reason]) end, diff --git a/lib/kernel/doc/src/code.xml b/lib/kernel/doc/src/code.xml index ee687511a3..214e61cc00 100644 --- a/lib/kernel/doc/src/code.xml +++ b/lib/kernel/doc/src/code.xml @@ -91,7 +91,7 @@ of the additional library directories will override modules with the same name in OTP, except for modules in Kernel and STDLIB.</p> - <p>The environment variable <c>ERL_LIBS</c> (if defined) shold contain + <p>The environment variable <c>ERL_LIBS</c> (if defined) should contain a colon-separated (for Unix-like systems) or semicolon-separated (for Windows) list of additional libraries.</p> <p>Example: On an Unix-like system, <c>ERL_LIBS</c> could be set to diff --git a/lib/reltool/doc/src/reltool.xml b/lib/reltool/doc/src/reltool.xml index 9b43640d83..2567a72999 100644 --- a/lib/reltool/doc/src/reltool.xml +++ b/lib/reltool/doc/src/reltool.xml @@ -144,7 +144,7 @@ value <c>include</c> implies that all applications and escripts that do not have any explicit <c>incl_cond</c> setting will be included. <c>exclude</c> implies that all - applications and escripts) that do not have any explicit + applications and escripts that do not have any explicit <c>incl_cond</c> setting will be excluded.</p> </item> diff --git a/lib/ssh/src/ssh.appup.src b/lib/ssh/src/ssh.appup.src index 6967a0f464..d08dbafc32 100644 --- a/lib/ssh/src/ssh.appup.src +++ b/lib/ssh/src/ssh.appup.src @@ -24,6 +24,7 @@ {load_module, ssh_connection_manager, soft_purge, soft_purge, []}, {load_module, ssh_auth, soft_purge, soft_purge, []}, {load_module, ssh_channel, soft_purge, soft_purge, []}, + {load_module, ssh_file, soft_purge, soft_purge, []}]}, {load_module, ssh, soft_purge, soft_purge, []}]}, {<<"2.0\\.*">>, [{restart_application, ssh}]}, {<<"1\\.*">>, [{restart_application, ssh}]} @@ -34,6 +35,7 @@ {load_module, ssh_connection_manager, soft_purge, soft_purge, []}, {load_module, ssh_auth, soft_purge, soft_purge, []}, {load_module, ssh_channel, soft_purge, soft_purge, []}, + {load_module, ssh_file, soft_purge, soft_purge, []}]}, {load_module, ssh, soft_purge, soft_purge, []}]}, {<<"2.0\\.*">>, [{restart_application, ssh}]}, {<<"1\\.*">>, [{restart_application, ssh}]} diff --git a/lib/ssh/src/ssh_file.erl b/lib/ssh/src/ssh_file.erl index d05fa8e09a..a6b82a7a13 100644 --- a/lib/ssh/src/ssh_file.erl +++ b/lib/ssh/src/ssh_file.erl @@ -232,7 +232,7 @@ lookup_host_key_fd(Fd, Host, KeyType) -> eof -> {error, not_found}; Line -> - case public_key:ssh_decode(Line, known_hosts) of + case ssh_decode_line(Line, known_hosts) of [{Key, Attributes}] -> handle_host(Fd, Host, proplists:get_value(hostnames, Attributes), Key, KeyType); [] -> @@ -240,6 +240,13 @@ lookup_host_key_fd(Fd, Host, KeyType) -> end end. +ssh_decode_line(Line, Type) -> + try + public_key:ssh_decode(Line, Type) + catch _:_ -> + [] + end. + handle_host(Fd, Host, HostList, Key, KeyType) -> Host1 = host_name(Host), case lists:member(Host1, HostList) and key_match(Key, KeyType) of @@ -285,7 +292,7 @@ lookup_user_key_fd(Fd, Key) -> eof -> {error, not_found}; Line -> - case public_key:ssh_decode(Line, auth_keys) of + case ssh_decode_line(Line, auth_keys) of [{AuthKey, _}] -> case is_auth_key(Key, AuthKey) of true -> diff --git a/lib/ssl/test/ssl_test_lib.erl b/lib/ssl/test/ssl_test_lib.erl index b39c995552..63731ee25c 100644 --- a/lib/ssl/test/ssl_test_lib.erl +++ b/lib/ssl/test/ssl_test_lib.erl @@ -150,7 +150,7 @@ run_client(Opts) -> {ok, Socket} -> Pid ! { connected, Socket }, test_server:format("Client: connected~n", []), - %% In specail cases we want to know the client port, it will + %% In special cases we want to know the client port, it will %% be indicated by sending {port, 0} in options list! send_selected_port(Pid, proplists:get_value(port, Options), Socket), {Module, Function, Args} = proplists:get_value(mfa, Opts), diff --git a/lib/stdlib/doc/src/unicode_usage.xml b/lib/stdlib/doc/src/unicode_usage.xml index b7b5d497d0..acd36d2125 100644 --- a/lib/stdlib/doc/src/unicode_usage.xml +++ b/lib/stdlib/doc/src/unicode_usage.xml @@ -212,7 +212,7 @@ Eshell V5.7 (abort with ^G) <section> <title>Unicode in environment variables and parameters</title> <p>Environment variables and their interpretation is handled much in the same way as file names. If Unicode file names are enabled, environment variables as well as parameters to the Erlang VM are expected to be in Unicode.</p> -<p>If Unicode file names are enabled, the calls to <seealso marker="kernel:os#os_getenv/0"><c>os:getenv/0</c></seealso>, <seealso marker="kernel:os#os_getenv/1"><c>os:getenv/1</c></seealso> and <seealso marker="kernel:os#os_putenv/2"><c>os:putenv/2</c></seealso> will handle Unicode strings. On Unix-like platforms, the built-in functions will translate environment variables in UTF-8 to/from Unicode strings, possibly with codepoints > 255. On Windows the Unicode versions of the environment system API will be used, also allowing for codepoints > 255.</p> +<p>If Unicode file names are enabled, the calls to <seealso marker="kernel:os#getenv/0"><c>os:getenv/0</c></seealso>, <seealso marker="kernel:os#getenv/1"><c>os:getenv/1</c></seealso> and <seealso marker="kernel:os#putenv/2"><c>os:putenv/2</c></seealso> will handle Unicode strings. On Unix-like platforms, the built-in functions will translate environment variables in UTF-8 to/from Unicode strings, possibly with codepoints > 255. On Windows the Unicode versions of the environment system API will be used, also allowing for codepoints > 255.</p> <p>On Unix-like operating systems, parameters are expected to be UTF-8 without translation if Unicode file names are enabled.</p> </section> <section> diff --git a/lib/test_server/doc/src/test_server_ctrl.xml b/lib/test_server/doc/src/test_server_ctrl.xml index 9028a67ecb..6b33591701 100644 --- a/lib/test_server/doc/src/test_server_ctrl.xml +++ b/lib/test_server/doc/src/test_server_ctrl.xml @@ -769,11 +769,13 @@ Optional, if not given the test server controller node constantly updated. The following can be reported: </p> <p><c>What = tests_start, Data = {Name,NumCases}</c><br></br> + <c>What = loginfo, Data = [{topdir,TestRootDir},{rundir,CurrLogDir}]</c><br></br> <c>What = tests_done, Data = {Ok,Failed,{UserSkipped,AutoSkipped}}</c><br></br> - <c>What = tc_start, Data = {Mod,Func}</c><br></br> + <c>What = tc_start, Data = {{Mod,Func},TCLogFile}</c><br></br> <c>What = tc_done, Data = {Mod,Func,Result}</c><br></br> <c>What = tc_user_skip, Data = {Mod,Func,Comment}</c><br></br> - <c>What = tc_auto_skip, Data = {Mod,Func,Comment}</c></p> + <c>What = tc_auto_skip, Data = {Mod,Func,Comment}</c><br></br> + <c>What = framework_error, Data = {{FWMod,FWFunc},Error}</c></p> </desc> </func> <func> diff --git a/lib/tools/doc/src/xref_chapter.xml b/lib/tools/doc/src/xref_chapter.xml index 39c5545af9..169313cb9c 100644 --- a/lib/tools/doc/src/xref_chapter.xml +++ b/lib/tools/doc/src/xref_chapter.xml @@ -301,7 +301,7 @@ and <c>|||</c>) are the only operators that accept both representations. This means that in order to analyze indirect calls using restriction, the <c>closure</c> operator (which creates the - <c>digraph</c> representation of graphs) has to been + <c>digraph</c> representation of graphs) has to be applied explicitly. </p> <p>As an example of analyzing indirect calls, the following Erlang |