Skip to content

Commit

Permalink
Convert support tests to auto test driver building (#3982)
Browse files Browse the repository at this point in the history
* Convert support tests to auto test driver building

* Restyle fixes

* Rename unit tests

* Allow persisted storage test only on mac and linux

* Restyle fixes

* Update TestUtils.h to UnitTestRegistration.h

* Move TestPool to auto test driver generation
  • Loading branch information
andy31415 authored Dec 7, 2020
1 parent c5099ed commit 5813d4a
Show file tree
Hide file tree
Showing 27 changed files with 43 additions and 481 deletions.
31 changes: 11 additions & 20 deletions src/lib/support/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,29 @@ import("${chip_root}/build/chip/chip_test_suite.gni")
chip_test_suite("tests") {
output_name = "libSupportTests"

sources = [
test_sources = [
"TestBufBound.cpp",
"TestBufferReader.cpp",
"TestCHIPArgParser.cpp",
"TestCHIPCounter.cpp",
"TestCHIPMem.cpp",
"TestErrorStr.cpp",
"TestPersistedCounter.cpp",
"TestPersistedStorageImplementation.cpp",
"TestPersistedStorageImplementation.h",
"TestPool.cpp",
"TestSafeInt.cpp",
"TestScopedBuffer.cpp",
"TestSerializableIntegerSet.cpp",
"TestSupport.h",
"TestTimeUtils.cpp",
]
sources = []

if (current_os == "linux" || current_os == "mac") {
# persisted counter unit test uses file-based persistent storage
test_sources += [ "TestPersistedCounter.cpp" ]
sources += [
"TestPersistedStorageImplementation.cpp",
"TestPersistedStorageImplementation.h",
]
}

cflags = [ "-Wconversion" ]

Expand All @@ -45,19 +51,4 @@ chip_test_suite("tests") {
"${chip_root}/src/platform",
"${nlunit_test_root}:nlunit-test",
]

tests = [
"TestBufBound",
"TestBufferReader",
"TestErrorStr",
"TestCHIPArgParser",
"TestTimeUtils",
"TestCHIPMem",
"TestCHIPCounter",
"TestPersistedCounter",
"TestPool",
"TestSafeInt",
"TestScopedBuffer",
"TestSerializableIntegerSet",
]
}
2 changes: 0 additions & 2 deletions src/lib/support/tests/TestBufBound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
*
*/

#include "TestSupport.h"

#include <support/BufBound.h>
#include <support/UnitTestRegistration.h>

Expand Down
31 changes: 0 additions & 31 deletions src/lib/support/tests/TestBufBoundDriver.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/lib/support/tests/TestBufferReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
*
*/

#include "TestSupport.h"

#include <support/BufferReader.h>
#include <support/UnitTestRegistration.h>
#include <type_traits>
Expand Down
31 changes: 0 additions & 31 deletions src/lib/support/tests/TestBufferReaderDriver.cpp

This file was deleted.

13 changes: 9 additions & 4 deletions src/lib/support/tests/TestCHIPArgParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,17 @@
* limitations under the License.
*/

#include "TestSupport.h"

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <core/CHIPCore.h>
#include <support/CHIPArgParser.hpp>
#include <support/CHIPMem.h>
#include <support/CHIPMemString.h>

#include <support/CHIPArgParser.hpp>
#include <support/ScopedBuffer.h>
#include <support/UnitTestRegistration.h>

#if CHIP_CONFIG_ENABLE_ARG_PARSER

Expand Down Expand Up @@ -761,6 +759,11 @@ static void HandleArgError(const char * msg, ...)

int TestCHIPArgParser(void)
{
if (chip::Platform::MemoryInit() != CHIP_NO_ERROR)
{
return EXIT_FAILURE;
}

SimpleParseTest_SingleLongOption();
SimpleParseTest_SingleShortOption();
SimpleParseTest_SingleLongOptionWithValue();
Expand Down Expand Up @@ -792,3 +795,5 @@ int TestCHIPArgParser(void)
return (EXIT_SUCCESS);
}
#endif // CHIP_CONFIG_ENABLE_ARG_PARSER

CHIP_REGISTER_TEST_SUITE(TestCHIPArgParser);
35 changes: 0 additions & 35 deletions src/lib/support/tests/TestCHIPArgParserDriver.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/support/tests/TestCHIPCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static int TestTeardown(void * inContext)
return (SUCCESS);
}

extern "C" int TestCHIPCounter(void)
int TestCHIPCounter(void)
{
// clang-format off
nlTestSuite theSuite = {
Expand Down
35 changes: 0 additions & 35 deletions src/lib/support/tests/TestCHIPCounterDriver.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/lib/support/tests/TestCHIPMem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*
*/

#include "TestSupport.h"

#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
Expand Down
30 changes: 0 additions & 30 deletions src/lib/support/tests/TestCHIPMemDriver.cpp

This file was deleted.

6 changes: 3 additions & 3 deletions src/lib/support/tests/TestErrorStr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "TestSupport.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <core/CHIPCore.h>

#include <support/ErrorStr.h>
#include <support/UnitTestRegistration.h>

using namespace chip;

Expand Down Expand Up @@ -175,3 +173,5 @@ int TestErrorStr(void)

return EXIT_SUCCESS;
}

CHIP_REGISTER_TEST_SUITE(TestErrorStr);
30 changes: 0 additions & 30 deletions src/lib/support/tests/TestErrorStrDriver.cpp

This file was deleted.

Loading

0 comments on commit 5813d4a

Please sign in to comment.