Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80548120
dynamic_loader.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Sep 1, 08:19
Size
1 KB
Mime Type
text/x-c
Expires
Tue, Sep 3, 08:19 (2 d)
Engine
blob
Format
Raw Data
Handle
20386643
Attached To
rSPECMICP SpecMiCP / ReactMiCP
dynamic_loader.cpp
View Options
#include <catch.hpp>
#include "utils/plugins/dynamic_library.hpp"
#include <iostream>
#include "utils/log.hpp"
using
namespace
specmicp
::
plugins
;
TEST_CASE
(
"Dynamic Loader"
,
"[plugin]"
)
{
specmicp
::
init_logger
(
nullptr
,
specmicp
::
logger
::
Warning
);
SECTION
(
"Loading"
)
{
std
::
string
error
;
DynamicLibraryPtr
lib
=
DynamicLibrary
::
load
(
"test_to_load.so"
,
error
);
CHECK
(
lib
!=
nullptr
);
if
(
lib
==
nullptr
)
{
std
::
cerr
<<
error
<<
std
::
endl
;
REQUIRE
(
false
);
}
int
(
*
add_f
)(
int
,
int
)
=
(
int
(
*
)(
int
,
int
))
lib
->
get_symbol
(
"add"
,
error
);
CHECK
(
add_f
!=
nullptr
);
if
(
add_f
==
nullptr
)
{
std
::
cerr
<<
error
<<
std
::
endl
;
REQUIRE
(
false
);
}
CHECK
(
add_f
(
1
,
2
)
==
3
);
}
SECTION
(
"Unsuccessful loading"
)
{
std
::
string
error
;
DynamicLibraryPtr
lib
=
DynamicLibrary
::
load
(
"platyput_with_7_legs"
,
error
);
CHECK
(
lib
==
nullptr
);
}
SECTION
(
"Unsuccessful symbol loading"
)
{
std
::
string
error
;
DynamicLibraryPtr
lib
=
DynamicLibrary
::
load
(
"test_to_load.so"
,
error
);
CHECK
(
lib
!=
nullptr
);
if
(
lib
==
nullptr
)
{
std
::
cerr
<<
error
<<
std
::
endl
;
REQUIRE
(
false
);
}
void
*
hop
=
lib
->
get_symbol
(
"latypus_with_7_legs"
,
error
);
CHECK
(
hop
==
nullptr
);
}
}
Event Timeline
Log In to Comment