Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18627] Bugfix correctly resolve alias in DDSQLFilter (backport #3530) #3586

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ struct identifier_processor
{
return DDSFilterValue::ValueKind::ENUM;
}
if (TK_ALIAS == type_object->complete()._d())
{
const TypeIdentifier& aliasedId =
type_object->complete().alias_type().body().common().related_type();
return get_value_kind(aliasedId, pos);
}
break;

}
Expand Down
5 changes: 5 additions & 0 deletions test/blackbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ set(BLACKBOXTESTS_SOURCE ${BLACKBOXTESTS_TEST_SOURCE}
types/KeyedData1mbPubSubTypes.cxx
types/FixedSized.cxx
types/FixedSizedPubSubTypes.cxx
types/TestIncludeRegression3361.cxx
types/TestIncludeRegression3361TypeObject.cxx
types/TestRegression3361.cxx
types/TestRegression3361PubSubTypes.cxx
types/TestRegression3361TypeObject.cxx

utils/data_generators.cpp
utils/lambda_functions.cpp
Expand Down
42 changes: 42 additions & 0 deletions test/blackbox/common/DDSBlackboxTestsContentFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "PubSubWriter.hpp"

#include "../types/HelloWorldTypeObject.h"
#include "../types/TestRegression3361PubSubTypes.h"
#include "../types/TestRegression3361TypeObject.h"

namespace eprosima {
namespace fastdds {
Expand Down Expand Up @@ -576,6 +578,46 @@ TEST_P(DDSContentFilter, WithLimitsDynamicReaders)
state.send_data(reader_4, filter_counter, 3u, { 2, 3, 4 }, true, 2u);
}

//! Regression test for https://github.com/eProsima/Fast-DDS/issues/3361
//! Correctly resolve an alias defined in another header
TEST(DDSContentFilter, CorrectlyHandleAliasOtherHeader)
{
registerTestRegression3361Types();

auto dpf = DomainParticipantFactory::get_instance();

auto participant = dpf->create_participant(0, PARTICIPANT_QOS_DEFAULT);

TypeSupport type( new TestRegression3361PubSubType());

auto ret = type.register_type(participant);

if (ret != ReturnCode_t::RETCODE_OK)
{
throw std::runtime_error("Failed to register type");
}

auto sub = participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT, nullptr);
if (sub == nullptr)
{
throw std::runtime_error("Failed to create subscriber");
}

auto topic = participant->create_topic("TestTopic", type->getName(), TOPIC_QOS_DEFAULT);
if (topic == nullptr)
{
throw std::runtime_error("Failed to create topic");
}

std::string expression = "uuid <> %0";
std::vector<std::string> parameters = {"'1235'"};

auto filtered_topic = participant->create_contentfilteredtopic(
"FilteredTestTopic", topic, expression, parameters);

EXPECT_NE(nullptr, filtered_topic);
}

#ifdef INSTANTIATE_TEST_SUITE_P
#define GTEST_INSTANTIATE_TEST_MACRO(x, y, z, w) INSTANTIATE_TEST_SUITE_P(x, y, z, w)
#else
Expand Down
36 changes: 36 additions & 0 deletions test/blackbox/types/TestIncludeRegression3361.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file TestIncludeRegression3361.cpp
* This source file contains the definition of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/

#ifdef _WIN32
// Remove linker warning LNK4221 on Visual Studio
namespace {
char dummy;
} // namespace
#endif // _WIN32

#include "TestIncludeRegression3361.h"
#include <fastcdr/Cdr.h>

#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;

#include <utility>

70 changes: 70 additions & 0 deletions test/blackbox/types/TestIncludeRegression3361.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
* @file TestIncludeRegression3361.h
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool gen.
*/

#ifndef _FAST_DDS_GENERATED_TESTINCLUDEREGRESSION3361_H_
#define _FAST_DDS_GENERATED_TESTINCLUDEREGRESSION3361_H_


#include <fastrtps/utils/fixed_size_string.hpp>

#include <stdint.h>
#include <array>
#include <string>
#include <vector>
#include <map>
#include <bitset>

#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#define eProsima_user_DllExport __declspec( dllexport )
#else
#define eProsima_user_DllExport
#endif // EPROSIMA_USER_DLL_EXPORT
#else
#define eProsima_user_DllExport
#endif // _WIN32

#if defined(_WIN32)
#if defined(EPROSIMA_USER_DLL_EXPORT)
#if defined(TestIncludeRegression3361_SOURCE)
#define TestIncludeRegression3361_DllAPI __declspec( dllexport )
#else
#define TestIncludeRegression3361_DllAPI __declspec( dllimport )
#endif // TestIncludeRegression3361_SOURCE
#else
#define TestIncludeRegression3361_DllAPI
#endif // EPROSIMA_USER_DLL_EXPORT
#else
#define TestIncludeRegression3361_DllAPI
#endif // _WIN32

namespace eprosima {
namespace fastcdr {
class Cdr;
} // namespace fastcdr
} // namespace eprosima


namespace TestModule {
typedef std::string MACHINEID;
} // namespace TestModule

#endif // _FAST_DDS_GENERATED_TESTINCLUDEREGRESSION3361_H_
10 changes: 10 additions & 0 deletions test/blackbox/types/TestIncludeRegression3361.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef TESTINCLUDE_REGRESSION_3361
#define TESTINCLUDE_REGRESSION_3361

module TestModule {

typedef string MACHINEID;

};

#endif // TESTINCLUDE_REGRESSION_3361
Loading