Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eclipse Projects
Eclipse Titan
titan.core
Commits
306edf68
Commit
306edf68
authored
Feb 04, 2021
by
Adam Knapp
Committed by
Gerrit Code Review
Feb 04, 2021
Browse files
Merge "Implemented multiplication of macros in the configuration file (bug 570921)"
parents
dbc5ce69
407aea64
Changes
7
Hide whitespace changes
Inline
Side-by-side
common/config_preproc_la.l
View file @
306edf68
...
@@ -288,6 +288,9 @@ MACRO_REFERENCE_INT \$"{"{WS}{TTCN3IDENTIFIER}{WS}(","{WS}integer{WS})?"}"
...
@@ -288,6 +288,9 @@ MACRO_REFERENCE_INT \$"{"{WS}{TTCN3IDENTIFIER}{WS}(","{WS}integer{WS})?"}"
BEGIN(SC_define_structured);
BEGIN(SC_define_structured);
return LCurly;
return LCurly;
}
}
"*" { return MultiplyOp; }
} /* SC_define */
} /* SC_define */
<SC_define_structured>
<SC_define_structured>
...
...
common/config_preproc_p.y
View file @
306edf68
...
@@ -59,10 +59,15 @@ static char* decode_secret_message(char* encoded);
...
@@ -59,10 +59,15 @@ static char* decode_secret_message(char* encoded);
char* str_val;
char* str_val;
int last_literal;
int last_literal;
} macro_val; /* 0 or 1 */
} macro_val; /* 0 or 1 */
struct {
char* str;
double num;
} multiplication;
}
}
%token <str_val> FillerStuff "whitespace, newline or comment"
%token <str_val> FillerStuff "whitespace, newline or comment"
%token AssignmentChar ":= or ="
%token AssignmentChar ":= or ="
%token MultiplyOp "*"
%token LCurly "{"
%token LCurly "{"
%token RCurly "}"
%token RCurly "}"
%token <str_val> FString "sequence of characters"
%token <str_val> FString "sequence of characters"
...
@@ -78,6 +83,7 @@ static char* decode_secret_message(char* encoded);
...
@@ -78,6 +83,7 @@ static char* decode_secret_message(char* encoded);
%type <str_val> StructuredValue
%type <str_val> StructuredValue
%type <str_val> StructuredValueList
%type <str_val> StructuredValueList
%type <str_val> MacroRhs
%type <str_val> MacroRhs
%type <multiplication> Multiplication
%destructor { Free($$); }
%destructor { Free($$); }
FillerStuff
FillerStuff
...
@@ -97,6 +103,9 @@ MacroRhs
...
@@ -97,6 +103,9 @@ MacroRhs
MacroAssignmentValueList
MacroAssignmentValueList
MacroAssignmentValue
MacroAssignmentValue
%destructor { Free($$.str); }
Multiplication
%%
%%
DefineSections:
DefineSections:
...
@@ -124,6 +133,10 @@ MacroRhs:
...
@@ -124,6 +133,10 @@ MacroRhs:
StructuredDefinition {
StructuredDefinition {
$$ = $1;
$$ = $1;
}
}
|
Multiplication {
$$ = $1.str;
}
;
;
StructuredDefinition:
StructuredDefinition:
...
@@ -250,6 +263,38 @@ FillerStuffConcat:
...
@@ -250,6 +263,38 @@ FillerStuffConcat:
}
}
;
;
Multiplication:
MacroAssignmentValue MultiplyOp MacroAssignmentValue {
char* ptr = NULL;
double num1 = strtod($1.str_val, &ptr);
if (ptr == NULL || *ptr != '\0') {
preproc_error_flag = 1;
config_preproc_error("First operand of multiplication is not a number: %s", $1.str_val);
}
double num2 = strtod($3.str_val, &ptr);
if (ptr == NULL || *ptr != '\0') {
preproc_error_flag = 1;
config_preproc_error("Second operand of multiplication is not a number: %s", $3.str_val);
}
Free($1.str_val);
Free($3.str_val);
$$.num = num1 * num2;
$$.str = mprintf("%lf", $$.num);
}
| Multiplication MultiplyOp MacroAssignmentValue {
char* ptr = NULL;
double num2 = strtod($3.str_val, &ptr);
if (ptr == NULL || *ptr != '\0') {
preproc_error_flag = 1;
config_preproc_error("Second operand of multiplication is not a number: %s", $3.str_val);
}
Free($1.str);
Free($3.str_val);
$$.num = $1.num * num2;
$$.str = mprintf("%lf", $$.num);
}
;
%%
%%
/* BISON error reporting function */
/* BISON error reporting function */
...
...
regression_test/cfgFile/define/Makefile
View file @
306edf68
...
@@ -15,7 +15,7 @@ include $(TOPDIR)/Makefile.regression
...
@@ -15,7 +15,7 @@ include $(TOPDIR)/Makefile.regression
un
export
ABS_SRC
un
export
ABS_SRC
un
export
SRCDIR
un
export
SRCDIR
DIRS
:=
macro_reference structured
DIRS
:=
macro_reference structured
expressions
# List of fake targets:
# List of fake targets:
.PHONY
:
all dep clean run $(DIRS) $(addsuffix /
,
$(DIRS)) profile
.PHONY
:
all dep clean run $(DIRS) $(addsuffix /
,
$(DIRS)) profile
...
...
regression_test/cfgFile/define/expressions/.gitignore
0 → 100644
View file @
306edf68
dir_single_mode
dir_parallel_mode
regression_test/cfgFile/define/expressions/Makefile
0 → 100644
View file @
306edf68
##############################################################################
# Copyright (c) 2000-2021 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
#
# Contributors:
# Baranyi, Botond
#
##############################################################################
TOPDIR
:=
../../../
include
$(TOPDIR)/Makefile.regression
MAKE_PROG
:=
$(MAKE)
TTCN_FILE
:=
expressions.ttcn
CFG
:=
expressions.cfg
FILES
:=
$(TTCN_FILE)
$(CFG)
RUNNABLE
:=
$(TTCN_FILE:.ttcn=)
DIR_SINGLE
:=
dir_single_mode
DIR_PARALLEL
:=
dir_parallel_mode
GENERATED_DIRS
:=
$(DIR_SINGLE)
$(DIR_PARALLEL)
COVERAGE_FLAG
:=
ifeq
($(COVERAGE), yes)
COVERAGE_FLAG
+=
-C
endif
ifdef
DYN
ifeq
($(PLATFORM), WIN32)
export
PATH
:=
$(PATH)
:
$(TTCN3_DIR)
/lib:
$(ABS_SRC)
/
$(DIR_SINGLE)
:
$(ABS_SRC)
/
$(DIR_PARALLEL)
:
else
export
LD_LIBRARY_PATH
:=
$(LD_LIBRARY_PATH)
:
$(ABS_SRC)
/
$(DIR_SINGLE)
:
$(ABS_SRC)
/
$(DIR_PARALLEL)
:
endif
endif
# List of fake targets:
.PHONY
:
all clean run run_single run_parallel runall
all
:
$(GENERATED_DIRS)
$(DIR_SINGLE)
:
mkdir
$@
cd
$@
&&
for
file
in
$(FILES)
;
do
ln
-s
../
$$
file
||
exit
;
done
cd
$@
&&
$(TTCN3_DIR)
/bin/ttcn3_makefilegen
$(COVERAGE_FLAG)
$(SPLIT_FLAG)
$(RT2_FLAG)
-s
./
*
&&
$(MAKE_PROG)
'CXXFLAGS=
$(CXXFLAGS)
'
'LDFLAGS=
$(LDFLAGS)
'
$(DIR_PARALLEL)
:
mkdir
$@
cd
$@
&&
for
file
in
$(FILES)
;
do
ln
-s
../
$$
file
||
exit
;
done
cd
$@
&&
$(TTCN3_DIR)
/bin/ttcn3_makefilegen
$(COVERAGE_FLAG)
$(SPLIT_FLAG)
$(RT2_FLAG)
./
*
&&
$(MAKE_PROG)
'CXXFLAGS=
$(CXXFLAGS)
'
'LDFLAGS=
$(LDFLAGS)
'
run
:
$(GENERATED_DIRS)
cd
$(DIR_SINGLE)
&&
./
$(RUNNABLE)
$(CFG)
cd
$(DIR_PARALLEL)
&&
$(TTCN3_DIR)
/bin/ttcn3_start
$(RUNNABLE)
$(CFG)
# To run all tests, possibly in parallel
run_single
:
$(DIR_SINGLE)
cd
$(DIR_SINGLE)
&&
./
$(RUNNABLE)
$(CFG)
run_parallel
:
$(DIR_PARALLEL)
cd
$(DIR_PARALLEL)
&&
$(TTCN3_DIR)
/bin/ttcn3_start
$(RUNNABLE)
$(CFG)
runall
:
run_single run_parallel
clean distclean
:
rm
-rf
$(GENERATED_DIRS)
regression_test/cfgFile/define/expressions/expressions.cfg
0 → 100644
View file @
306edf68
###############################################################################
# Copyright (c) 2000-2021 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
#
# Contributors:
# Baranyi, Botond
#
###############################################################################
[DEFINE]
DEF_1 := 10.0
DEF_2 :=
2.0
DEF_3 := 1.5
MUL_1 := ${DEF_1}*${DEF_2}
MUL_2 := ${DEF_1}*${DEF_2}*${DEF_3}
MUL_3 := ${DEF_1}*3*${DEF_2}*${DEF_3}
MUL_4 := ${DEF_1}*-1.0e2*${DEF_2}*${DEF_3}
[MODULE_PARAMETERS]
mul1 := ${MUL_1, float}
mul2 := ${MUL_2, float}
mul3 := ${MUL_3, float}
mul4 := ${MUL_4, float}
[EXECUTE]
expressions.control
regression_test/cfgFile/define/expressions/expressions.ttcn
0 → 100644
View file @
306edf68
/******************************************************************************
* Copyright (c) 2000-2021 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Baranyi, Botond
*
******************************************************************************/
module
expressions
{
modulepar
float
mul1
;
modulepar
float
mul2
;
modulepar
float
mul3
;
modulepar
float
mul4
;
type
component
CT
{}
testcase
tc_multiply
()
runs
on
CT
{
if
(
mul1
!=
20.0
)
{
setverdict
(
fail
,
"mul1: "
,
mul1
);
}
if
(
mul2
!=
30.0
)
{
setverdict
(
fail
,
"mul2: "
,
mul1
);
}
if
(
mul3
!=
90.0
)
{
setverdict
(
fail
,
"mul3: "
,
mul1
);
}
if
(
mul4
!=
-
3000.0
)
{
setverdict
(
fail
,
"mul4: "
,
mul1
);
}
setverdict
(
pass
);
}
control
{
execute
(
tc_multiply
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment