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

Extend bitset support and test #411

Merged
merged 3 commits into from
Nov 22, 2024
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
5 changes: 4 additions & 1 deletion ridlbe/c++11/templates/cli/hdr/bitset.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public:
% end
%end

bool operator== (const <%= cxxname %> &rhs) const;
bool operator!= (const <%= cxxname %> &rhs) const;

%bitfields.find_all {|bitf| !bitf.cxxname.empty? }.each do |_m|
inline void <%= _m.cxxname %> (<%= _m.cxx_in_type %> _x11_<%= _m.cxxname %>) { this->_taox11_<%= cxxname.downcase %>.<%= _m.cxxname %> = _x11_<%= _m.cxxname %>; }
inline <%= _m.cxx_in_type %> <%= _m.cxxname %> () const { return this->_taox11_<%= cxxname.downcase %>.<%= _m.cxxname %>; }
Expand All @@ -40,7 +43,7 @@ private:
{
%bitfields.each do |bitfield|
/// @copydoc <%= bitfield.doc_scoped_name %>
<%= bitfield.cxx_member_type %> <%= bitfield.cxxname %> : <%= bitfield.bits %>;
<%= bitfield.cxx_member_type %> <%= bitfield.cxxname %> : <%= bitfield.bits %><%= bitfield.cxxname.empty? ? '' : ' {}' %>;
%end
} _taox11_<%= cxxname.downcase %>;
}; // <%= cxxname %>
Expand Down
4 changes: 3 additions & 1 deletion ridlbe/c++11/templates/cli/hdr/bitset_idl_traits.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

%# TODO handle inheritance
// generated from <%= ridl_template_path %>
template<>
struct traits <<%= scoped_cxxtype %>>
Expand All @@ -22,6 +21,9 @@ struct formatter<<%= scoped_cxxtype %>, OStrm_>
{
%_sep = nil
os_ << "<%= formatted_cxxname %>{"
%unless base.nil?
<< IDL::traits<<%= base.cxxname %>>::write(val_) << ','
%end
%bitfields.each do |_m|
% unless _m.cxxname.empty?
<< "<%= _sep %><%= _m.cxxname %>=" << IDL::traits<<%= _m.scoped_cxxtype %>>::write(val_.<%= _m.cxxname %> ())
Expand Down
19 changes: 19 additions & 0 deletions ridlbe/c++11/templates/cli/inl/bitset_inl.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,22 @@ inline void <%= scoped_cxxtype %>::swap (<%= scoped_cxx_out_type %> s)
std::swap (this->_taox11_<%= cxxname.downcase %>, s._taox11_<%= cxxname.downcase %>);
%# end
}

inline bool <%= scoped_cxxtype %>::operator== (const <%= cxxname %> &rhs) const {
return
%unless base.nil?
<%= base.cxxname %>::operator==(rhs) &&
%end
%_ms = bitfields.dup.find_all {|bitf| !bitf.cxxname.empty? }
%unless _ms.empty?
% while !_ms.empty?
% _m = _ms.shift
(this->_taox11_<%= cxxname.downcase %>.<%= _m.cxxname %> == rhs._taox11_<%= cxxname.downcase %>.<%= _m.cxxname %>)<%= _ms.empty? ? ';' : ' &&' %>
% end
%end
}

inline bool <%= scoped_cxxtype %>::operator!= (const <%= cxxname %> &rhs) const
{
return !this->operator== (rhs);
}
122 changes: 120 additions & 2 deletions tests/idl4/bitset/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,130 @@
#include "testC.h"
#include "testlib/taox11_testlog.h"

int main (int /*argc*/, char* /*argv*/[])
int main (int argc, char* argv[])
{
int error_count = 0;

MyBitset1 mbs1;

// Just compilation test
TAOX11_TEST_INFO << "mbs1: " << mbs1 << std::endl;

return 0;
try
{
IDL::traits<CORBA::ORB>::ref_type _orb = CORBA::ORB_init (argc, argv);

if (!_orb)
{
TAOX11_TEST_ERROR << "ERROR: CORBA::ORB_init (argc, argv) returned null ORB." << std::endl;
return 1;

Check warning on line 29 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L28-L29

Added lines #L28 - L29 were not covered by tests
}

IDL::traits<CORBA::Object>::ref_type obj = _orb->string_to_object ("file://test.ior");

if (!obj)
{
TAOX11_TEST_ERROR << "ERROR: string_to_object(<ior>) returned null reference." << std::endl;
return 1;

Check warning on line 37 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L36-L37

Added lines #L36 - L37 were not covered by tests
}

TAOX11_TEST_DEBUG << "retrieved object reference" << std::endl;

IDL::traits<Test::Foo>::ref_type foo = IDL::traits<Test::Foo>::narrow (obj);

if (!foo)
{
TAOX11_TEST_ERROR << "ERROR: IDL::traits<Test::Foo>::narrow (obj) returned null object." << std::endl;
return 1;

Check warning on line 47 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L46-L47

Added lines #L46 - L47 were not covered by tests
}
TAOX11_TEST_DEBUG << "narrowed Foo interface" << std::endl;

MyBitset1 sin1 {};
MyBitset1 sinout1 {};
MyBitset1 sout1 {};

TAOX11_TEST_DEBUG << "Sending MyBitset1 sin: " << sin1 << " sinout: " << sinout1 << std::endl;
MyBitset1 const sret1 = foo->test_mybitset1 (sin1, sinout1, sout1);
if (sout1 != sin1)
{
TAOX11_TEST_ERROR << "ERROR: sout1<" << sout1 << "> != sin1<" << sin1 << ">" << std::endl;
++error_count;

Check warning on line 60 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L59-L60

Added lines #L59 - L60 were not covered by tests
}
if (sinout1 != sin1)
{
TAOX11_TEST_ERROR << "ERROR: sinout1<" << sinout1 << "> != sin<" << sin1 << ">" << std::endl;
++error_count;

Check warning on line 65 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L64-L65

Added lines #L64 - L65 were not covered by tests
}
TAOX11_TEST_DEBUG << "Received MyBitset1 sret1: " << sret1 << " sinout1: " << sinout1 << " sout1: " << sout1 << std::endl;

MyBitset2 sin2 {};
MyBitset2 sinout2 {};
MyBitset2 sout2 {};

TAOX11_TEST_DEBUG << "Sending MyBitset2 sin: " << sin2 << " sinout: " << sinout2 << std::endl;
MyBitset2 const sret2 = foo->test_mybitset2 (sin2, sinout2, sout2);
if (sout2 != sin2)
{
TAOX11_TEST_ERROR << "ERROR: sout2<" << sout2 << "> != sin2<" << sin2 << ">" << std::endl;
++error_count;

Check warning on line 78 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L77-L78

Added lines #L77 - L78 were not covered by tests
}
if (sinout2 != sin2)
{
TAOX11_TEST_ERROR << "ERROR: sinout2<" << sinout2 << "> != sin<" << sin2 << ">" << std::endl;
++error_count;

Check warning on line 83 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L82-L83

Added lines #L82 - L83 were not covered by tests
}
TAOX11_TEST_DEBUG << "Received MyBitset2 sret2: " << sret2 << " sinout2: " << sinout2 << " sout2: " << sout2 << std::endl;

MyBitset3 sin3 {};
MyBitset3 sinout3 {};
MyBitset3 sout3 {};

TAOX11_TEST_DEBUG << "Sending MyBitset3 sin: " << sin3 << " sinout: " << sinout3 << std::endl;
MyBitset3 const sret3 = foo->test_mybitset3 (sin3, sinout3, sout3);
if (sout3 != sin3)
{
TAOX11_TEST_ERROR << "ERROR: sout3<" << sout3 << "> != sin3<" << sin3 << ">" << std::endl;
++error_count;

Check warning on line 96 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L95-L96

Added lines #L95 - L96 were not covered by tests
}
if (sinout3 != sin3)
{
TAOX11_TEST_ERROR << "ERROR: sinout3<" << sinout3 << "> != sin<" << sin3 << ">" << std::endl;
++error_count;

Check warning on line 101 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L100-L101

Added lines #L100 - L101 were not covered by tests
}
TAOX11_TEST_DEBUG << "Received MyBitset3 sret3: " << sret3 << " sinout3: " << sinout3 << " sout3: " << sout3 << std::endl;

MyBitset4 sin4 {};
MyBitset4 sinout4 {};
MyBitset4 sout4 {};

TAOX11_TEST_DEBUG << "Sending MyBitset4 sin: " << sin4 << " sinout: " << sinout4 << std::endl;
MyBitset4 const sret4 = foo->test_mybitset4 (sin4, sinout4, sout4);
if (sout4 != sin4)
{
TAOX11_TEST_ERROR << "ERROR: sout4<" << sout4 << "> != sin4<" << sin4 << ">" << std::endl;
++error_count;

Check warning on line 114 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L113-L114

Added lines #L113 - L114 were not covered by tests
}
if (sinout4 != sin4)
{
TAOX11_TEST_ERROR << "ERROR: sinout4<" << sinout4 << "> != sin<" << sin4 << ">" << std::endl;
++error_count;

Check warning on line 119 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L118-L119

Added lines #L118 - L119 were not covered by tests
}
TAOX11_TEST_DEBUG << "Received MyBitset4 sret4: " << sret4 << " sinout4: " << sinout4 << " sout4: " << sout4 << std::endl;

TAOX11_TEST_DEBUG << "shutting down..." << std::endl;
foo->shutdown ();
_orb->destroy ();
}
catch (const CORBA::BAD_PARAM& e)

Check warning on line 127 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L127

Added line #L127 was not covered by tests
{
TAOX11_TEST_ERROR << "main - ERROR - Unexpected CORBA::BAD_PARAM exception caught"
<< e << std::endl;
++error_count;

Check warning on line 131 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L129-L131

Added lines #L129 - L131 were not covered by tests
}
catch (const std::exception& e)

Check warning on line 133 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L133

Added line #L133 was not covered by tests
{
TAOX11_TEST_ERROR << "main - ERROR - Unexpected exception caught: " << e << std::endl;
++error_count;

Check warning on line 136 in tests/idl4/bitset/client.cpp

View check run for this annotation

Codecov / codecov/patch

tests/idl4/bitset/client.cpp#L135-L136

Added lines #L135 - L136 were not covered by tests
}
return error_count;
}
58 changes: 58 additions & 0 deletions tests/idl4/bitset/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @file foo.cpp
* @author Johnny Willemsen
*
* @copyright Copyright (c) Remedy IT Expertise BV
*/
#include "foo.h"

#include "testlib/taox11_testlog.h"

Foo::Foo (IDL::traits<CORBA::ORB>::ref_type orb,
IDL::traits<PortableServer::POA>::ref_type poa)
: orb_ (std::move(orb))
, poa_ (std::move(poa))
{
}

MyBitset1
Foo::test_mybitset1 (const MyBitset1 & sin, MyBitset1 & sinout, MyBitset1 & sout)
{
sout = sin;
sinout = sin;
MyBitset1 sret = sin;
return sret;
}

MyBitset2
Foo::test_mybitset2 (const MyBitset2 & sin, MyBitset2 & sinout, MyBitset2 & sout)
{
sout = sin;
sinout = sin;
MyBitset2 sret = sin;
return sret;
}

MyBitset3
Foo::test_mybitset3 (const MyBitset3 & sin, MyBitset3 & sinout, MyBitset3 & sout)
{
sout = sin;
sinout = sin;
MyBitset3 sret = sin;
return sret;
}

MyBitset4
Foo::test_mybitset4 (const MyBitset4 & sin, MyBitset4 & sinout, MyBitset4 & sout)
{
sout = sin;
sinout = sin;
MyBitset4 sret = sin;
return sret;
}

void
Foo::shutdown ()
{
this->orb_->shutdown (false);
}
36 changes: 36 additions & 0 deletions tests/idl4/bitset/foo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @file foo.h
* @author Johnny Willemsen
*
* @copyright Copyright (c) Remedy IT Expertise BV
*/
#ifndef FOO_H
#define FOO_H

#include "testS.h"

class Foo final
: public virtual CORBA::servant_traits<Test::Foo>::base_type
{
public:
/// Constructor
Foo (IDL::traits<CORBA::ORB>::ref_type orb,
IDL::traits<PortableServer::POA>::ref_type poa);

// = The skeleton methods
MyBitset1 test_mybitset1 (const MyBitset1 & sin, MyBitset1 & sinout, MyBitset1 & sout) override;
MyBitset2 test_mybitset2 (const MyBitset2 & sin, MyBitset2 & sinout, MyBitset2 & sout) override;
MyBitset3 test_mybitset3 (const MyBitset3 & sin, MyBitset3 & sinout, MyBitset3 & sout) override;
MyBitset4 test_mybitset4 (const MyBitset4 & sin, MyBitset4 & sinout, MyBitset4 & sout) override;

void shutdown () override;

private:
/// Use an ORB reference shutdown the server.
IDL::traits<CORBA::ORB>::ref_type orb_;
/// Use a POA reference to activate the references to
// the template module interface.
IDL::traits<PortableServer::POA>::ref_type poa_;
};

#endif /* FOO_H */
63 changes: 55 additions & 8 deletions tests/idl4/bitset/run_test.pl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#---------------------------------------------------------------------
# @file run_test.pl
# @author Marcel Smit
# @author Johnny Willemsen
#
# @copyright Copyright (c) Remedy IT Expertise BV
#---------------------------------------------------------------------
Expand All @@ -13,19 +13,66 @@
use lib "$ENV{ACE_ROOT}/bin";
use PerlACE::TestTarget;

my $target = PerlACE::TestTarget::create_target(2) || die "Create target 2 failed\n";
my $status = 0;
my $debug_level = '0';

$status = 0;
foreach $i (@ARGV) {
if ($i eq '-debug') {
$debug_level = '10';
}
}

my $server = PerlACE::TestTarget::create_target(2) || die "Create target 2 failed\n";
my $client = PerlACE::TestTarget::create_target(3) || die "Create target 3 failed\n";

my $iorbase = "test.ior";
my $server_iorfile = $server->LocalFile ($iorbase);
my $client_iorfile = $client->LocalFile ($iorbase);
$server->DeleteFile($iorbase);
$client->DeleteFile($iorbase);

my $SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile");
my $CL = $client->CreateProcess ("client", "-ORBdebuglevel $debug_level -k file://$client_iorfile");
my $server_status = $SV->Spawn ();

if ($server_status != 0) {
print STDERR "ERROR: server returned $server_status\n";
exit 1;
}

if ($server->WaitForFileTimed ($iorbase,
$server->ProcessStartWaitInterval()) == -1) {
print STDERR "ERROR: cannot find file <$server_iorfile>\n";
$SV->Kill (); $SV->TimedWait (1);
exit 1;
}

if ($server->GetFile ($iorbase) == -1) {
print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
$SV->Kill (); $SV->TimedWait (1);
exit 1;
}
if ($client->PutFile ($iorbase) == -1) {
print STDERR "ERROR: cannot set file <$client_iorfile>\n";
$SV->Kill (); $SV->TimedWait (1);
exit 1;
}

$SV = $target->CreateProcess ("client");
my $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval());

if ($client_status != 0) {
print STDERR "ERROR: client returned $client_status\n";
$status = 1;
}

$server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval());
$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval());

if ($server != 0) {
print STDERR "ERROR: client returned $server\n";
if ($server_status != 0) {
print STDERR "ERROR: server returned $server_status\n";
$status = 1;
}

$target->GetStderrLog();
$server->DeleteFile($iorbase);
$client->DeleteFile($iorbase);

exit $status;
Loading