Skip to content

Commit

Permalink
Add a buildconfig header for GoogleTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Alami-Amine committed Oct 31, 2024
1 parent 83b60fd commit cd889c2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions build/chip/tests.gni
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ declare_args() {
declare_args() {
# Enable building tests.
chip_build_tests = current_os != "freertos"

# building unit tests using GoogleTest framework, this should only be enabled through build_examples.py, see PR #36268
chip_build_tests_googletest = false
}

declare_args() {
Expand Down
2 changes: 1 addition & 1 deletion examples/common/QRCode/repo
Submodule repo updated 58 files
+131 −25 Readme.markdown
+1 −1 c/Makefile
+0 −70 c/Readme.markdown
+0 −24 c/qrcodegen-demo.c
+32 −59 c/qrcodegen-test.c
+118 −0 c/qrcodegen-worker.c
+96 −103 c/qrcodegen.c
+53 −127 c/qrcodegen.h
+3 −3 cpp/Makefile
+87 −54 cpp/QrCode.cpp
+24 −17 cpp/QrCode.hpp
+2 −35 cpp/QrCodeGeneratorDemo.cpp
+101 −0 cpp/QrCodeGeneratorWorker.cpp
+0 −61 cpp/Readme.markdown
+0 −65 java-fast/Readme.markdown
+0 −134 java-fast/io/nayuki/fastqrcodegen/BitBuffer.java
+0 −57 java-fast/io/nayuki/fastqrcodegen/DataTooLongException.java
+0 −95 java-fast/io/nayuki/fastqrcodegen/Memoizer.java
+0 −595 java-fast/io/nayuki/fastqrcodegen/QrCode.java
+0 −255 java-fast/io/nayuki/fastqrcodegen/QrCodeGeneratorDemo.java
+0 −338 java-fast/io/nayuki/fastqrcodegen/QrSegment.java
+0 −424 java-fast/io/nayuki/fastqrcodegen/QrSegmentAdvanced.java
+0 −269 java-fast/io/nayuki/fastqrcodegen/QrTemplate.java
+0 −106 java-fast/io/nayuki/fastqrcodegen/ReedSolomonGenerator.java
+0 −52 java-fast/io/nayuki/fastqrcodegen/package-info.java
+0 −65 java/Readme.markdown
+3 −35 java/pom.xml
+3 −3 java/src/main/java/io/nayuki/qrcodegen/DataTooLongException.java
+118 −48 java/src/main/java/io/nayuki/qrcodegen/QrCode.java
+22 −103 java/src/main/java/io/nayuki/qrcodegen/QrCodeGeneratorDemo.java
+100 −0 java/src/main/java/io/nayuki/qrcodegen/QrCodeGeneratorWorker.java
+23 −43 java/src/main/java/io/nayuki/qrcodegen/QrSegment.java
+9 −17 java/src/main/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java
+4 −5 java/src/main/java/io/nayuki/qrcodegen/package-info.java
+0 −29 java/src/main/java/module-info.java
+0 −53 python/Readme.markdown
+142 −0 python/qrcodegen-batch-test.py
+1 −21 python/qrcodegen-demo.py
+81 −0 python/qrcodegen-worker.py
+216 −160 python/qrcodegen.py
+15 −9 python/setup.py
+0 −12 rust-no-heap/Cargo.toml
+0 −71 rust-no-heap/Readme.markdown
+0 −267 rust-no-heap/examples/qrcodegen-demo.rs
+0 −1,477 rust-no-heap/src/lib.rs
+1 −2 rust/Cargo.toml
+24 −30 rust/Readme.markdown
+13 −36 rust/examples/qrcodegen-demo.rs
+113 −0 rust/examples/qrcodegen-worker.rs
+146 −129 rust/src/lib.rs
+0 −56 typescript-javascript/Readme.markdown
+5 −0 typescript-javascript/build.sh
+10 −26 typescript-javascript/qrcodegen-input-demo.html
+22 −62 typescript-javascript/qrcodegen-input-demo.ts
+1 −10 typescript-javascript/qrcodegen-output-demo.html
+18 −38 typescript-javascript/qrcodegen-output-demo.ts
+130 −0 typescript-javascript/qrcodegen-worker.ts
+140 −105 typescript-javascript/qrcodegen.ts
1 change: 1 addition & 0 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
self.extra_gn_options.append('import("//build_overrides/googletest.gni")')
self.extra_gn_options.append('pw_unit_test_BACKEND="$dir_pw_unit_test:googletest"')
self.extra_gn_options.append('dir_pw_third_party_googletest="$dir_googletest"')
self.extra_gn_options.append('chip_build_tests_googletest=true')

def GnBuildArgs(self):
if self.board == HostBoard.NATIVE:
Expand Down
1 change: 1 addition & 0 deletions src/lib/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ buildconfig_header("chip_buildconfig") {
"CHIP_CONFIG_TLV_VALIDATE_CHAR_STRING_ON_WRITE=${chip_tlv_validate_char_string_on_write}",
"CHIP_CONFIG_TLV_VALIDATE_CHAR_STRING_ON_READ=${chip_tlv_validate_char_string_on_read}",
"CHIP_CONFIG_COMMAND_SENDER_BUILTIN_SUPPORT_FOR_BATCHED_COMMANDS=${chip_enable_sending_batch_commands}",
"CHIP_CONFIG_TEST_GOOGLETEST=${chip_build_tests_googletest}",
]

visibility = [ ":chip_config_header" ]
Expand Down
11 changes: 11 additions & 0 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,17 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
#define CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS 5
#endif // CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS

/**
* @def CHIP_CONFIG_TEST_GOOGLETEST
*
* @brief
* If asserted (1), enable APIs that support unit tests built with the GoogleTest framework
*
*/
#ifndef CHIP_CONFIG_TEST_GOOGLETEST
#define CHIP_CONFIG_TEST_GOOGLETEST 0
#endif // CHIP_CONFIG_TEST_GOOGLETEST

/**
* @}
*/
5 changes: 2 additions & 3 deletions src/lib/core/StringBuilderAdapters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ StatusWithSize ToString<CHIP_ERROR>(const CHIP_ERROR & err, pw::span<char> buffe

} // namespace pw

#if CHIP_DEVICE_LAYER_TARGET_LINUX || CHIP_DEVICE_LAYER_TARGET_DARWIN || CHIP_DEVICE_LAYER_TARGET_TIZEN || \
CHIP_DEVICE_LAYER_TARGET_ANDROID
#if CHIP_CONFIG_TEST_GOOGLETEST
namespace chip {

void PrintTo(const CHIP_ERROR & err, std::ostream * os)
Expand All @@ -44,4 +43,4 @@ void PrintTo(const CHIP_ERROR & err, std::ostream * os)
*os << "CHIP_ERROR:<" << err.Format() << ">";
}
} // namespace chip
#endif
#endif //CHIP_CONFIG_TEST_GOOGLETEST
5 changes: 2 additions & 3 deletions src/lib/core/StringBuilderAdapters.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ template <>
StatusWithSize ToString<CHIP_ERROR>(const CHIP_ERROR & err, pw::span<char> buffer);

} // namespace pw
#if CHIP_DEVICE_LAYER_TARGET_LINUX || CHIP_DEVICE_LAYER_TARGET_DARWIN || CHIP_DEVICE_LAYER_TARGET_TIZEN || \
CHIP_DEVICE_LAYER_TARGET_ANDROID
#if CHIP_CONFIG_TEST_GOOGLETEST

namespace chip {

Expand All @@ -71,4 +70,4 @@ namespace chip {
/// This enhances the readability and diagnostic information in GoogleTest test logs.
void PrintTo(const CHIP_ERROR & err, std::ostream * os);
} // namespace chip
#endif
#endif //CHIP_CONFIG_TEST_GOOGLETEST

0 comments on commit cd889c2

Please sign in to comment.