I have written an Expect Script that I need to call from a testcase written in C++. I need the Expect script to be called prior to and after the testcase has done its magic.
Question: How do you call an Expect Script from C++.
Here's my C++ testcase:
====================================================
@TCID: ip99_expect
@GAP_PACKAGE:
set_reserve_timeout(60);
set_trace("LOGGING","ON"
GTP_TRACE="ON";
ip99_expect(resource_name1="gtp:sgsn_shasta_52",
resource_name3="msca:imsi_multi"
@GAP_TC:
#include <tc/TTF.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <gtp_codec/GTP_prot.h>
#include <gtp_ts/GTPTunnel.h>
#include <bss_ts/Mobile.h>
GTPTunnel sgsn("resource_name1", "no_default"
Mobile ms("resource_name3", "no_default"
//----------------------
// user_main
//----------------------
void ohm_main(void)
{
TTF_Result result;
SS7_Msg msg;
TTF_String imsi = "5050241012160001";
TTF_String euAddress;
TTF_String steid;
TTF_String pdpAddress;
uint8 pdpType = 0;
uint8 nsapi = 4;
// Set up routing
sgsn.setPrimaryRouting(imsi, nsapi);
///////I want to call my script here
//----------------
// Bring Tunnel UP
//----------------
// Build "Create PDP Context Request" Message
msg.addIE(GTP_HDR_IE_VERSION_LFN, "32"
msg.addIE(GTP_HDR_IE_MSG_TYPE, GTP_CPDPC_RQST);
//msg.addIE(GTP_HDR_IE_TEID, "00000000"
msg.addIE(GTP_HDR_IE_SEQ_NUM, "0001"
msg.addIE(GTP_HDR_IE_NPDN, "00"
//msg.addIE(GTP_HDR_IE_EXT_HDR_TYPE, "00"
msg.addIE(GTP_IE_IMSI, imsi);
msg.addIE(GTP_IE_SEL_MODE, "fc"
//msg.addIE(GTP_IE_TEID_DATA, "0000000a"
//msg.addIE(GTP_IE_TEID_SIG, "0000000b"
msg.addIE(GTP_IE_NSAPI, nsapi);
msg.addIE(GTP_IE_EU_ADDR, "f121" // IP Address: 0.0.0.0
msg.addIE(GTP_IE_APN, "0474657374" // APN: "test"
//msg.addIE(GTP_IE_APN, "046c327470" // APN: "l2tp"
//msg.addIE(GTP_IE_APN, "056970736563" // APN: "ipsec"
//msg.addIE(GTP_IE_APN, "0a726f72792d6970736563" // rory-ipsec
//msg.addIE(GTP_IE_APN, "0661667368616e" // afshan (ipsec)
msg.addIE(GTP_IE_MSISDN, "919137868588ff"
//msg.addIE(GTP_IE_QOS, "012200007314010122060101"
//msg.addIE(GTP_IE_QOS, "012200007314010122060101" // 68.5
//msg.addIE(GTP_IE_QOS, "011203007314010122060101" // 68.6
//msg.addIE(GTP_IE_QOS, "0122001f5314010122060101" // 68.7
//msg.addIE(GTP_IE_QOS, "012200007314020222060909" // 68.8
//msg.addIE(GTP_IE_QOS, "012200007314010197060101" // 68.9
//msg.addIE(GTP_IE_QOS, "012190007314010122060101" // 68.10
msg.addIE(GTP_IE_QOS, "012200007399010122f80101" // 68.11
//msg.addIE(GTP_IE_QOS, "012200000114010122060101" // 68.12
//msg.addIE(GTP_IE_QOS, "01e208e07314010122060101" // 68.13
//msg.addIE(GTP_IE_QOS, "013a00007314010122060101" // 68.14
//msg.addIE(GTP_IE_QOS, "016f00007314010122060101" // 68.15
//msg.addIE(GTP_IE_QOS, "012200007314010122ff0101" // 68.16
//msg.addIE(GTP_IE_QOS, "0122cc003314010122067fff" // 68.17
//msg.addIE(GTP_IE_QOS, "032200007314010122060101" // 68.18
//msg.addIE(GTP_IE_QOS, "032200003314010122060101" // 68.19
//msg.addIE(GTP_IE_QOS, "022200009314010122060101" // 68.20
//msg.addIE(GTP_IE_QOS, "01220000b314010122060101" // 68.21
//msg.addIE(GTP_IE_PRIVATE_EXT, "0232020951001027006f25"
// Send the message to the GGSN
sgsn.send(msg);
// Expect to receive a message within 10000 milliseconds or 10 seconds
sgsn.receive(msg, 10000);
// Using the verifyIE methods of the SS7_Msg class to verify
// IEs in the received message.
msg.verifyIE(GTP_HDR_IE_MSG_TYPE, GTP_CPDPC_RESP);
// Get the IEs from the response message to be reused in the delete req
msg.getIE(GTP_IE_TEID_SIG, steid);
sgsn.getPDPAddress(msg, pdpType, pdpAddress);
sgsn.configureMobileIPRouting(result, pdpAddress);
// Intercepting Data Transfer
//sgsn.setOption(GTP_OPT_TX_LOGGING_ON);
//sgsn.setOption(GTP_OPT_TX_INTERCEPT_ON);
//sgsn.setOption(GTP_OPT_RX_LOGGING_ON);
//sgsn.setOption(GTP_OPT_RX_INTERCEPT_ON);
//************************//
//* RUN USER APPLICATION *//
//************************//
TTF_String application = "/usr/X11R6/bin/xterm -display :$LOCAL_DISPLAY -geo 80x25 -bg '#770000' -fg white -T TUNNEL -n TUNNEL";
sgsn.launchApplicationInContext(result, application);
if (result.get_status() != TTF_OK)
{
report << "*** ERROR Launching Application: " << application << endl;
}
else
{
sgsn.waitUntilApplicationsFinish();
}
//------------------
// Bring Tunnel DOWN
//------------------
// Build "Delete PDP Context Request" Message
msg.clear();
msg.addIE(GTP_HDR_IE_VERSION_LFN, "32"
msg.addIE(GTP_HDR_IE_MSG_TYPE, GTP_DPDPC_RQST);
msg.addIE(GTP_HDR_IE_TEID, steid);
msg.addIE(GTP_HDR_IE_SEQ_NUM, "0002"
msg.addIE(GTP_HDR_IE_NPDN, "00"
msg.addIE(GTP_IE_NSAPI, nsapi);
// Send the message to the SUT
sgsn.send(msg);
// Expect to receive a message within 10000 milliseconds or 10 seconds
sgsn.receive(msg, 10000);
// Using the verifyIE methods of the SS7_Msg class to verify
// IEs in the received message.
msg.verifyIE(GTP_HDR_IE_MSG_TYPE, GTP_DPDPC_RESP);
// Clear Routings
sgsn.clearRouting();
Question: How do you call an Expect Script from C++.
Here's my C++ testcase:
====================================================
@TCID: ip99_expect
@GAP_PACKAGE:
set_reserve_timeout(60);
set_trace("LOGGING","ON"
GTP_TRACE="ON";
ip99_expect(resource_name1="gtp:sgsn_shasta_52",
resource_name3="msca:imsi_multi"
@GAP_TC:
#include <tc/TTF.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <gtp_codec/GTP_prot.h>
#include <gtp_ts/GTPTunnel.h>
#include <bss_ts/Mobile.h>
GTPTunnel sgsn("resource_name1", "no_default"
Mobile ms("resource_name3", "no_default"
//----------------------
// user_main
//----------------------
void ohm_main(void)
{
TTF_Result result;
SS7_Msg msg;
TTF_String imsi = "5050241012160001";
TTF_String euAddress;
TTF_String steid;
TTF_String pdpAddress;
uint8 pdpType = 0;
uint8 nsapi = 4;
// Set up routing
sgsn.setPrimaryRouting(imsi, nsapi);
///////I want to call my script here
//----------------
// Bring Tunnel UP
//----------------
// Build "Create PDP Context Request" Message
msg.addIE(GTP_HDR_IE_VERSION_LFN, "32"
msg.addIE(GTP_HDR_IE_MSG_TYPE, GTP_CPDPC_RQST);
//msg.addIE(GTP_HDR_IE_TEID, "00000000"
msg.addIE(GTP_HDR_IE_SEQ_NUM, "0001"
msg.addIE(GTP_HDR_IE_NPDN, "00"
//msg.addIE(GTP_HDR_IE_EXT_HDR_TYPE, "00"
msg.addIE(GTP_IE_IMSI, imsi);
msg.addIE(GTP_IE_SEL_MODE, "fc"
//msg.addIE(GTP_IE_TEID_DATA, "0000000a"
//msg.addIE(GTP_IE_TEID_SIG, "0000000b"
msg.addIE(GTP_IE_NSAPI, nsapi);
msg.addIE(GTP_IE_EU_ADDR, "f121" // IP Address: 0.0.0.0
msg.addIE(GTP_IE_APN, "0474657374" // APN: "test"
//msg.addIE(GTP_IE_APN, "046c327470" // APN: "l2tp"
//msg.addIE(GTP_IE_APN, "056970736563" // APN: "ipsec"
//msg.addIE(GTP_IE_APN, "0a726f72792d6970736563" // rory-ipsec
//msg.addIE(GTP_IE_APN, "0661667368616e" // afshan (ipsec)
msg.addIE(GTP_IE_MSISDN, "919137868588ff"
//msg.addIE(GTP_IE_QOS, "012200007314010122060101"
//msg.addIE(GTP_IE_QOS, "012200007314010122060101" // 68.5
//msg.addIE(GTP_IE_QOS, "011203007314010122060101" // 68.6
//msg.addIE(GTP_IE_QOS, "0122001f5314010122060101" // 68.7
//msg.addIE(GTP_IE_QOS, "012200007314020222060909" // 68.8
//msg.addIE(GTP_IE_QOS, "012200007314010197060101" // 68.9
//msg.addIE(GTP_IE_QOS, "012190007314010122060101" // 68.10
msg.addIE(GTP_IE_QOS, "012200007399010122f80101" // 68.11
//msg.addIE(GTP_IE_QOS, "012200000114010122060101" // 68.12
//msg.addIE(GTP_IE_QOS, "01e208e07314010122060101" // 68.13
//msg.addIE(GTP_IE_QOS, "013a00007314010122060101" // 68.14
//msg.addIE(GTP_IE_QOS, "016f00007314010122060101" // 68.15
//msg.addIE(GTP_IE_QOS, "012200007314010122ff0101" // 68.16
//msg.addIE(GTP_IE_QOS, "0122cc003314010122067fff" // 68.17
//msg.addIE(GTP_IE_QOS, "032200007314010122060101" // 68.18
//msg.addIE(GTP_IE_QOS, "032200003314010122060101" // 68.19
//msg.addIE(GTP_IE_QOS, "022200009314010122060101" // 68.20
//msg.addIE(GTP_IE_QOS, "01220000b314010122060101" // 68.21
//msg.addIE(GTP_IE_PRIVATE_EXT, "0232020951001027006f25"
// Send the message to the GGSN
sgsn.send(msg);
// Expect to receive a message within 10000 milliseconds or 10 seconds
sgsn.receive(msg, 10000);
// Using the verifyIE methods of the SS7_Msg class to verify
// IEs in the received message.
msg.verifyIE(GTP_HDR_IE_MSG_TYPE, GTP_CPDPC_RESP);
// Get the IEs from the response message to be reused in the delete req
msg.getIE(GTP_IE_TEID_SIG, steid);
sgsn.getPDPAddress(msg, pdpType, pdpAddress);
sgsn.configureMobileIPRouting(result, pdpAddress);
// Intercepting Data Transfer
//sgsn.setOption(GTP_OPT_TX_LOGGING_ON);
//sgsn.setOption(GTP_OPT_TX_INTERCEPT_ON);
//sgsn.setOption(GTP_OPT_RX_LOGGING_ON);
//sgsn.setOption(GTP_OPT_RX_INTERCEPT_ON);
//************************//
//* RUN USER APPLICATION *//
//************************//
TTF_String application = "/usr/X11R6/bin/xterm -display :$LOCAL_DISPLAY -geo 80x25 -bg '#770000' -fg white -T TUNNEL -n TUNNEL";
sgsn.launchApplicationInContext(result, application);
if (result.get_status() != TTF_OK)
{
report << "*** ERROR Launching Application: " << application << endl;
}
else
{
sgsn.waitUntilApplicationsFinish();
}
//------------------
// Bring Tunnel DOWN
//------------------
// Build "Delete PDP Context Request" Message
msg.clear();
msg.addIE(GTP_HDR_IE_VERSION_LFN, "32"
msg.addIE(GTP_HDR_IE_MSG_TYPE, GTP_DPDPC_RQST);
msg.addIE(GTP_HDR_IE_TEID, steid);
msg.addIE(GTP_HDR_IE_SEQ_NUM, "0002"
msg.addIE(GTP_HDR_IE_NPDN, "00"
msg.addIE(GTP_IE_NSAPI, nsapi);
// Send the message to the SUT
sgsn.send(msg);
// Expect to receive a message within 10000 milliseconds or 10 seconds
sgsn.receive(msg, 10000);
// Using the verifyIE methods of the SS7_Msg class to verify
// IEs in the received message.
msg.verifyIE(GTP_HDR_IE_MSG_TYPE, GTP_DPDPC_RESP);
// Clear Routings
sgsn.clearRouting();