Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
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
Container Registry
Model registry
Operate
Environments
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
cm-projects
RIOT
Commits
d86c1418
You need to sign in or sign up before continuing.
Commit
d86c1418
authored
8 years ago
by
Kaspar Schleiser
Browse files
Options
Downloads
Patches
Plain Diff
core, tests: adapt to changed clist function names
parent
6d12a916
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
core/include/clist.h
+1
-1
1 addition, 1 deletion
core/include/clist.h
core/sched.c
+2
-2
2 additions, 2 deletions
core/sched.c
core/thread.c
+1
-1
1 addition, 1 deletion
core/thread.c
tests/unittests/tests-core/tests-core-clist.c
+188
-17
188 additions, 17 deletions
tests/unittests/tests-core/tests-core-clist.c
with
192 additions
and
21 deletions
core/include/clist.h
+
1
−
1
View file @
d86c1418
...
@@ -225,7 +225,7 @@ static inline clist_node_t *clist_rpop(clist_node_t *list)
...
@@ -225,7 +225,7 @@ static inline clist_node_t *clist_rpop(clist_node_t *list)
if
(
list
->
next
)
{
if
(
list
->
next
)
{
list_node_t
*
last
=
list
->
next
;
list_node_t
*
last
=
list
->
next
;
while
(
list
->
next
->
next
!=
last
)
{
while
(
list
->
next
->
next
!=
last
)
{
clist_
advance
(
list
);
clist_
lpoprpush
(
list
);
}
}
return
clist_lpop
(
list
);
return
clist_lpop
(
list
);
}
}
...
...
This diff is collapsed.
Click to expand it.
core/sched.c
+
2
−
2
View file @
d86c1418
...
@@ -133,7 +133,7 @@ void sched_set_status(thread_t *process, unsigned int status)
...
@@ -133,7 +133,7 @@ void sched_set_status(thread_t *process, unsigned int status)
if
(
!
(
process
->
status
>=
STATUS_ON_RUNQUEUE
))
{
if
(
!
(
process
->
status
>=
STATUS_ON_RUNQUEUE
))
{
DEBUG
(
"sched_set_status: adding thread %"
PRIkernel_pid
" to runqueue %"
PRIu16
".
\n
"
,
DEBUG
(
"sched_set_status: adding thread %"
PRIkernel_pid
" to runqueue %"
PRIu16
".
\n
"
,
process
->
pid
,
process
->
priority
);
process
->
pid
,
process
->
priority
);
clist_
insert
(
&
sched_runqueues
[
process
->
priority
],
&
(
process
->
rq_entry
));
clist_
rpush
(
&
sched_runqueues
[
process
->
priority
],
&
(
process
->
rq_entry
));
runqueue_bitcache
|=
1
<<
process
->
priority
;
runqueue_bitcache
|=
1
<<
process
->
priority
;
}
}
}
}
...
@@ -141,7 +141,7 @@ void sched_set_status(thread_t *process, unsigned int status)
...
@@ -141,7 +141,7 @@ void sched_set_status(thread_t *process, unsigned int status)
if
(
process
->
status
>=
STATUS_ON_RUNQUEUE
)
{
if
(
process
->
status
>=
STATUS_ON_RUNQUEUE
)
{
DEBUG
(
"sched_set_status: removing thread %"
PRIkernel_pid
" to runqueue %"
PRIu16
".
\n
"
,
DEBUG
(
"sched_set_status: removing thread %"
PRIkernel_pid
" to runqueue %"
PRIu16
".
\n
"
,
process
->
pid
,
process
->
priority
);
process
->
pid
,
process
->
priority
);
clist_
remove_head
(
&
sched_runqueues
[
process
->
priority
]);
clist_
lpop
(
&
sched_runqueues
[
process
->
priority
]);
if
(
!
sched_runqueues
[
process
->
priority
].
next
)
{
if
(
!
sched_runqueues
[
process
->
priority
].
next
)
{
runqueue_bitcache
&=
~
(
1
<<
process
->
priority
);
runqueue_bitcache
&=
~
(
1
<<
process
->
priority
);
...
...
This diff is collapsed.
Click to expand it.
core/thread.c
+
1
−
1
View file @
d86c1418
...
@@ -98,7 +98,7 @@ void thread_yield(void)
...
@@ -98,7 +98,7 @@ void thread_yield(void)
unsigned
old_state
=
irq_disable
();
unsigned
old_state
=
irq_disable
();
thread_t
*
me
=
(
thread_t
*
)
sched_active_thread
;
thread_t
*
me
=
(
thread_t
*
)
sched_active_thread
;
if
(
me
->
status
>=
STATUS_ON_RUNQUEUE
)
{
if
(
me
->
status
>=
STATUS_ON_RUNQUEUE
)
{
clist_
advance
(
&
sched_runqueues
[
me
->
priority
]);
clist_
lpoprpush
(
&
sched_runqueues
[
me
->
priority
]);
}
}
irq_restore
(
old_state
);
irq_restore
(
old_state
);
...
...
This diff is collapsed.
Click to expand it.
tests/unittests/tests-core/tests-core-clist.c
+
188
−
17
View file @
d86c1418
...
@@ -22,15 +22,15 @@ static list_node_t test_clist;
...
@@ -22,15 +22,15 @@ static list_node_t test_clist;
static
void
set_up
(
void
)
static
void
set_up
(
void
)
{
{
memset
(
tests_clist_buf
,
0
,
sizeof
(
tests_clist_buf
));
memset
(
tests_clist_buf
,
0
,
sizeof
(
tests_clist_buf
));
test_clist
.
next
=
NULL
;
}
}
static
void
test_clist_
add_one
(
void
)
static
void
test_clist_
rpush
(
void
)
{
{
list_node_t
*
elem
=
&
(
tests_clist_buf
[
0
]);
list_node_t
*
elem
=
&
(
tests_clist_buf
[
0
]);
list_node_t
*
list
=
&
test_clist
;
list_node_t
*
list
=
&
test_clist
;
list
->
next
=
NULL
;
clist_
insert
(
list
,
elem
);
clist_
rpush
(
list
,
elem
);
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT
(
list
->
next
->
next
==
list
->
next
);
TEST_ASSERT
(
list
->
next
->
next
==
list
->
next
);
...
@@ -39,29 +39,130 @@ static void test_clist_add_one(void)
...
@@ -39,29 +39,130 @@ static void test_clist_add_one(void)
static
void
test_clist_add_two
(
void
)
static
void
test_clist_add_two
(
void
)
{
{
list_node_t
*
list
=
&
test_clist
;
list_node_t
*
list
=
&
test_clist
;
list
->
next
=
NULL
;
list_node_t
*
elem
=
&
(
tests_clist_buf
[
1
]);
list_node_t
*
elem
=
&
(
tests_clist_buf
[
1
]);
test_clist_
add_one
();
test_clist_
rpush
();
clist_
insert
(
list
,
elem
);
clist_
rpush
(
list
,
elem
);
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT
(
list
->
next
==
elem
);
TEST_ASSERT
(
list
->
next
==
elem
);
TEST_ASSERT
(
list
->
next
->
next
->
next
==
list
->
next
);
TEST_ASSERT
(
list
->
next
->
next
->
next
==
list
->
next
);
}
}
static
void
test_clist_remove_head
(
void
)
static
void
test_clist_add_three
(
void
)
{
list_node_t
*
list
=
&
test_clist
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
clist_rpush
(
list
,
&
(
tests_clist_buf
[
i
]));
}
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT
(
list
->
next
==
&
(
tests_clist_buf
[
2
]));
TEST_ASSERT
(
list
->
next
->
next
==
&
(
tests_clist_buf
[
0
]));
TEST_ASSERT
(
list
->
next
->
next
->
next
==
&
(
tests_clist_buf
[
1
]));
TEST_ASSERT
(
list
->
next
->
next
->
next
->
next
==
&
(
tests_clist_buf
[
2
]));
}
static
void
test_clist_find
(
void
)
{
list_node_t
*
list
=
&
test_clist
;
test_clist_add_three
();
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
TEST_ASSERT
(
clist_find
(
list
,
&
(
tests_clist_buf
[
i
]))
==
&
(
tests_clist_buf
[
i
]));
}
TEST_ASSERT_NULL
(
clist_find
(
list
,
&
(
tests_clist_buf
[
3
])));
}
static
void
test_clist_find_before
(
void
)
{
list_node_t
*
list
=
&
test_clist
;
test_clist_add_three
();
TEST_ASSERT
(
clist_find_before
(
list
,
&
(
tests_clist_buf
[
0
]))
==
&
(
tests_clist_buf
[
2
]));
for
(
int
i
=
1
;
i
<
3
;
i
++
)
{
TEST_ASSERT
(
clist_find_before
(
list
,
&
(
tests_clist_buf
[
i
]))
==
&
(
tests_clist_buf
[
i
-
1
]));
}
TEST_ASSERT_NULL
(
clist_find_before
(
list
,
&
(
tests_clist_buf
[
3
])));
}
static
void
test_clist_remove
(
void
)
{
list_node_t
*
list
=
&
test_clist
;
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
set_up
();
test_clist_add_three
();
clist_remove
(
list
,
&
(
tests_clist_buf
[
i
]));
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
if
(
i
==
j
)
{
TEST_ASSERT_NULL
(
clist_find
(
list
,
&
(
tests_clist_buf
[
j
])));
}
else
{
TEST_ASSERT
(
clist_find
(
list
,
&
(
tests_clist_buf
[
j
]))
==
&
(
tests_clist_buf
[
j
]));
}
}
}
/* list now contains 0, 1 */
TEST_ASSERT
(
list
->
next
==
&
(
tests_clist_buf
[
1
]));
TEST_ASSERT
(
list
->
next
->
next
==
&
(
tests_clist_buf
[
0
]));
clist_remove
(
list
,
&
(
tests_clist_buf
[
1
]));
TEST_ASSERT
(
list
->
next
==
&
(
tests_clist_buf
[
0
]));
TEST_ASSERT
(
list
->
next
->
next
==
&
(
tests_clist_buf
[
0
]));
clist_remove
(
list
,
&
(
tests_clist_buf
[
0
]));
TEST_ASSERT_NULL
(
list
->
next
);
}
static
void
test_clist_lpop
(
void
)
{
list_node_t
*
list
=
&
test_clist
;
test_clist_add_three
();
TEST_ASSERT
(
clist_lpop
(
list
)
==
&
tests_clist_buf
[
0
]);
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT
(
clist_lpop
(
list
)
==
&
tests_clist_buf
[
1
]);
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT
(
clist_lpop
(
list
)
==
&
tests_clist_buf
[
2
]);
TEST_ASSERT_NULL
(
list
->
next
);
TEST_ASSERT_NULL
(
clist_lpop
(
list
));
}
static
void
test_clist_lpush
(
void
)
{
{
list_node_t
*
list
=
&
test_clist
;
list_node_t
*
list
=
&
test_clist
;
test_clist_add_two
();
test_clist_add_two
();
clist_lpush
(
list
,
&
tests_clist_buf
[
2
]);
clist_remove_head
(
list
);
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT
(
list
->
next
->
next
==
&
tests_clist_buf
[
2
]);
}
static
void
test_clist_rpop
(
void
)
{
list_node_t
*
list
=
&
test_clist
;
test_clist_add_two
();
clist_rpop
(
list
);
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT_NOT_NULL
(
list
->
next
);
TEST_ASSERT
(
list
->
next
->
next
==
&
tests_clist_buf
[
1
]);
TEST_ASSERT
(
list
->
next
->
next
==
&
tests_clist_buf
[
0
]);
}
}
static
void
test_clist_remove_two
(
void
)
static
void
test_clist_remove_two
(
void
)
...
@@ -70,36 +171,106 @@ static void test_clist_remove_two(void)
...
@@ -70,36 +171,106 @@ static void test_clist_remove_two(void)
test_clist_add_two
();
test_clist_add_two
();
clist_
remove_head
(
list
);
clist_
lpop
(
list
);
clist_
remove_head
(
list
);
clist_
lpop
(
list
);
TEST_ASSERT_NULL
(
list
->
next
);
TEST_ASSERT_NULL
(
list
->
next
);
}
}
static
void
test_clist_
advance
(
void
)
static
void
test_clist_
lpoprpush
(
void
)
{
{
list_node_t
*
list
=
&
test_clist
;
list_node_t
*
list
=
&
test_clist
;
list
->
next
=
NULL
;
list
->
next
=
NULL
;
test_clist_add_two
();
test_clist_add_two
();
clist_
advance
(
list
);
clist_
lpoprpush
(
list
);
TEST_ASSERT
(
list
->
next
->
next
==
&
tests_clist_buf
[
1
]);
TEST_ASSERT
(
list
->
next
->
next
==
&
tests_clist_buf
[
1
]);
clist_
advance
(
list
);
clist_
lpoprpush
(
list
);
TEST_ASSERT
(
list
->
next
->
next
==
&
tests_clist_buf
[
0
]);
TEST_ASSERT
(
list
->
next
->
next
==
&
tests_clist_buf
[
0
]);
}
}
static
int
_foreach_called
;
static
int
_foreach_visited
[
TEST_CLIST_LEN
];
static
int
_foreach_abort_after
=
TEST_CLIST_LEN
/
2
;
static
void
_foreach_test
(
clist_node_t
*
node
)
{
TEST_ASSERT
(
node
==
&
tests_clist_buf
[
_foreach_called
]);
for
(
int
i
=
0
;
i
<
TEST_CLIST_LEN
;
i
++
)
{
if
(
node
==
&
tests_clist_buf
[
i
])
{
_foreach_visited
[
i
]
++
;
break
;
}
}
for
(
int
i
=
0
;
i
<
TEST_CLIST_LEN
;
i
++
)
{
if
(
i
<=
_foreach_called
)
{
TEST_ASSERT
(
_foreach_visited
[
i
]
==
1
);
}
else
{
TEST_ASSERT
(
_foreach_visited
[
i
]
==
0
);
}
}
_foreach_called
++
;
}
/* embunit test macros only work within void returning functions, so this
* trampoline function is needed */
static
int
_foreach_test_trampoline
(
clist_node_t
*
node
)
{
_foreach_test
(
node
);
if
(
_foreach_called
==
_foreach_abort_after
)
{
return
1
;
}
else
{
return
0
;
}
}
static
void
test_clist_foreach
(
void
)
{
list_node_t
*
list
=
&
test_clist
;
for
(
int
i
=
0
;
i
<
TEST_CLIST_LEN
;
i
++
)
{
clist_rpush
(
list
,
&
tests_clist_buf
[
i
]);
}
clist_foreach
(
list
,
_foreach_test_trampoline
);
TEST_ASSERT
(
_foreach_called
==
_foreach_abort_after
);
_foreach_called
=
0
;
for
(
int
i
=
0
;
i
<
TEST_CLIST_LEN
;
i
++
)
{
_foreach_visited
[
i
]
=
0
;
}
_foreach_abort_after
=
(
TEST_CLIST_LEN
+
1
);
clist_foreach
(
list
,
_foreach_test_trampoline
);
TEST_ASSERT
(
_foreach_called
==
TEST_CLIST_LEN
);
}
Test
*
tests_core_clist_tests
(
void
)
Test
*
tests_core_clist_tests
(
void
)
{
{
EMB_UNIT_TESTFIXTURES
(
fixtures
)
{
EMB_UNIT_TESTFIXTURES
(
fixtures
)
{
new_TestFixture
(
test_clist_
add_one
),
new_TestFixture
(
test_clist_
rpush
),
new_TestFixture
(
test_clist_add_two
),
new_TestFixture
(
test_clist_add_two
),
new_TestFixture
(
test_clist_remove_head
),
new_TestFixture
(
test_clist_lpop
),
new_TestFixture
(
test_clist_rpop
),
new_TestFixture
(
test_clist_lpush
),
new_TestFixture
(
test_clist_remove_two
),
new_TestFixture
(
test_clist_remove_two
),
new_TestFixture
(
test_clist_advance
),
new_TestFixture
(
test_clist_add_three
),
new_TestFixture
(
test_clist_find
),
new_TestFixture
(
test_clist_find_before
),
new_TestFixture
(
test_clist_remove
),
new_TestFixture
(
test_clist_lpoprpush
),
new_TestFixture
(
test_clist_foreach
),
};
};
EMB_UNIT_TESTCALLER
(
core_clist_tests
,
set_up
,
NULL
,
EMB_UNIT_TESTCALLER
(
core_clist_tests
,
set_up
,
NULL
,
...
...
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