Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > 675c8c8167236dfcf8d66da674f931e8 > files > 1485

erlang-doc-R15B-03.3.fc17.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css">
<title>Erlang -- Write you own test server framework</title>
</head>
<body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/test_server-3.5.3.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>Test Server</strong><br><strong>User's Guide</strong><br><small>Version 3.5.3</small></p>
<br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Chapters</strong></small></p>
<ul class="flipMenu" imagepath="../../../../doc/js/flipmenu">
<li id="no" title="Test Server Basics" expanded="false">Test Server Basics<ul>
<li><a href="basics_chapter.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="basics_chapter.html#id56984">Introduction</a></li>
<li title="Getting started"><a href="basics_chapter.html#id56907">Getting started</a></li>
<li title="Definition of terms"><a href="basics_chapter.html#id61500">Definition of terms</a></li>
</ul>
</li>
<li id="no" title="Test Structure and Test Specifications" expanded="false">Test Structure and Test Specifications<ul>
<li><a href="test_spec_chapter.html">
              Top of chapter
            </a></li>
<li title="Test structure"><a href="test_spec_chapter.html#id62057">Test structure</a></li>
<li title="Test specifications"><a href="test_spec_chapter.html#id57989">Test specifications</a></li>
<li title="Test Specification Files"><a href="test_spec_chapter.html#id63174">Test Specification Files</a></li>
<li title="Configuration cases"><a href="test_spec_chapter.html#id60965">Configuration cases</a></li>
<li title="The parallel property and nested configuration cases"><a href="test_spec_chapter.html#id56819">The parallel property and nested configuration cases</a></li>
<li title="Repeated execution of test cases"><a href="test_spec_chapter.html#id56843">Repeated execution of test cases</a></li>
<li title="Shuffled test case order"><a href="test_spec_chapter.html#id59974">Shuffled test case order</a></li>
<li title="Skipping test cases"><a href="test_spec_chapter.html#id60025">Skipping test cases</a></li>
</ul>
</li>
<li id="no" title="Writing Test Suites" expanded="false">Writing Test Suites<ul>
<li><a href="write_test_chapter.html">
              Top of chapter
            </a></li>
<li title="Support for test suite authors"><a href="write_test_chapter.html#id62420">Support for test suite authors</a></li>
<li title="Test suites"><a href="write_test_chapter.html#id62477">Test suites</a></li>
<li title="Init per test case"><a href="write_test_chapter.html#id62508">Init per test case</a></li>
<li title="Test cases"><a href="write_test_chapter.html#id62581">Test cases</a></li>
<li title="Data and Private Directories"><a href="write_test_chapter.html#id62718">Data and Private Directories</a></li>
<li title="Execution environment"><a href="write_test_chapter.html#id62776">Execution environment</a></li>
</ul>
</li>
<li id="no" title="Running Test Suites" expanded="false">Running Test Suites<ul>
<li><a href="run_test_chapter.html">
              Top of chapter
            </a></li>
<li title="Using the test server controller"><a href="run_test_chapter.html#id62898">Using the test server controller</a></li>
</ul>
</li>
<li id="loadscrollpos" title="Write you own test server framework" expanded="true">Write you own test server framework<ul>
<li><a href="write_framework_chapter.html">
              Top of chapter
            </a></li>
<li title="Introduction"><a href="write_framework_chapter.html#id62979">Introduction</a></li>
<li title="Interfacing the test server controller from Erlang"><a href="write_framework_chapter.html#id62997">Interfacing the test server controller from Erlang</a></li>
<li title="Interfacing the test server controller from the operating system."><a href="write_framework_chapter.html#id63107">Interfacing the test server controller from the operating system.</a></li>
<li title="Framework callback functions"><a href="write_framework_chapter.html#id63412">Framework callback functions</a></li>
<li title="Other concerns"><a href="write_framework_chapter.html#id63442">Other concerns</a></li>
</ul>
</li>
<li id="no" title="Examples" expanded="false">Examples<ul>
<li><a href="example_chapter.html">
              Top of chapter
            </a></li>
<li title="Test suite"><a href="example_chapter.html#id63550">Test suite</a></li>
<li title="Test specification file"><a href="example_chapter.html#id63589">Test specification file</a></li>
</ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<h1>5 Write you own test server framework</h1>
  

  <h3><a name="id62979">5.1 
        Introduction</a></h3>
    
    <p>The test server controller can be interfaced from the operating
      system or from within Erlang. The nature of your new framework
      will decide which interface to use. If you want your framework to
      start a new node for each test, the operating system interface is
      very convenient. If your node is already started, going from
      within Erlang might be a more flexible solution.
      </p>
    <p>The two methods are described below.
      </p>
  

  <h3><a name="id62997">5.2 
        Interfacing the test server controller from Erlang</a></h3>
    
    <p>Using the test server from Erlang means that you have to start
      the test server and then add test jobs. Use
      <span class="code">test_server_ctrl:start/0</span> to start a local target or
      <span class="code">test_server_ctrl:start/1</span> to start a remote target. The test
      server is stopped by <span class="code">test_server_ctrl:stop/0</span>.
      </p>
    <p>The argument to <span class="code">test_server_ctrl:start/1</span> is the name of a
      parameter file. The parameter file specifies what type of target
      to start and where to start it, as well as some additional
      parameters needed for different target types. See the reference
      manual for a detailed description of all valid parameters.
      </p>

    <h4>Adding test jobs</h4>
      
      <p>There are many commands available for adding test cases to
        the test server's job queue:        <br>
</p>
      <ul>
        <li>Single test case        <br>
<span class="code">test_server_ctrl:add_case/2/3</span>
</li>
        <li>Multiple test cases from same suite        <br>
<span class="code">test_server_ctrl:add_cases/2/3</span>
</li>
        <li>Test suite module or modules        <br>
<span class="code">test_server_ctrl:add_module/1/2</span>
</li>
        <li>Some or all test suite modules in a directory        <br>
<span class="code">test_server_ctrl:add_dir/2/3</span>
</li>
        <li>Test cases specified in a test specification file        <br>
<span class="code">test_server_ctrl:add_spec/1</span>
</li>
      </ul>
      <p>All test suites are given a unique name, which is usually
        given when the test suite is added to the job queue. In some
        cases, a default name is used, as in the case when a module is
        added without a specified name. The test job name is used to
        store logfiles, which are stored in the `name.logs' directory
        under the current directory.
        </p>
      <p>See the reference manual for details about the functions for
        adding test jobs.
        </p>
    
  

  <h3><a name="id63107">5.3 
        Interfacing the test server controller from the operating system.</a></h3>
    
    <p>The function <span class="code">run_test/1</span> is your interface in the test
      server controller if you wish to use it from the operating
      system. You simply start an erlang shell and invoke this function
      with the <span class="code">-s</span> option. <span class="code">run_test/1</span> starts the test
      server, runs the test specified by the command line and stops the
      test server. The argument to <span class="code">run_test/1</span> is a list of
      command line flags, typically
      <span class="code">['KEY1', Value1, 'KEY2', Value2, ...]</span>. 
      The valid command line flags are listed in the reference manual
      for <span class="code">test_server_ctrl</span>.
      </p>
    <p>A typical command line may look like this      <br>
<span class="code">erl -noshell -s test_server_ctrl run_test KEY1 Value1 KEY2 Value2 ... -s erlang halt</span></p>
    <p>Or make an alias (this is for unix/tcsh)      <br>
<span class="code">alias erl_test 'erl -noshell -s test_server_ctrl run_test \!* -s erlang halt'</span></p>
    <p>And then use it like this      <br>
<span class="code">erl_test KEY1 Value1 KEY2 Value2 ...</span>      <br>
</p>

    <h4>An Example</h4>
      
      <p>An example of starting a test run from the command line        <br>
</p>
      <p><span class="code">erl -name test_srv -noshell -rsh /home/super/otp/bin/ctrsh </span>        <br>
<span class="code">-pa /clearcase/otp/erts/lib/kernel/test </span>        <br>
<span class="code">-boot start_sasl -sasl errlog_type error </span>        <br>
<span class="code">-s test_server_ctrl run_test SPEC kernel.spec -s erlang halt</span>        <br>
</p>
    
  

  <h3><a name="id63412">5.4 
        Framework callback functions</a></h3>
    
    <p>By defining the environment variable
      <span class="code">TEST_SERVER_FRAMEWORK</span> to a module name, the framework
      callback functions can be used. The framework callback functions
      are called by the test server in order let the framework interact
      with the execution of the tests and to keep the framework upto
      date with information about the test progress.
      </p>
    <p>The framework callback functions are described in the reference
      manual for <span class="code">test_server_ctrl</span>.
      </p>
    <p>Note that this topic is in an early stage of development, and
      changes might occur.
      </p>
  

  <h3><a name="id63442">5.5 
        Other concerns</a></h3>
    
    <p>Some things to think about when writing you own test server
      framework:
      </p>
    <ul>
      <li>
<span class="code">emulator version</span> - Make sure that the intended
       version of the emulator is started.
      </li>
      <li>
<span class="code">operating system path</span> - If test cases use port
       programs, make sure the paths are correct.
      </li>
      <li>
<span class="code">recompilation</span> - Make sure all test suites are fresh
       compiled.
      </li>
      <li>
<span class="code">test_server.hrl</span> - Make sure the
      <span class="code">test_server.hrl</span> file is in the include path when
       compiling test suites.
      </li>
      <li>
<span class="code">running applications</span> - Some test suites require
       some applications to be running (e.g. sasl). Make sure they are
       started.
      </li>
    </ul>
  
</div>
<div class="footer">
<hr>
<p>Copyright © 2002-2012 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div></body>
</html>