Skip to content

Commit a3e8216

Browse files
rename, refactors. Create lib helper methods that setup or teardown all cpputest for freertos provided modules (convenience method for tests).
1 parent 478d7bb commit a3e8216

16 files changed

+92
-41
lines changed

cpputest-for-freertos-lib/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ include_directories(include)
3636
set(FREERTOS_KERNEL_PATH ${CMS_FREERTOS_KERNEL_TOP_DIR} CACHE INTERNAL "")
3737

3838
add_library(cpputest-for-freertos-lib
39-
src/cpputest_freertos_task.cpp
40-
src/cpputest_freertos_queue.cpp
41-
src/cpputest_freertos_assert.cpp
42-
src/cpputest_freertos_timers.cpp
39+
src/cpputest_for_freertos_task.cpp
40+
src/cpputest_for_freertos_queue.cpp
41+
src/cpputest_for_freertos_assert.cpp
42+
src/cpputest_for_freertos_timers.cpp
4343
src/cpputest_main.cpp
44-
src/cpputest_freertos_semaphore.cpp
44+
src/cpputest_for_freertos_semaphore.cpp
45+
include/cpputest_for_freertos_lib.hpp
4546
)
4647

4748
add_subdirectory(tests)

cpputest-for-freertos-lib/include/cpputest_freertos_assert.hpp renamed to cpputest-for-freertos-lib/include/cpputest_for_freertos_assert.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
///***************************************************************************
2222
/// @endcond
2323

24-
#ifndef CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_ASSERT_HPP
25-
#define CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_ASSERT_HPP
24+
#ifndef CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_ASSERT_HPP
25+
#define CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_ASSERT_HPP
2626

2727
#include "FreeRTOS.h"
2828
#include "CppUTestExt/MockSupport.h"
@@ -45,4 +45,4 @@ namespace cms {
4545
} // namespace test
4646
} // namespace cms
4747

48-
#endif //CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_ASSERT_HPP
48+
#endif //CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_ASSERT_HPP
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/// @brief Top level init/teardown methods for CppUTest for FreeRTOS library.
2+
/// @ingroup
3+
/// @cond
4+
///***************************************************************************
5+
///
6+
/// Copyright (C) 2024 Matthew Eshleman. All rights reserved.
7+
///
8+
/// This program is open source software: you can redistribute it and/or
9+
/// modify it under the terms of the GNU General Public License as published
10+
/// by the Free Software Foundation, either version 3 of the License, or
11+
/// (at your option) any later version.
12+
///
13+
/// Alternatively, upon written permission from Matthew Eshleman, this program
14+
/// may be distributed and modified under the terms of a Commercial
15+
/// License. For further details, see the Contact Information below.
16+
///
17+
/// Contact Information:
18+
/// Matthew Eshleman
19+
/// https://covemountainsoftware.com
20+
21+
///***************************************************************************
22+
/// @endcond
23+
24+
#ifndef CPPUTEST_FOR_FREERTOS_LIB_HPP
25+
#define CPPUTEST_FOR_FREERTOS_LIB_HPP
26+
27+
#include "cpputest_for_freertos_assert.hpp"
28+
#include "cpputest_for_freertos_task.hpp"
29+
#include "cpputest_for_freertos_timers.hpp"
30+
31+
namespace cms {
32+
namespace test {
33+
/**
34+
* call this in your unit test setup() method to initialize
35+
* all available CppUTest for FreeRTOS modules.
36+
*/
37+
void LibInitAll() {
38+
TaskInit();
39+
AssertOutputEnable();
40+
TimersInit();
41+
}
42+
43+
/**
44+
* call this in your unit test teardown() method to correctly
45+
* destroy/teardown all available CppUTest for FreeRTOS modules.
46+
*/
47+
void LibTeardownAll() {
48+
TimersDestroy();
49+
TaskDestroy();
50+
}
51+
} // namespace test
52+
} //namespace cms
53+
54+
#endif //CPPUTEST_FOR_FREERTOS_LIB_HPP

cpputest-for-freertos-lib/include/cpputest_freertos_task.hpp renamed to cpputest-for-freertos-lib/include/cpputest_for_freertos_task.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
2222
///***************************************************************************
2323
/// @endcond
24-
#ifndef CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_TASK_HPP
25-
#define CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_TASK_HPP
24+
#ifndef CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_TASK_HPP
25+
#define CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_TASK_HPP
2626

2727
namespace cms {
2828
namespace test {
@@ -41,4 +41,4 @@ namespace cms {
4141
}
4242
}
4343

44-
#endif //CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_TASK_HPP
44+
#endif //CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_TASK_HPP

cpputest-for-freertos-lib/include/cpputest_freertos_timers.hpp renamed to cpputest-for-freertos-lib/include/cpputest_for_freertos_timers.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
#ifndef CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_TIMERS_HPP
3-
#define CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_TIMERS_HPP
2+
#ifndef CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_TIMERS_HPP
3+
#define CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_TIMERS_HPP
44

55
#include <chrono>
66

@@ -39,4 +39,4 @@ namespace test {
3939
} //namespace
4040
}//namespace
4141

42-
#endif //CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_TIMERS_HPP
42+
#endif //CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_TIMERS_HPP

cpputest-for-freertos-lib/src/cpputest_freertos_assert.cpp renamed to cpputest-for-freertos-lib/src/cpputest_for_freertos_assert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/// @endcond
2323

2424
#include <cstdio>
25-
#include "cpputest_freertos_assert.hpp"
25+
#include "cpputest_for_freertos_assert.hpp"
2626

2727
static bool m_printAssert = true;
2828

cpputest-for-freertos-lib/src/cpputest_freertos_fake_queue.hpp renamed to cpputest-for-freertos-lib/src/cpputest_for_freertos_fake_queue.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
#ifndef CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_FAKE_QUEUE_HPP
3-
#define CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_FAKE_QUEUE_HPP
2+
#ifndef CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_FAKE_QUEUE_HPP
3+
#define CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_FAKE_QUEUE_HPP
44

55
#include <deque>
66
#include <vector>
@@ -14,4 +14,4 @@ typedef struct QueueDefinition
1414
std::deque<std::vector<uint8_t>> queue = {};
1515
} FakeQueue;
1616

17-
#endif //CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FREERTOS_FAKE_QUEUE_HPP
17+
#endif //CPPUTEST_FOR_FREERTOS_LIB_CPPUTEST_FOR_FREERTOS_FAKE_QUEUE_HPP

cpputest-for-freertos-lib/src/cpputest_freertos_queue.cpp renamed to cpputest-for-freertos-lib/src/cpputest_for_freertos_queue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
///***************************************************************************
2525
/// @endcond
2626

27-
#include "cpputest_freertos_fake_queue.hpp"
27+
#include "cpputest_for_freertos_fake_queue.hpp"
2828
#include <cstring>
2929
#include "FreeRTOS.h"
3030
#include "queue.h"

cpputest-for-freertos-lib/src/cpputest_freertos_semaphore.cpp renamed to cpputest-for-freertos-lib/src/cpputest_for_freertos_semaphore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "cpputest_freertos_fake_queue.hpp"
1+
#include "cpputest_for_freertos_fake_queue.hpp"
22
#include <cstring>
33
#include "queue.h"
44
#include "semphr.h"

cpputest-for-freertos-lib/src/cpputest_freertos_task.cpp renamed to cpputest-for-freertos-lib/src/cpputest_for_freertos_task.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/// @endcond
2929
#include "FreeRTOS.h"
3030
#include "task.h"
31-
#include "cpputest_freertos_timers.hpp"
31+
#include "cpputest_for_freertos_timers.hpp"
3232

3333
namespace cms {
3434
namespace test {

0 commit comments

Comments
 (0)