WiFi QC Automated test: A preliminary study of Ixchariot API

Source: Internet
Author: User

Chariot provides us with a friendly interface, but you must use the command line or use its API to

Implement automated testing. Chariot will let you choose the command line interface component at the time of installation, there are some tools under its installation directory,

Do not know what to do for a while, but its C language API can try it.

Open the chariot Help file and you can see that it has API interface:

Among them, Tcl interface can refer to other people's blog, has not yet found someone has done C language, here began to study.

Help inside mentions that it supports these compilers (QT may also be supported, just not listed):

    • Microsoft Visual C + +. NET 2003, Visual Studio 6.0 SP5 and above.
    • IBM VisualAge for C + + Version 3.5 and above. (Note:this compiler is no longer available for new purchases).
    • Watcom C + + Version 10.0 and above. (Note:this compiler is no longer available for new purchases).

I use VC6.0 to do this for the sake of effort.

Create a new project and add the following documents:

These files can be found under the C:\Program files\ixia\ixchariot\sdk directory.

The compiled result is 0 error, 0 warnings

Then click on the VC exclamation mark after the run error, said need to ChrApi.dll. I also took a detour here.

After unpacking the Lib file, found that there are many such DLLs, I randomly extract all will be problematic.

A DLL viewer was later found to be unable to recognize these DLLs. Finally, under the Chariot installation directory

These DLLs are found. The resulting test.exe can be run directly into the Chariot installation directory (although there may be minor problems).

That's half the success. The next step is to modify, refine, and customize the code.

Here's an example code:

/**************************************************************** * * Ixchariot API SDK file:chrlbsimple.c  * * This module contains code made available by Ixia in an as is * basis. Any one receiving the module are considered to being * licensed under Ixia copyrights to use the ixia-provided * Source Co  De in any-the-he or she deems fit, including copying * it, compiling it, modifying it, and redistributing it, with * or Without modifications. No license under any Ixia patents * or patent applications are to being implied from this copyright * license. * * A user of the module should understand that Ixia cannot * provide technical support for the module and is not being * Responsible for any consequences of the. * * Any notices, including this one, is not to is removed from * the module without the prior written consent of Ixia.  * For more information, contact: * * Ixia * 26601 W. Agoura Rd. * Calabasas, CA 91302 USA * Web:http://www.ixiacom.com * phone:818-871-1800 * fax:818-871-1805 * * General Information: * e-mail: [email protected] * *  Technical Support: * e-mail: [email protected] * * Example:your First Program * * The program creates and runs A simple loopback test using * The File Send, short Connection script, prints some results, * and saves it to disk. * * All attributes of the This test is defined by the this program. * ****************************************************************/#include <stdio.h> #include <stdlib.h > #include <string.h>/* * The header file which defines everything in the Chariot API: * functions, constants, etc . */#include ". /.. /include/chrapi.h "/* * Local function to print information about errors. */static Voidshow_error (chr_handle HANDLE, CHR_API_RC code, chr_string where);/* Data for the test: * Change t hese for your local network if desired. */staticchr_string e1 = "localhost"; staticchr_string e2 = "localhost"; staticchr_stringScript = "C:/Program files/ixia/ixchariot/scripts/throughput.scr"; staticchr_string testfile = "LBTEST.TST"; StaticCHR  _count timeout = 120; /* 2 minutes in seconds *//************************************************************** * * Program main * * If the Retu RN code from any Chariot API function call Chr_ok, the Show_error () function was called to * display information a Bout what happened then exit. * * The numbers is parentheses in the comments refer to the * program Notes sections of the Chariot API Programming Guide.     * **************************************************************/void Main () {/* * The object handles we ll need    */Chr_test_handle TEST = (chr_test_handle) NULL;    Chr_pair_handle PAIR = (chr_pair_handle) NULL;    /* * Variables and buffers for the attributes and results */Chr_count Paircount;    Chr_protocol PROTOCOL;    Char ADDR[CHR_MAX_ADDR];    Char Scriptname[chr_max_filename]; Char Applscriptname[chr_max_appl_script_naME];    Chr_length Len;    Chr_count Timingreccount;    Chr_float avg, Min, Max;    /* * Buffer for extended error info for initialization */char errorinfo[chr_max_error_info];    /* * Chariot API return code */CHR_API_RC RC;     /* (1) * Initialize the Chariot API * before you can use the functions in it. * Chariot API function * which includes extended error information * In its calling parameters, S     Ince it is * isn't associated with an object.    */rc = Chr_api_initialize (Chr_detail_level_all, ErrorInfo, Chr_max_error_info, &len); if (CHR_OK! = RC) {/* * Because initialization failed, we can ' t * ask the API for the message F or this * return code, so we can ' t call our * SHOW_ERROR () function.         Instead, we ' ll * Print what we do know before exiting.        */printf ("Initialization failed:rc =%d\n", RC); printf"Extended error info:\n%s\n", errorinfo);     }/* (2) * Must create a test object to define a new test * or to the load an existing test from disk.        */if (CHR_OK = = rc) {printf ("Create the test...\n");        rc = Chr_test_new (&test);        if (rc = CHR_OK) {show_error ((chr_handle) NULL, RC, "test_new");     }}//* (3) * Must create a pair object in order to define it.        */if (CHR_OK = = rc) {printf ("Create the pair...\n");        rc = Chr_pair_new (&pair);        if (rc = CHR_OK) {show_error ((chr_handle) NULL, RC, "pair_new");     }}//* (4) * Once You has a pair, you can define its attributes.        */if (CHR_OK = = rc) {printf ("Set required pair attributes...\n");        rc = chr_pair_set_e1_addr (pair, E1, strlen (E1));        if (rc! = CHR_OK) {show_error (pair, RC, "pair_set_e1_addr"); }} if (CHR_OK = = rc) {rc = CHR_PAIR_SET_E2_ADDR (pair, E2, strlen (E2));        if (rc! = CHR_OK) {show_error (pair, RC, "pair_set_e2_addr");     }}//* (5) * must define a script for use in the test.        */if (CHR_OK = = rc) {printf ("Use a script...\n");        rc = Chr_pair_use_script_filename (pair, script, strlen (script));        if (rc! = CHR_OK) {show_error (pair, RC, "Pair_use_script_filename");     }}//* (6) * Now, the pair is defined, you can add it to the test.        */if (CHR_OK = = rc) {printf ("Add the pair to the test...\n");        rc = Chr_test_add_pair (test, pair);        if (rc! = CHR_OK) {show_error (test, RC, "Test_add_pair");     }}//* (7) * We have a test defined and so now We can run it.        */if (CHR_OK = = rc) {printf ("Run the test...\n");        rc = Chr_test_start (test);        if (rc! = CHR_OK) {show_error (test, RC, "Test_start");  }}/* (8)   * We have a to-wait for the test-stop before We can look * at the results from it.     We'll wait for 2 minutes here, and then call it a error if it has a not yet stopped.        */if (CHR_OK = = rc) {printf ("Wait for the test to stop...\n");        rc = chr_test_query_stop (test, timeout);        if (rc! = CHR_OK) {show_error (test, RC, "Test_query_stop"); }}//* (9) * Let's print out how we defined the test before printing * results from running it.     Since we have the same pair handle * from when we created it, we don ' t need to get it from * the test.        */if (CHR_OK = = rc) {printf ("===========\n");            printf ("Test setup:\n----------\ n");        rc = Chr_test_get_pair_count (test, &paircount);        if (rc! = CHR_OK) {show_error (test, RC, "Get_pair_count");    } printf ("Number of pairs =%d\n", paircount); } if (CHR_OK = = rc) {rc = chr_pair_get_e1_addr (pair, addr, chr_max_addr, &len);        if (rc! = CHR_OK) {show_error (pair, RC, "pair_get_e1_addr");    } printf ("E1 Address:%s\n", addr);        } if (CHR_OK = = rc) {rc = chr_pair_get_e2_addr (pair, addr, chr_max_addr, &len);        if (rc! = CHR_OK) {show_error (pair, RC, "pair_get_e2_addr");    } printf ("E2 Address:%s\n", addr);     }/* * We didn ' t set protocol, but let ' s show it anyway.        */if (CHR_OK = = rc) {rc = Chr_pair_get_protocol (pair, &protocol);        if (rc! = CHR_OK) {show_error (pair, RC, "Pair_get_protocol");    } printf ("Protocol:%d\n", Protocol);     }/* * We'll show both the script filename and * the application script name.                                           */if (CHR_OK = = rc) {rc = Chr_pair_get_script_filename (pair, ScriptName,        Chr_max_filename, &len); if (rc! = CHR_OK) {show_error (pair, RC, "PAIR_GET_SCRipt_filename ");    } printf ("Script filename:%s\n", scriptname);                                           } if (CHR_OK = = rc) {rc = Chr_pair_get_appl_script_name (pair, Applscriptname,        Chr_max_appl_script_name, &len);        if (rc! = CHR_OK) {show_error (pair, RC, "Pair_get_appl_script_name");    } printf ("APPL Script Name:%s\n", applscriptname); }/* (TEN) * Now let's get some results: * The number of timing records and * The Throughput (avg, MIN, max)        , */if (CHR_OK = = rc) {printf ("\ntest results:\n------------\ n");        rc = Chr_pair_get_timing_record_count (pair, &timingreccount);        if (rc! = CHR_OK) {show_error (pair, RC, "Pair_get_timing_record_count");    } printf ("Number of timing records =%d\n", timingreccount); }/* (one) * we ' re not going-to-check for No_such_value here * although We should. This return Code signals that * The requested result was not available for this * particular test. These kinds of results is shown * as "n/a" in the Chariot console display. In this case, * though, we should is able to get throughput.     We'll call * any and return code except CHR_OK an error. */if (CHR_OK = = rc) {rc = Chr_pair_results_get_average (pair, Chr_resu        Lts_throughput, &AMP;AVG);        if (rc! = CHR_OK) {show_error (pair, RC, "Pair_results_get_average"); }} if (CHR_OK = = rc) {rc = Chr_pair_results_get_minimum (pair, Chr_        Results_throughput, &min);        if (rc! = CHR_OK) {show_error (pair, RC, "Pair_results_get_minimum"); }} if (CHR_OK = = rc) {rc = Chr_pair_results_get_maximum (pair, CHR_results_throughput, &max);        if (rc! = CHR_OK) {show_error (pair, RC, "Pair_results_get_maximum"); }/* * We'll format these to look like the Chariot * Console displays these kinds of number    S. */printf ("throughput:\n avg%.3f min%.3f max%.3f\n", Avg, Min, max);     }/* * Finally, let's save the test so we can look at it again.     * We have to set the filename before We can save it.        */if (CHR_OK = = rc) {printf ("==========\nsave the test...\n");        rc = Chr_test_set_filename (test, Testfile, strlen (testfile));        if (rc! = CHR_OK) {show_error (test, RC, "Test_set_filename");        } else {rc = Chr_test_save (test);        } if (rc! = CHR_OK) {show_error (test, RC, "Test_save");  }}/* Explicitly free allocated resources    */if (pair! = (Chr_pair_handle) NULL) {chr_pair_delete (pair);    } if (Test! = (chr_test_handle) NULL) {chr_test_delete (test);     }/* * Exit Test with success or error code. */exit (RC);} /************************************************************** * * Print information about an error and exit.  * * Parameters:handle-what Object had the error * code-the Chariot API return code * where -what function call failed * **************************************************************/static Voidshow_error (CH    R_handle HANDLE, CHR_API_RC code, chr_string where) {char msg[chr_max_return_msg];    Chr_length Msglen;    Char Errorinfo[chr_max_error_info];    Chr_length Errorlen;    CHR_API_RC RC;     /* Get The API message for this return code.    */rc = chr_api_get_return_msg (code, MSG, chr_max_return_msg, &msglen); if (rc = CHR_OK) {/* CouldNot get the message:show why */printf ("%s failed\n", where);    printf ("Unable to get message for return code%d, rc =%d\n", code, RC);    } else {/* Tell the user about the error */printf ("%s FAILED:RC =%d (%s) \ n", where, Code, MSG);     }/* * See if there is extended error information available. * It ' s meaningful only after some error returns.      After * failed "new" function calls, we don't have a handle so * we cannot check for extended error information.          */if ((Code = = Chr_operation_failed | |         Code = = Chr_object_invalid | | Code = = chr_app_group_invalid) && handle! = (chr_handle) NULL) {rc = Chr_common_error_get_info (hand                                       Le, Chr_detail_level_all, ErrorInfo,        Chr_max_error_info, &errorlen); if (rc = = CHR_OK) {/* * We can ignore all non-success return codes here * Because most should not OCCU  R (the API ' s been * initialized, the handle is good, the buffer * pointer is valid, and the detail             Level are okay), * and the No_such_value return code here means * There is NO info available.        */printf ("Extended error info:\n%s\n", errorinfo); }    }}

  

WiFi QC Automated test: A preliminary study of Ixchariot API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.