Skip to content

Commit

Permalink
Typeobjects with tests (#255)
Browse files Browse the repository at this point in the history
* Fix tests for common struct name in different modules (#268)

* Refs #20052: fix tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #20052: update submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

---------

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Added TypeObject tests with templates for primitives and strings structures.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Added TypeObject tests for most cases.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Added TypeObject tests for unions enums and annotations.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Added missing checks

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* API changes. Additional checks.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Changes if TypeIdentifiers checks.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* API changes. Fixed errors.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Tests use gtest now.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Format changes.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Fixed namespaces, inheritance check and type functions.

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Typo

Signed-off-by: adriancampo <adriancampo@eprosima.com>

* Refs #19595: -typeobject argument is deprecated. TypeObject files will always be generated

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix copyright and include header order. Remove unused headers

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix TypeObjectRegistry::get_type_identifiers call

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix TypeObjectRegistry::get_type_objects call

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: remove const tests: constants do not have TypeObject

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix templates. Remove non-required parameter

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: simplify test templates and include collection and string tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: refactor struct TypeObject test

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: refactor bitset TypeObject test

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: refactor bitset TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix enum type TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix enum literals TypeObject test

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix bitmask TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix type detail annotations checks

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix alias tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix union type TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix union member tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: reorder templates. Fixes for string/wstring

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: check Collection TypeIdentifier EquivalenceKind

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix discriminator API according to review suggestion

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: array type tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix map type tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: map type tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix build errors

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: check TypeIdentifier and TypeObject consistency

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: remove non-necessary template attribute

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: member applied annotations check

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: remove non necessary templates. Check already done within consistency methods

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: check dimension/union label

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: add annotation type test

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: w/string type tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: REMOVE: comment TypeObject code in order to build

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: update submodules

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fixes in TypeObject tests

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: update dds types test submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: update idl parser submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: fix Fast DDS include

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

* Refs #19595: update submodule

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>

---------

Signed-off-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
Signed-off-by: adriancampo <adriancampo@eprosima.com>
Co-authored-by: José Luis Bueno López <69244257+JLBuenoLopez-eProsima@users.noreply.github.com>
Co-authored-by: JLBuenoLopez-eProsima <joseluisbueno@eprosima.com>
  • Loading branch information
3 people committed Dec 11, 2023
1 parent 21effb7 commit 1a797d9
Show file tree
Hide file tree
Showing 7 changed files with 1,379 additions and 10 deletions.
2 changes: 1 addition & 1 deletion resources/Custom.stg
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ string_type(ctx, string) ::= <<>>

wide_string_type(ctx, wstring) ::= <<>>

array_declarator(ctx, array, array_type) ::= <<>>
array_declarator(ctx, array) ::= <<>>

interface(ctx, parent, interface, export_list) ::= <<>>

Expand Down
21 changes: 18 additions & 3 deletions src/main/java/com/eprosima/fastdds/fastddsgen.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class fastddsgen
// Generates type naming compatible with ROS 2
private boolean m_type_ros2 = false;

// Generate TypeObject files?
// Generate deprecated TypeObject files
private boolean m_type_object_files = false;

// Generate string and sequence types compatible with C?
Expand Down Expand Up @@ -734,6 +734,12 @@ private Project parseIDL(
tmanager.addGroup("com/eprosima/fastdds/idl/templates/SerializationTestSource.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/SerializationHeader.stg");
tmanager.addGroup("com/eprosima/fastdds/idl/templates/SerializationSource.stg");

if(!m_type_object_files)
{
// Load TypeObject test template
tmanager.addGroup("com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg");
}
}

// Add JNI sources.
Expand Down Expand Up @@ -782,8 +788,7 @@ private Project parseIDL(
lexer.setContext(ctx);
CommonTokenStream tokens = new CommonTokenStream(lexer);
IDLParser parser = new IDLParser(tokens);
// Pass the finelame without the extension

// Pass the filename without the extension
Specification specification = parser.specification(ctx, tmanager, maintemplates).spec;
returnedValue = specification != null && !tmanager.get_st_error();;

Expand Down Expand Up @@ -891,6 +896,15 @@ private Project parseIDL(
String trimmedElement = element.substring(0, element.length() - 4);// Remove .idl
project.addCommonTestingFile(trimmedElement + "Serialization.cpp");
}

if(!m_type_object_files)
{
System.out.println("Generating TypeObjects Test file...");
String fileNameTO = output_dir + ctx.getFilename() + "TypeObjectTestingTest.cpp";
returnedValue = Utils.writeFile(fileNameTO, maintemplates.getTemplate("com/eprosima/fastdds/idl/templates/TypeObjectTestingTestSource.stg"), m_replace);
project.addTypeObjectTestingFile(relative_dir + ctx.getFilename() + "TypeObjectTestingTest.cpp");
//project.addTypeObjectTestingFile(relative_dir + ctx.getFilename() + "TypeObject.cxx");
}
}

System.out.println("Generating Type Support files...");
Expand Down Expand Up @@ -1250,6 +1264,7 @@ private boolean genCMakeLists(

cmake.add("solution", solution);
cmake.add("test", m_test);
cmake.add("type_object_files", !m_type_object_files);

returnedValue = Utils.writeFile(m_outputDir + "CMakeLists.txt", cmake, m_replace);
}
Expand Down
20 changes: 17 additions & 3 deletions src/main/java/com/eprosima/fastdds/idl/templates/CMakeLists.stg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

group CMakeLists;

cmakelists(solution, test) ::= <<
cmakelists(solution, test, type_object_files) ::= <<

cmake_minimum_required(VERSION 3.22)

Expand All @@ -41,11 +41,11 @@ $endif$
find_package(fastcdr REQUIRED)
find_package(fastrtps 2.12 REQUIRED)

$solution.projects : { project | $pub_sub_execs(project=project, libraries=solution.libraries, test=test)$}; separator="\n"$
$solution.projects : { project | $pub_sub_execs(project=project, libraries=solution.libraries, test=test, typeobject=type_object_files)$}; separator="\n"$

>>

pub_sub_execs(project, libraries, test) ::= <<
pub_sub_execs(project, libraries, test, typeobject) ::= <<

message(STATUS "Configuring $project.name$...")
$if(!project.commonSrcFiles.empty)$
Expand Down Expand Up @@ -82,6 +82,20 @@ target_link_libraries($project.name$SerializationTest
)
gtest_discover_tests($project.name$SerializationTest)

$if(typeobject)$

# $project.name$ TypeObject Test
add_executable($project.name$TypeObjectTestingTest
$project.typeObjectTestingFiles : { file | $file$}; separator="\n"$
)
target_link_libraries($project.name$TypeObjectTestingTest
GTest::gtest_main
$solution.libraries : { library | $library$}; separator=" "$
$project.name$_lib $project.dependencies : { dep | $dep$_lib}; separator=" "$)
gtest_discover_tests($project.name$TypeObjectTestingTest)
$endif$

$endif$


>>
Loading

0 comments on commit 1a797d9

Please sign in to comment.