Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
senf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wiback
senf
Commits
693303f4
Commit
693303f4
authored
15 years ago
by
tho
Browse files
Options
Downloads
Patches
Plain Diff
added some tests
parent
a053b599
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Socket/NetdeviceController.test.cc
+8
-3
8 additions, 3 deletions
Socket/NetdeviceController.test.cc
Utils/Console/Config.test.cc
+13
-3
13 additions, 3 deletions
Utils/Console/Config.test.cc
with
21 additions
and
6 deletions
Socket/NetdeviceController.test.cc
+
8
−
3
View file @
693303f4
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
// Custom includes
// Custom includes
#include
"NetdeviceController.hh"
#include
"NetdeviceController.hh"
#include
"Protocols/Raw/MACAddress.hh"
#include
"Protocols/Raw/MACAddress.hh"
#include
<net/if.h>
#include
"../Utils/auto_unit_test.hh"
#include
"../Utils/auto_unit_test.hh"
#include
<boost/test/test_tools.hpp>
#include
<boost/test/test_tools.hpp>
...
@@ -38,11 +39,13 @@
...
@@ -38,11 +39,13 @@
BOOST_AUTO_UNIT_TEST
(
NetdeviceController
)
{
BOOST_AUTO_UNIT_TEST
(
NetdeviceController
)
{
senf
::
NetdeviceController
ctrl
(
"lo"
);
std
::
string
ifname
(
"lo"
);
BOOST_CHECK_EQUAL
(
ctrl
.
interfaceName
(),
"lo"
);
senf
::
NetdeviceController
ctrl
(
ifname
);
BOOST_CHECK_EQUAL
(
ctrl
.
interfaceName
(),
ifname
);
int
index
=
ctrl
.
interfaceIndex
();
int
index
=
ctrl
.
interfaceIndex
();
BOOST_CHECK_EQUAL
(
index
,
senf
::
NetdeviceController
(
index
).
interfaceIndex
()
);
BOOST_CHECK_EQUAL
(
index
,
senf
::
NetdeviceController
(
index
).
interfaceIndex
()
);
BOOST_CHECK_EQUAL
(
index
,
if_nametoindex
(
ifname
.
c_str
())
);
BOOST_CHECK_THROW
(
senf
::
NetdeviceController
(
"invalid_interfacename"
),
senf
::
SystemException
);
BOOST_CHECK_THROW
(
senf
::
NetdeviceController
(
"invalid_interfacename"
),
senf
::
SystemException
);
...
@@ -51,6 +54,8 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) {
...
@@ -51,6 +54,8 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) {
bool
promisc
;
bool
promisc
;
SENF_CHECK_NO_THROW
(
promisc
=
ctrl
.
promisc
());
SENF_CHECK_NO_THROW
(
promisc
=
ctrl
.
promisc
());
BOOST_CHECK
(
ctrl
.
isUp
());
if
(
getuid
()
!=
0
)
{
if
(
getuid
()
!=
0
)
{
BOOST_WARN_MESSAGE
(
false
,
"Cannot run some tests of senf::NetdeviceController as non-root user"
);
BOOST_WARN_MESSAGE
(
false
,
"Cannot run some tests of senf::NetdeviceController as non-root user"
);
...
@@ -71,7 +76,7 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) {
...
@@ -71,7 +76,7 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) {
///////////////////////////////cc.e////////////////////////////////////////
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
#undef prefix_
// Local Variables:
// Local Variables:
// mode: c++
// mode: c++
// fill-column: 100
// fill-column: 100
...
...
This diff is collapsed.
Click to expand it.
Utils/Console/Config.test.cc
+
13
−
3
View file @
693303f4
...
@@ -69,10 +69,15 @@ namespace {
...
@@ -69,10 +69,15 @@ namespace {
BOOST_AUTO_UNIT_TEST
(
configBundle
)
BOOST_AUTO_UNIT_TEST
(
configBundle
)
{
{
senf
::
console
::
ScopedDirectory
<>
root
;
senf
::
console
::
ScopedDirectory
<>
root
;
senf
::
console
::
root
().
add
(
"root"
,
root
);
senf
::
console
::
root
().
add
(
"root"
,
root
);
root
.
mkdir
(
"dir1"
).
add
(
"fun1"
,
&
fun1
);
senf
::
console
::
ScopedDirectory
<>
chroot
;
root
.
add
(
"fun2"
,
&
fun2
);
senf
::
console
::
root
().
add
(
"chroot"
,
chroot
);
root
.
mkdir
(
"dir1"
).
add
(
"fun1"
,
&
fun1
);
root
.
add
(
"fun2"
,
&
fun2
);
chroot
.
mkdir
(
"dir1"
).
add
(
"fun1"
,
&
fun1
);
chroot
.
add
(
"fun2"
,
&
fun2
);
TempFile
cfg
(
"test.cfg"
);
TempFile
cfg
(
"test.cfg"
);
cfg
<<
"dir1/fun1 foo; fun2;"
<<
TempFile
::
close
;
cfg
<<
"dir1/fun1 foo; fun2;"
<<
TempFile
::
close
;
...
@@ -86,6 +91,11 @@ BOOST_AUTO_UNIT_TEST(configBundle)
...
@@ -86,6 +91,11 @@ BOOST_AUTO_UNIT_TEST(configBundle)
SENF_CHECK_NO_THROW
(
bundle
.
parse
()
);
SENF_CHECK_NO_THROW
(
bundle
.
parse
()
);
BOOST_CHECK_EQUAL
(
val1
,
"bar"
);
BOOST_CHECK_EQUAL
(
val1
,
"bar"
);
BOOST_CHECK_EQUAL
(
val2
,
true
);
BOOST_CHECK_EQUAL
(
val2
,
true
);
bundle
.
chroot
(
chroot
);
SENF_CHECK_NO_THROW
(
bundle
.
parse
()
);
BOOST_CHECK_EQUAL
(
val1
,
"bar"
);
BOOST_CHECK_EQUAL
(
val2
,
true
);
}
}
///////////////////////////////cc.e////////////////////////////////////////
///////////////////////////////cc.e////////////////////////////////////////
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment