aboutsummaryrefslogtreecommitdiff
path: root/pw_assert_basic
AgeCommit message (Collapse)Author
2020-11-04CMake: Revamp CMake buildWyatt Hepler
- Define CMake cache variables (similar to gn args) for facade backends. - Create simple initial toolchain files for GCC and Clang. - Misc updates to pigweed.cmake and pw_build/CMakeLists.txt. - Add or expand various CMakeLists.txt files. - Watch CMake files in watch.py to support using CMake in pw watch. Change-Id: I490d157485d02811a11f6a3589a0508ea1851f58 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22840 Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com> Reviewed-by: Keir Mierle <keir@google.com>
2020-10-16pw_build: add "-Wundef" to strict_warningsEwout van Bekkum
Adds "-Wundef" to "strict_warnings" to catch use of accidentally undefined macros which otherwise implicitly default to 0. Updates macros across Pigweed to make it compile. Drops support for PW_TEST_DONT_DEFINE_* in addition to GTEST_DONT_DEFINE_*, instead only GTEST_DONT_DEFINE_* is used. Change-Id: Id89f85f7cb8a52c1619bc0f7262349310203067b Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21463 Reviewed-by: Alexei Frolov <frolv@google.com> Reviewed-by: Wyatt Hepler <hepler@google.com> Commit-Queue: Ewout van Bekkum <ewout@google.com>
2020-10-15BUILD.gn files: Improve import formattingWyatt Hepler
The "# gn-format disable" comments are no longer necessary. Delete these comments and reformat with a Vim macro and gn format. Change-Id: Ia62c40ad73eef91187d0d443d6e3b0fa723e5aa9 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21380 Reviewed-by: Armando Montanez <amontanez@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-10-01docs: Make labels consistent; remove boilerplateWyatt Hepler
- Update labels so they use consistent naming. Instead of the copy-and-pasted `chapter` prefix, name labels with a prefix consistent with what they point to: - "module-" for module - "target-" for targets - "docs-" for general documentation - Remove the unnecessary highlight and default-domain directives. Neither is necessary since the Pigweed docs always specify the language in code snippets and other directives. Change-Id: I55c34e9ec919f6f4670e5d3d008e0edf5fecf05b Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19328 Commit-Queue: Wyatt Hepler <hepler@google.com> Reviewed-by: Keir Mierle <keir@google.com>
2020-09-29pw_assert: Only extern "C" in C++Wyatt Hepler
- Use PW_EXTERN_C_* for the pw_assert_HandleFailure function. - Specify a void parameter since this is a C function. - Add C tests for PW_ASSERT. Change-Id: Ica24e8f4e358381e95b3c95daab8dfc3a8669d43 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19200 Reviewed-by: Ewout van Bekkum <ewout@google.com> Reviewed-by: Keir Mierle <keir@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-09-25pw_assert: Add new "light" PW_ASSERT macrosKeir Mierle
This introduces two new macros: PW_ASSERT() and PW_DASSERT(). These exist to offer a lightweight assert that is safe to use in headers and is safe for constexpr. Most of the time, these macros should not be used, and instead the PW_CHECK() and PW_DCHECK() variants used instead. Other changes: - Renames PW_ASSERT_ENABLE_DCHECK to PW_ASSERT_ENABLE_DEBUG, to reflect that the setting applies to both PW_CHECK and PW_ASSERT. - Updates Roadamp & Status documentation sections Testing: Since currently it is not possible to test the PW_ASSERT macros due to needing to swap the backend, this is manually tested by flipping the #if in pw_assert/light_test.cc to 1, and verifying that it crashes as expected. Change-Id: I6d2c68f772da4280e61a52576bfb6ab60e280bdf Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/17462 Reviewed-by: Wyatt Hepler <hepler@google.com> Commit-Queue: Keir Mierle <keir@google.com>
2020-08-08GN build: No longer add public to sourcesWyatt Hepler
Adding public to sources is unnecessary. Clean up the remaining places where this is done. Change-Id: I63f1df64054b319d0a3297f62227756a1e3847ed Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/15665 Reviewed-by: Alexei Frolov <frolv@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-07-17pw_assert: adds float near and float exactEwout van Bekkum
- Renames PW_{D,}CHECK_FLOAT_* macros to PW_{D,}CHECK_FLOAT_EXACT_* to make it really obvious that it ignores floating point precision limits and ergo accumulated error which may cause accidental Asserts if the developer was not aware of this. - Adds PW_{D,}CHECK_FLOAT_NEAR to provide an Assert that allows the developer to take float precision limits into account. - Updates some stale comments and TODOs. Change-Id: Id39921775db6386bc48dc8a9fbc7afd9937addfb Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/14041 Commit-Queue: Ewout van Bekkum <ewout@google.com> Reviewed-by: Keir Mierle <keir@google.com>
2020-06-16Update docsArmando Montanez
First pass at docs to bring them up to date with The Great GN Refactor. More to follow. Change-Id: I02dc977fcdc7bf3efa8fc9080282dee9b1455cdd
2020-06-16Remove legacy_target.gniArmando Montanez
Transition to args is done, so this import is no longer needed. Change-Id: Id42e06ec9fcc16eace2cc7ef51a5dacaf012147a
2020-06-16Define Linux clang target as toolchainAlexei Frolov
This change configures the Linux clang -Og target as a toolchain with args. To support this, all Pigweed variables from pw_vars_default are made into build args, defined within their respective modules. The Linux clang target/toolchain is the only one that currently works. Pigweed's other targets will be ported in later changes. Change-Id: I051e29fde7577e41a3184c37031a4e04936404e1
2020-06-16Don't declare pigweed variables as globalsArmando Montanez
Require targets to explicitly import pigweed variable definitions. This moves out some necessary logic from the BUILDCONFIG.gn file. Change-Id: If9c9fe5a680cc9d897a0e8a55889873be618ed84
2020-06-16pw_build: Switch to pw_* target typesAlexei Frolov
This change replaces the implicit overrides of the default GN target types in BUILDCONFIG.gn with explicit pw_* versions. This is done to allow Pigweed to build within larger GN projects without modifying their BUILDCONFIG files. Change-Id: I1d1e41d5e9bde8fe076f7031f3c2b98b9630ff70
2020-06-05pw_assert: PW_CHECK_OK() macro for StatusKeir Mierle
This adds PW_CHECK_OK() for both C and C++ to assert that a Status object or enum is OK. Change-Id: I85e963bffc39510769feeb93e0b331f044557e7e
2020-06-03pw_assert: Add design discussion to docsKeir Mierle
This enhances the assert documentation with information about tradeoffs considered while designing the module. Additionally, provides some guidance to be more explicit that PW_CHECK(a < b) shouldn't be used, and instead PW_CHECK_INT_LT(a, b) should be used. Change-Id: I421700bfa85cb34c874c999245c201cb3337ebb4
2020-04-16pw_assert_basic: abort() on assert failureKeir Mierle
This makes pw_assert_basic trigger C's standard abort() function by default, unless PW_ASSERT_BASIC_ABORT is defined as 0. Below is an example session in pw watch with the abort functionality: ▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄ ▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌ ▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌ ▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌ ▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀ Watching for changes. Ctrl-C to exit; enter to rebuild 20200415 21:17:32 INF Change detected: None 20200415 21:17:32 INF Starting build with 1 directories 20200415 21:17:32 INF [1/1] Starting build: out/host ninja: Entering directory `out/host' [1/5] ACTION //pw_assert:assert_backend_compile_test_run(//pw_toolchain:host_clang_og) FAILED: gen/pw_assert/assert_backend_compile_test_run.pw_pystamp python ../../pw_build/py/python_runner.py --gn-root ../../ --out-dir //out/host --touch //out/host/gen/pw_assert/assert_backend_compile_test_run.pw_pystamp --capture-output -- //pw_unit_test/py/pw_unit_test/test_runner.py --runner //targets/host/run_test --test //out/host/obj/pw_assert:assert_backend_compile_test INF Test 1/1: [ RUN] assert_backend_compile_test ERR /Users/keir/wrk/pigweed/targets/host/run_test exited with status 134 OUT [15726] INF [==========] Running all tests. INF [ RUN ] Crash.WithAndWithoutMessageArguments INF [ OK ] Crash.WithAndWithoutMessageArguments INF [ RUN ] Check.NoMessage INF [ OK ] Check.NoMessage INF [ RUN ] Check.WithMessageAndArgs INF [ OK ] Check.WithMessageAndArgs INF [ RUN ] Check.IntComparison ▄████▄ ██▀███ ▄▄▄ ██████ ██░ ██ ▒██▀ ▀█ ▓██ ▒ ██▒ ▒████▄ ▒██ ▒ ▓██░ ██▒ ▒▓█ 💥 ▄ ▓██ ░▄█ ▒ ▒██ ▀█▄ ░ ▓██▄ ▒██▀▀██░ ▒▓▓▄ ▄██▒ ▒██▀▀█▄ ░██▄▄▄▄██ ▒ ██▒ ░▓█ ░██ ▒ ▓███▀ ░ ░██▓ ▒██▒ ▓█ ▓██▒ ▒██████▒▒ ░▓█▒░██▓ ░ ░▒ ▒ ░ ░ ▒▓ ░▒▓░ ▒▒ ▓▒█░ ▒ ▒▓▒ ▒ ░ ▒ ░░▒░▒ ░ ▒ ░▒ ░ ▒░ ▒ ▒▒ ░ ░ ░▒ ░ ░ ▒ ░▒░ ░ ░ ░░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ Welp, that didn't go as planned. It seems we crashed. Terribly sorry! CRASH MESSAGE Check failed: x_int (=50) >= y_int (=66). Oh dear. In state: TEST CRASH FILE & LINE ../../pw_assert/assert_backend_compile_test.cc:92 CRASH FUNCTION PigweedTestBody /Users/keir/wrk/pigweed/targets/host/run_test: line 18: 15727 Abort trap: 6 "$@" INF Test 1/1: [FAIL] assert_backend_compile_test ninja: build stopped: subcommand failed. 20200415 21:17:32 ERR [1/1] Finished build: out/host (FAIL) 20200415 21:17:32 INF Finished; some builds failed .------------------------------------ | | FAIL out/host | '------------------------------------ ▄██████▒░▄▄▄ ██▓ ░██▓ ▓█▓ ░▒████▄ ▓██▒ ░▓██▒ ▒████▒ ░▒█▀ ▀█▄ ▒██▒ ▒██░ ░▓█▒ ░░██▄▄▄▄██ ░██░ ▒██░ ░▒█░ ▓█ ▓██▒░██░░ ████████▒ ▒█░ ▒▒ ▓▒█░░▓ ░ ▒░▓ ░ ░▒ ▒ ▒▒ ░ ▒ ░░ ░ ▒ ░ ░ ░ ░ ▒ ▒ ░ ░ ░ ░ ░ ░ ░ ░ Change-Id: Iaf69455c5f108b2d4d9ae1b8dc4cd6bb5902fbed
2020-04-07Many changes to support stricter depsRob Mohr
* Split pw_assert targets as in pwrev/9000. * Add many missing dependencies (mostly on //pw_unit_test) * Added visibility and licenses to pw_minimal_cpp_stdlib/BUILD * Used explicit template params in pw_result/result_test.cc * Added missing #include of pw_kvs/pw_kvs_private/macros.h Change-Id: I9bdc875b585e47792ca926f7c75cfe055b02fa48 Bug: 101
2020-03-03pw_assert: Expand documentation coverageKeir Mierle
Change-Id: Ic3f57f30286ca96fb6d0bc303de39c60322ea663
2020-03-03Rename pw_dumb_io to pw_sys_ioArmando Montanez
Rename pw_dumb_io facade and backends to use the more deliberate name pw_sys_io moving forward. Change-Id: I968480715967ab8de491856afa1b7692b973ed7e
2020-02-28Roll GN to 239533dRob Mohr
This caused gn format to flag many things which were also fixed. Change-Id: Ie1d9081a1b08047bec52c60f54d2a94366be1ba6
2020-02-13pw_assert: Add basic Bazel supportKeir Mierle
Change-Id: Ic46c20bf80df111950ea0b2853f363cf0e00a9d2
2020-02-13pw_assert: Add pw_assert_basic CMake buildKeir Mierle
Change-Id: I5dfda5ccf3077ff799bdf7761250ba9eb00366dd
2020-02-07pw_assert: Initial assert moduleKeir Mierle
This starts the assert and assert_basic modules, which are the beginning of our assert foundation. Much more is needed; in particular the "tests" don't really do much other than check for compilation. Screenshot ========== ▄████▄ ██▀███ ▄▄▄ ██████ ██░ ██ ▒██▀ ▀█ ▓██ ▒ ██▒ ▒████▄ ▒██ ▒ ▓██░ ██▒ ▒▓█ 💥 ▄ ▓██ ░▄█ ▒ ▒██ ▀█▄ ░ ▓██▄ ▒██▀▀██░ ▒▓▓▄ ▄██▒ ▒██▀▀█▄ ░██▄▄▄▄██ ▒ ██▒ ░▓█ ░██ ▒ ▓███▀ ░ ░██▓ ▒██▒ ▓█ ▓██▒ ▒██████▒▒ ░▓█▒░██▓ ░ ░▒ ▒ ░ ░ ▒▓ ░▒▓░ ▒▒ ▓▒█░ ▒ ▒▓▒ ▒ ░ ▒ ░░▒░▒ ░ ▒ ░▒ ░ ▒░ ▒ ▒▒ ░ ░ ░▒ ░ ░ ▒ ░▒░ ░ ░ ░░ ░ ░ ▒ ░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ Welp, that didn't go as planned. It seems we crashed. Terribly sorry! CRASH MESSAGE Check failed: x (=50) > y (=51300): You SHOULD see this message CRASH FILE & LINE ../../pw_assert/assert_test.cc:46 CRASH FUNCTION PigweedTestBody ========== Change-Id: I9dbb460b3b33040d8009749f44b9fc174e2c8138