aa_register_init_class (public)

 aa_register_init_class init_class_id init_class_desc constructor \
    destructor

Defined in packages/acs-automated-testing/tcl/aa-test-procs.tcl

Registers an initialization class to be used by one or more testcases. An initialization class can be assigned to a testcase via the aa_register_case proc. An initialization constructor is called once before running a set of testcases, and the destructor called once upon completion of running a set of testcases.

The idea behind this is that it could be used to perform data intensive operations that shared amongst a set if testcases. For example, mounting an instance of a package. This could be performed by each testcase individually, but this would be highly inefficient if there are any significant number of them. Better to let the acs-automated-testing infrastructure call the init_class code to set the package up, run all the tests, then call the destructor to unmount the package.

Parameters:
init_class_id - Unique string to identify the init class
init_class_desc - Longer description of the init class
constructor - Tcl code block to run to setup the init class
destructor - Tcl code block to tear down the init class
Author:
Peter Harper
Created:
04 November 2001

Partial Call Graph (max 5 caller/called nodes):
%3 test_check_package_mount check_package_mount (test news) aa_register_init_class aa_register_init_class test_check_package_mount->aa_register_init_class test_db_check_news_archive db_check_news_archive (test news) test_db_check_news_archive->aa_register_init_class test_db_check_news_create db_check_news_create (test news) test_db_check_news_create->aa_register_init_class test_db_check_news_revision db_check_news_revision (test news) test_db_check_news_revision->aa_register_init_class test_db_check_news_set_approve db_check_news_set_approve (test news) test_db_check_news_set_approve->aa_register_init_class

Testcases:
check_package_mount, db_check_news_create, db_check_news_revision, db_check_news_archive, db_check_news_set_approve, db_check_news_status
Source code:
    #
    # Work out the package key
    #
    set package_root [file join $::acs::rootdir packages]
    set package_rel [string replace [info script]  0 [string length $package_root]]
    if {![info exists package_key]} {
        set package_key [lindex [file split $package_rel] 0]
    }
    #
    # First, search the current list of init_classes. If an old version already
    # exists, replace it with the new version.
    #
    set lpos 0
    set found_pos -1
    foreach init_class [nsv_get aa_test init_classes] {
        if {[lindex $init_class 0] == $init_class_id &&
            [lindex $init_class 1] == $package_key} {
            nsv_set aa_test init_classes [lreplace [nsv_get aa_test init_classes]  $lpos $lpos  [list $init_class_id $package_key  $init_class_desc  [info script]  $constructor $destructor]]
            set found_pos $lpos
            break
        }
        incr lpos
    }
    #
    # If we haven't already replaced an existing entry, append the new
    # entry to the list.
    #
    if {$found_pos == -1} {
        nsv_lappend aa_test init_classes [list $init_class_id $package_key  $init_class_desc  [info script]  $constructor $destructor]
    }

    #
    # Define the functions.  Note the destructor upvars into the
    # aa_runseries function to gain visibility of all the variables
    # the constructor has exported.
    #
    d_proc -private _${package_key}__i_$init_class_id {} "
    aa_log \"Running \\\"$init_class_id\\\" initialization class constructor\"
    $constructor
  "
    d_proc -private _${package_key}__d_$init_class_id {} "
    upvar _aa_exports _aa_exports
    foreach v \$_aa_exports(\[list $package_key $init_class_id\]) {
      upvar \$v \$v
    }
    $destructor
  "
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: