Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
osie
Commits
6bdbe53d
Commit
6bdbe53d
authored
Nov 15, 2022
by
Balakrishna Balakrishna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inclusion of unit tests
parent
ad52d450
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
16 deletions
+40
-16
coupler/opc-ua-server/server.c
coupler/opc-ua-server/server.c
+2
-1
tests/unit_test/Makefile
tests/unit_test/Makefile
+9
-1
tests/unit_test/test_keep_alive_publisher.c
tests/unit_test/test_keep_alive_publisher.c
+10
-14
tests/unit_test/test_keep_alive_subscriber.c
tests/unit_test/test_keep_alive_subscriber.c
+19
-0
No files found.
coupler/opc-ua-server/server.c
View file @
6bdbe53d
...
...
@@ -70,7 +70,7 @@ static void stopHandler(int sign)
running
=
false
;
}
#ifndef DOING_UNIT_TESTS
int
main
(
int
argc
,
char
**
argv
)
{
// init dictionary only once$
...
...
@@ -194,3 +194,4 @@ int main(int argc, char **argv)
return
retval
==
UA_STATUSCODE_GOOD
?
EXIT_SUCCESS
:
EXIT_FAILURE
;
}
#endif
\ No newline at end of file
tests/unit_test/Makefile
View file @
6bdbe53d
...
...
@@ -3,7 +3,7 @@ CFLAGS= -l:libopen62541.so -L/usr/local/lib -Wall -Wno-missing-braces -ggdb `pkg
LDFLAGS
=
`
pkg-config
--libs
criterion
`
-lmbedcrypto
-lmbedx509
OUT_DIR
=
build/
all
:
test_common test_modio_i2c test_keep_alive test_keep_alive_publisher
all
:
test_common test_modio_i2c test_keep_alive test_keep_alive_publisher
test_keep_alive_subscriber
test_common
:
test_common.o
@
mkdir
-p
$(OUT_DIR)
...
...
@@ -25,12 +25,18 @@ test_keep_alive_publisher: test_keep_alive_publisher.o
$(CC)
-o
$@
$^
$(CFLAGS)
$(LDFLAGS)
@
mv
$@
$(OUT_DIR)
test_keep_alive_subscriber
:
test_keep_alive_subscriber.o
@
mkdir
-p
$(OUT_DIR)
$(CC)
-o
$@
$^
$(CFLAGS)
$(LDFLAGS)
@
mv
$@
$(OUT_DIR)
run
:
all
@
${OUT_DIR}
/test_common
--tap
=
${OUT_DIR}
/test_common.tap
@
${OUT_DIR}
/test_modio_i2c
--tap
=
${OUT_DIR}
/test_modio_i2c.tap
@
${OUT_DIR}
/test_keep_alive
--tap
=
${OUT_DIR}
/test_keep_alive.tap
@
${OUT_DIR}
/test_keep_alive_publisher
--tap
=
${OUT_DIR}
/test_keep_alive_publisher.tap
@
${OUT_DIR}
/test_keep_alive_subscriber
--tap
=
${OUT_DIR}
/test_keep_alive_subscriber.tap
clean
:
@
rm
$(OUT_DIR)
test_common 2>/dev/null
||
true
...
...
@@ -41,6 +47,8 @@ clean:
@
rm
$(OUT_DIR)
test_keep_alive.tap 2>/dev/null
||
true
@
rm
$(OUT_DIR)
test_keep_alive_publisher 2>/dev/null
||
true
@
rm
$(OUT_DIR)
test_keep_alive_publisher.tap 2>/dev/null
||
true
@
rm
$(OUT_DIR)
test_keep_alive_subscriber 2>/dev/null
||
true
@
rm
$(OUT_DIR)
test_keep_alive_subscriber.tap 2>/dev/null
||
true
@
rm
*
.o 2>/dev/null
||
true
...
...
tests/unit_test/test_keep_alive_publisher.c
View file @
6bdbe53d
/* ================ Includes ===================== */
#define DOING_UNIT_TESTS
#include <criterion/criterion.h>
#include <linux/i2c-dev.h>
#include <open62541/plugin/log_stdout.h>
#include <open62541/server.h>
#include "../../coupler/opc-ua-server/server.c"
// #include "../../coupler/opc-ua-server/server.c"
// #include "../../coupler/opc-ua-server/common.h"
// #include "../../coupler/opc-ua-server/mod_io_i2c.h"
// #include "../../coupler/opc-ua-server/keep_alive_publisher.h"
/* ================ Function Tests =============== */
// ############# check heart beats of the server ##############
// Test(keepalivepublisher, callbackTicHeartBeat) {
// int result = 1;
// callbackTicHeartBeat();
Test
(
keepalivepublisher
,
callbackTicHeartBeat
)
{
int
result
=
1
;
// cr_expect_geq(HEART_BEATS, result);
// }
server
=
UA_Server_new
();
callbackTicHeartBeat
();
UA_Server_delete
(
server
);
cr_expect_geq
(
HEART_BEATS
,
result
);
}
tests/unit_test/test_keep_alive_subscriber.c
0 → 100644
View file @
6bdbe53d
/* ================ Includes ===================== */
#define DOING_UNIT_TESTS
#include <criterion/criterion.h>
#include "../../coupler/opc-ua-server/server.c"
/* ================ Function Tests =============== */
// ############# check heart beats of the server ##############
Test
(
keepalivepublisher
,
callbackTicHeartBeat
)
{
int
result
=
0
;
server
=
UA_Server_new
();
callbackCheckHeartBeat
();
UA_Server_delete
(
server
);
cr_expect_geq
(
HEART_BEAT_ID_LIST
[
0
],
result
);
}
\ No newline at end of file
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