Commit b1bb61e7 authored by Elemer Lelik's avatar Elemer Lelik
Browse files

Initial contribution

parent 4a405e7d
#titan.TestPorts.STDINOUTmsg
Main project page:
https://projects.eclipse.org/projects/tools.titan
The source code of the TTCN-3 compiler and executor:
https://github.com/eclipse/titan.core
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015 Ericsson
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
File: STDINOUTmsg_CNL113642.tpd
Description: tpd project file
Rev: R3A
Prodnr: CNL 113 642
-->
<TITAN_Project_File_Information version="1.0">
<ProjectName>STDINOUTmsg_CNL113642</ProjectName>
<Folders>
<FolderResource projectRelativePath="src" relativeURI="src"/>
</Folders>
<Files>
<FileResource projectRelativePath="src/STDINOUTmsg_PT.cc" relativeURI="src/STDINOUTmsg_PT.cc"/>
<FileResource projectRelativePath="src/STDINOUTmsg_PT.hh" relativeURI="src/STDINOUTmsg_PT.hh"/>
<FileResource projectRelativePath="src/STDINOUTmsg_PortType.ttcn" relativeURI="src/STDINOUTmsg_PortType.ttcn"/>
</Files>
<ActiveConfiguration>Default</ActiveConfiguration>
<Configurations>
<Configuration name="Default">
<ProjectProperties>
<MakefileSettings>
<generateInternalMakefile>true</generateInternalMakefile>
<GNUMake>true</GNUMake>
<incrementalDependencyRefresh>true</incrementalDependencyRefresh>
<targetExecutable>bin/STDINOUTmsg_CNL113642</targetExecutable>
<buildLevel>Level 3 - Creating object files with dependency update</buildLevel>
</MakefileSettings>
<LocalBuildSettings>
<workingDirectory>bin</workingDirectory>
</LocalBuildSettings>
</ProjectProperties>
</Configuration>
</Configurations>
</TITAN_Project_File_Information>
/******************************************************************************
* Copyright (c) 2009, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Balazs Andor Zalanyi
* Endre Kulcsar
* Gabor Szalai
* Janos Kovesdi
******************************************************************************/
//
// File: STDINOUT_Test.ttcn
// Description: Example test for STDINOUT Test Port
// Rev: R3A
// Prodnr: CNL 113 642
///////////////////////////////////////////////
module STDINOUT_Test
{
import from STDINOUTmsg_PortType all;
type component MTCType
{
port STDINOUTmsg_PT STDINOUT_PORT;
}
testcase HelloW2() runs on MTCType system MTCType
{
timer T;
map(mtc:STDINOUT_PORT, system:STDINOUT_PORT);
STDINOUT_PORT.send("Hello, world!");
T.start(30.0);
alt {
[] STDINOUT_PORT.receive("Hello, TTCN-3!") { T.stop; setverdict(pass); }
[] T.timeout { setverdict(inconc); }
[] STDINOUT_PORT.receive { T.stop; setverdict(fail); }
}
}
control
{
execute(HelloW2());
}
}
[LOGGING]
FileMask := LOG_ALL
ConsoleMask := TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS
[EXECUTE]
STDINOUT_Test.control
[MAIN_CONTROLLER]
NumHCs := 1
#TCPPort := 7618
#!/bin/sh
#The first parameter is the executable
#The second parameter is the configuration file
# The configuration file need to have [MAIN_CONTROLLER] section where NumHCs := 1
mctr_cli $2 | tee /tmp/ttcn3_autostart_${USER}&
#You should wait on stdout for "Listening on TCP port <TCP port>.",
TTCN_TCPPORT=
while [ "$TTCN_TCPPORT" = "" ]
do
sleep 1
TTCN_TCPPORT=`grep "Listening on TCP port" /tmp/ttcn3_autostart_${USER} | sed 's/.*TCP port \([0-9]*\)\./\1/'`
#echo $TTCN_TCPPORT
done
#TTCN_TCPPORT=`grep TCPPort $2 | sed 's/[^0-9]//g'`
#Read the hostname for starting the host controller
TTCN_HOSTNAME=`hostname`
#start the only one host controller in a separate terminal
xterm -title "Input to TTCN" -sb -sl 1000 -fg white -cr white -bg red -geometry 80x10 -e sh -c "./$1 $TTCN_HOSTNAME $TTCN_TCPPORT; echo; echo PUSH ENTER TO CLOSE TERMINAL; read x" &
# -display ehubuux110:17.0
rm -f /tmp/ttcn3_autostart_${USER}
/******************************************************************************
* Copyright (c) 2009, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Balazs Andor Zalanyi
* Endre Kulcsar
* Gabor Szalai
* Janos Kovesdi
******************************************************************************/
//
// File: STDINOUTmsg_PT.cc
// Description: The source file for STDINOUT testport
// Rev: R3A
// Prodnr: CNL 113 642
///////////////////////////////////////////////
#include "STDINOUTmsg_PT.hh"
#include "STDINOUTmsg_PortType.hh"
#include "memory.h"
namespace STDINOUTmsg__PortType {
bool STDINOUTmsg__PT_PROVIDER::port_connected = false;
STDINOUTmsg__PT_PROVIDER::STDINOUTmsg__PT_PROVIDER(const char *par_port_name)
: PORT(par_port_name)
{}
STDINOUTmsg__PT_PROVIDER::~STDINOUTmsg__PT_PROVIDER()
{}
void STDINOUTmsg__PT_PROVIDER::Handle_Fd_Event_Readable(int fd) {
size_t buf_len = 0, buf_size = 32;
int c;
char *buf = (char*)Malloc(buf_size);
while (true)
{
c = getc(stdin);
if (c == EOF)
{
if (buf_len > 0)
incoming_message(CHARSTRING(buf_len, buf));
//Uninstall_Handler();
Handler_Remove_Fd_Read(fd);
break;
}
else if (c == '\n')
{
incoming_message(CHARSTRING(buf_len, buf));
break;
}
else
{
if (buf_len >= buf_size)
{
buf_size *= 2;
buf = (char*)Realloc(buf, buf_size);
}
buf[buf_len++] = c;
}
}
Free(buf);
}
void STDINOUTmsg__PT_PROVIDER::user_map(const char *system_port)
{
if(port_connected)
TTCN_error("Only one STDINOUT Test Port entity can be mapped"
" on the same time");
port_connected = true;
Handler_Add_Fd_Read(fileno(stdin));
}
void STDINOUTmsg__PT_PROVIDER::user_unmap(const char *system_port)
{
port_connected = false;
Uninstall_Handler();
}
void STDINOUTmsg__PT_PROVIDER::outgoing_send(const CHARSTRING& send_par)
{
puts((const char*)send_par);
fflush(stdout);
}
} /* end of namespace */
/******************************************************************************
* Copyright (c) 2009, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Balazs Andor Zalanyi
* Endre Kulcsar
* Gabor Szalai
* Janos Kovesdi
******************************************************************************/
//
// File: STDINOUTmsg_PT.hh
// Description: The header file for STDINOUT testport
// Rev: R3A
// Prodnr: CNL 113 642
///////////////////////////////////////////////
#ifndef STDINOUTmsg__PT_HH
#define STDINOUTmsg__PT_HH
#include <TTCN3.hh>
// Note: Header file STDINOUTmsg_PortType.hh must not be included into this file!
// Please add the declarations of message types manually.
namespace STDINOUTmsg__PortType {
class STDINOUTmsg__PT_PROVIDER : public PORT {
public:
STDINOUTmsg__PT_PROVIDER(const char *par_port_name);
~STDINOUTmsg__PT_PROVIDER();
void set_parameter(const char *parameter_name,
const char *parameter_value){};
void Handle_Fd_Event_Readable(int fd);
void Handle_Timeout(double time_since_last_call) {}
static bool port_connected;
protected:
void user_map(const char *system_port);
void user_unmap(const char *system_port);
void user_start(){};
void user_stop(){};
void outgoing_send(const CHARSTRING& send_par);
virtual void incoming_message(const CHARSTRING& incoming_par) = 0;
};
} /* end of namespace */
#endif
/******************************************************************************
* Copyright (c) 2009, 2015 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Balazs Andor Zalanyi
* Endre Kulcsar
* Gabor Szalai
* Janos Kovesdi
******************************************************************************/
//
// File: STDINOUTmsg_PortType.ttcn
// Description: The definition of ports used by STDINOUT testport
// Rev: R3A
// Prodnr: CNL 113 642
///////////////////////////////////////////////
module STDINOUTmsg_PortType
{
type port STDINOUTmsg_PT message
{
inout charstring;
} with { extension "provider" }
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment