From 48e121fc4950680209327a000bff33ca619ce595 Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Tue, 19 Oct 2021 14:51:13 +0200 Subject: [PATCH 01/21] add code without coverage to verify that a decrease in coverage fails the build. --- src/Not_Covered.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Not_Covered.cpp diff --git a/src/Not_Covered.cpp b/src/Not_Covered.cpp new file mode 100644 index 0000000..960e08f --- /dev/null +++ b/src/Not_Covered.cpp @@ -0,0 +1,23 @@ +// This file is deliberately not covered. The PR can be thrown away once we validate that coveralls rejects it and accepts it when the code is removed. + +unsigned int crc32b(unsigned char *message) { + int i, j; + unsigned int byte, crc, mask; + + i = 0; + crc = 0xFFFFFFFF; + while (message[i] != 0) { + byte = message[i]; // Get next byte. + crc = crc ^ byte; + for (j = 7; j >= 0; j--) { // Do eight times. + mask = -(crc & 1); + crc = (crc >> 1) ^ (0xEDB88320 & mask); + } + i = i + 1; + } + return ~crc; +} + +void f(void) { + +} \ No newline at end of file From 98a493bc25b8149bf92b5c999350133b67be5d2f Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Tue, 19 Oct 2021 14:59:06 +0200 Subject: [PATCH 02/21] include the uncovered code in the test build (I thought it was automatic.) --- test/run_all_tests.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/run_all_tests.sh b/test/run_all_tests.sh index d71829f..c3f76b4 100755 --- a/test/run_all_tests.sh +++ b/test/run_all_tests.sh @@ -5,6 +5,7 @@ all_tests_result=0 if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running Notecard Test Suite...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ + src/Not_Covered.cpp \ src/Notecard.cpp \ test/Notecard.test.cpp \ test/mock/mock-arduino.cpp \ @@ -32,6 +33,7 @@ fi if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running NoteI2c_Arduino Test Suite (no flags)...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ + src/Not_Covered.cpp \ src/NoteI2c_Arduino.cpp \ test/NoteI2c_Arduino.test.cpp \ test/mock/mock-arduino.cpp \ @@ -56,6 +58,7 @@ fi if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running NoteI2c_Arduino Test Suite (-DWIRE_HAS_END)...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ + src/Not_Covered.cpp \ src/NoteI2c_Arduino.cpp \ test/NoteI2c_Arduino.test.cpp \ test/mock/mock-arduino.cpp \ @@ -81,6 +84,7 @@ fi if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running NoteLog_Arduino Test Suite...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ + src/Not_Covered.cpp \ src/NoteLog_Arduino.cpp \ test/NoteLog_Arduino.test.cpp \ test/mock/mock-arduino.cpp \ @@ -104,6 +108,7 @@ fi if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running NoteSerial_Arduino Test Suite...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ + src/Not_Covered.cpp \ src/NoteSerial_Arduino.cpp \ test/NoteSerial_Arduino.test.cpp \ test/mock/mock-arduino.cpp \ From b46f799d11fc3aa87b093f77c82f7dd9507f680f Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Tue, 19 Oct 2021 15:17:43 +0200 Subject: [PATCH 03/21] ensure errors are propagated to the enviornment --- .github/actions/publish-coverage/report/report.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/publish-coverage/report/report.py b/.github/actions/publish-coverage/report/report.py index fd9af72..865b57e 100644 --- a/.github/actions/publish-coverage/report/report.py +++ b/.github/actions/publish-coverage/report/report.py @@ -95,7 +95,9 @@ def main(): del json_coverage_details['service_job_id'] # Post report to Coveralls.io - post_report(json_coverage_details, args) + if post_report(json_coverage_details, args)!=0: + sys.exit(-1) + if __name__ == '__main__': main() \ No newline at end of file From 7fadc2d8fd5a29f67c01dad0f26a9fa1d5a5439a Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Tue, 19 Oct 2021 15:30:51 +0200 Subject: [PATCH 04/21] capture github environment to set up the job ID correctly --- .github/actions/publish-coverage/report/report.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/publish-coverage/report/report.py b/.github/actions/publish-coverage/report/report.py index 865b57e..92fc3fc 100644 --- a/.github/actions/publish-coverage/report/report.py +++ b/.github/actions/publish-coverage/report/report.py @@ -90,6 +90,9 @@ def main(): json_coverage_details['service_job_id'] = os.environ.get('CF_BUILD_ID') if (json_coverage_details['service_job_id'] is not None): json_coverage_details['service_name'] = "codefresh" + elif os.environ.get('GITHUB_RUN_NUMBER') is not None: + json_coverage_details['service_job_id'] = os.environ.get('GITHUB_RUN_NUMBER') + json_coverage_details['service_name'] = "github" else: json_coverage_details['service_name'] = "" del json_coverage_details['service_job_id'] From 304c2a84b70a741c415cc3562ce1b271a435a34d Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Tue, 19 Oct 2021 15:42:52 +0200 Subject: [PATCH 05/21] use github run ID (to follow same path as the Coveralls Github Action) --- .github/actions/publish-coverage/report/report.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/actions/publish-coverage/report/report.py b/.github/actions/publish-coverage/report/report.py index 92fc3fc..4c26ff8 100644 --- a/.github/actions/publish-coverage/report/report.py +++ b/.github/actions/publish-coverage/report/report.py @@ -90,8 +90,9 @@ def main(): json_coverage_details['service_job_id'] = os.environ.get('CF_BUILD_ID') if (json_coverage_details['service_job_id'] is not None): json_coverage_details['service_name'] = "codefresh" - elif os.environ.get('GITHUB_RUN_NUMBER') is not None: - json_coverage_details['service_job_id'] = os.environ.get('GITHUB_RUN_NUMBER') + elif os.environ.get('GITHUB_RUN_ID') is not None: + print('Using GITHUB_RUN_ID') + json_coverage_details['service_job_id'] = os.environ.get('GITHUB_RUN_ID') json_coverage_details['service_name'] = "github" else: json_coverage_details['service_name'] = "" @@ -99,7 +100,7 @@ def main(): # Post report to Coveralls.io if post_report(json_coverage_details, args)!=0: - sys.exit(-1) + exit(-2) if __name__ == '__main__': From feb00fc28531ca880b8f541b26cbda3787aa8456 Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Tue, 19 Oct 2021 16:03:08 +0200 Subject: [PATCH 06/21] clutching at straws now... --- .github/workflows/note-arduino-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/note-arduino-ci.yml b/.github/workflows/note-arduino-ci.yml index ea8af3f..831765f 100644 --- a/.github/workflows/note-arduino-ci.yml +++ b/.github/workflows/note-arduino-ci.yml @@ -23,4 +23,6 @@ jobs: - name: Publish Test Coverage id: publish_coverage uses: ./.github/actions/publish-coverage + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} From fae155a735eeead8559dc7980e419eefa943af6b Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 20 Oct 2021 13:15:02 +0200 Subject: [PATCH 07/21] doesn't interfere with the service details since these may be set by gcovr. --- .github/actions/publish-coverage/report/report.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/actions/publish-coverage/report/report.py b/.github/actions/publish-coverage/report/report.py index 4c26ff8..0728b3e 100644 --- a/.github/actions/publish-coverage/report/report.py +++ b/.github/actions/publish-coverage/report/report.py @@ -86,18 +86,6 @@ def main(): print("Environment variable COVERALLS_REPO_TOKEN is required to upload coverage information") exit(-1) - # Consume Codefresh CI specific environment variables _(if available)_ - json_coverage_details['service_job_id'] = os.environ.get('CF_BUILD_ID') - if (json_coverage_details['service_job_id'] is not None): - json_coverage_details['service_name'] = "codefresh" - elif os.environ.get('GITHUB_RUN_ID') is not None: - print('Using GITHUB_RUN_ID') - json_coverage_details['service_job_id'] = os.environ.get('GITHUB_RUN_ID') - json_coverage_details['service_name'] = "github" - else: - json_coverage_details['service_name'] = "" - del json_coverage_details['service_job_id'] - # Post report to Coveralls.io if post_report(json_coverage_details, args)!=0: exit(-2) From 87a36c6ad7e2f81392f88bb1497aa5afd4ddaacd Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 20 Oct 2021 13:29:12 +0200 Subject: [PATCH 08/21] add more untested code --- src/Not_Covered.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Not_Covered.cpp b/src/Not_Covered.cpp index 960e08f..54c37aa 100644 --- a/src/Not_Covered.cpp +++ b/src/Not_Covered.cpp @@ -18,6 +18,26 @@ unsigned int crc32b(unsigned char *message) { return ~crc; } + +unsigned int crc32b_2(unsigned char *message) { + int i, j; + unsigned int byte, crc, mask; + + i = 0; + crc = 0xFFFFFFFF; + while (message[i] != 0) { + byte = message[i]; // Get next byte. + crc = crc ^ byte; + for (j = 7; j >= 0; j--) { // Do eight times. + mask = -(crc & 1); + crc = (crc >> 1) ^ (0xEDB88320 & mask); + } + i = i + 1; + } + return ~crc; +} + + void f(void) { - + } \ No newline at end of file From d62d87841569e99752fe383cc526ad310b9b29e2 Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 20 Oct 2021 14:46:34 +0200 Subject: [PATCH 09/21] add status to the response --- .github/actions/publish-coverage/report/report.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/publish-coverage/report/report.py b/.github/actions/publish-coverage/report/report.py index 0728b3e..96fe4ae 100644 --- a/.github/actions/publish-coverage/report/report.py +++ b/.github/actions/publish-coverage/report/report.py @@ -58,8 +58,10 @@ def post_report(coverage, args): """Post coverage report to coveralls.io.""" response = requests.post(URL, files={'json_file': json.dumps(coverage)}, verify=(not args.skip_ssl_verify)) + try: result = response.json() + result['status'] = response.status_code except ValueError: result = {'error': 'Failure to submit data. ' 'Response [%(status)s]: %(text)s' % { From a42e3863f990df21282283f60061c80e3bb04ede Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 20 Oct 2021 14:47:25 +0200 Subject: [PATCH 10/21] reduce coverage --- src/Not_Covered.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Not_Covered.cpp b/src/Not_Covered.cpp index 54c37aa..893f098 100644 --- a/src/Not_Covered.cpp +++ b/src/Not_Covered.cpp @@ -37,6 +37,23 @@ unsigned int crc32b_2(unsigned char *message) { return ~crc; } +unsigned int crc32b_3(unsigned char *message) { + int i, j; + unsigned int byte, crc, mask; + + i = 0; + crc = 0xFFFFFFFF; + while (message[i] != 0) { + byte = message[i]; // Get next byte. + crc = crc ^ byte; + for (j = 7; j >= 0; j--) { // Do eight times. + mask = -(crc & 1); + crc = (crc >> 1) ^ (0xEDB88320 & mask); + } + i = i + 1; + } + return ~crc; +} void f(void) { From 641903cf6174c9aabe7409df96a63d13d2df0e75 Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 12:34:35 -0700 Subject: [PATCH 11/21] try out gihub coveralls action --- .github/workflows/coverage.yml | 31 +++++++++++++++++++++++++++ .github/workflows/note-arduino-ci.yml | 5 ----- test/run_all_tests.sh | 16 ++++++-------- 3 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..2b4fa5a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,31 @@ +name: Build and Test + +on: + push: + branches: + - '*' + pull_request: + branches: + - '*' + + +jobs: + coverage: + name: coverage (ubuntu-18.04) + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y lcov g++ valgrind + - name: test + run: ./test/run_all_tests.sh + - name: run lcov + run: lcov --capture --directory . --output-file lcov.info + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: "./lcov.info" + diff --git a/.github/workflows/note-arduino-ci.yml b/.github/workflows/note-arduino-ci.yml index 831765f..fdcc3c0 100644 --- a/.github/workflows/note-arduino-ci.yml +++ b/.github/workflows/note-arduino-ci.yml @@ -20,9 +20,4 @@ jobs: uses: ./.github/actions/run-tests-in-container env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} - - name: Publish Test Coverage - id: publish_coverage - uses: ./.github/actions/publish-coverage - env: - COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} diff --git a/test/run_all_tests.sh b/test/run_all_tests.sh index c3f76b4..82fc0ba 100755 --- a/test/run_all_tests.sh +++ b/test/run_all_tests.sh @@ -134,20 +134,16 @@ if [ 0 -eq ${all_tests_result} ]; then echo && echo 'All tests have passed!' # Run coverage if available if [ $(which gcovr) ]; then - gcovr --print-summary --sort-percentage --exclude-throw-branches --delete \ + echo "GITHUB_ACTIONS $GITHUB_ACTIONS" + echo "GITHUB_WORKFLOW $GITHUB_WORKFLOW" + echo "GITHUB_RUN_ID $GITHUB_RUN_ID" + echo "GITHUB_SHA $GITHUB_SHA" + gcovr --print-summary --sort-percentage --exclude-throw-branches \ --object-directory . \ --root src \ --exclude .*_error.* \ --exclude test \ - --coveralls coverage.json \ - --txt \ - && rm ./a.out *.gcno - if [ ! -f "coverage.json" ]; then - echo "Coverage report not produced"; - all_tests_result=997 - fi - else - rm -f ./a.out *.gcda *.gcno + --txt fi else echo && echo 'TESTS FAILED!!!' \ From 2b6bfb515d7621dabcca2e321293e4ed2aa7de8f Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 12:38:26 -0700 Subject: [PATCH 12/21] increase coverage --- src/Not_Covered.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Not_Covered.cpp b/src/Not_Covered.cpp index 893f098..0128d31 100644 --- a/src/Not_Covered.cpp +++ b/src/Not_Covered.cpp @@ -1,5 +1,7 @@ // This file is deliberately not covered. The PR can be thrown away once we validate that coveralls rejects it and accepts it when the code is removed. +#if 0 + unsigned int crc32b(unsigned char *message) { int i, j; unsigned int byte, crc, mask; @@ -57,4 +59,6 @@ unsigned int crc32b_3(unsigned char *message) { void f(void) { -} \ No newline at end of file +} + +#endif \ No newline at end of file From 5bb873fe4f77aee3a59f43ce3813a508fb0271ac Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 13:46:07 -0700 Subject: [PATCH 13/21] remove test sources from coverage --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2b4fa5a..84723be 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -22,7 +22,7 @@ jobs: - name: test run: ./test/run_all_tests.sh - name: run lcov - run: lcov --capture --directory . --output-file lcov.info + run: lcov --capture --directory . --output-file lcov-all.info && lcov --remove lcov-all.info "*test*" "*mock*" -o lcov.info - name: Coveralls uses: coverallsapp/github-action@master with: From f53561f74786309e336f2da4938c9534ec74b4ea Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 13:55:37 -0700 Subject: [PATCH 14/21] remove test source coverage --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 84723be..8e7c76f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -22,7 +22,7 @@ jobs: - name: test run: ./test/run_all_tests.sh - name: run lcov - run: lcov --capture --directory . --output-file lcov-all.info && lcov --remove lcov-all.info "*test*" "*mock*" -o lcov.info + run: lcov --capture --directory . --output-file lcov-all.info && rm "*mock*.gcda" "*Mock*.gcda" "*test*.gcda" && lcov --remove lcov-all.info "*test*" "*mock*" -o lcov.info - name: Coveralls uses: coverallsapp/github-action@master with: From a6e5644db99f2984394f8464206d44c67f2afd73 Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 14:04:58 -0700 Subject: [PATCH 15/21] remove test sources --- .github/workflows/coverage.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 8e7c76f..d29ff20 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -21,8 +21,10 @@ jobs: run: sudo apt-get update && sudo apt-get install -y lcov g++ valgrind - name: test run: ./test/run_all_tests.sh + - name: remove test source coverage + run: rm *mock*.gc?? *Mock*.gc?? *test*.gc?? - name: run lcov - run: lcov --capture --directory . --output-file lcov-all.info && rm "*mock*.gcda" "*Mock*.gcda" "*test*.gcda" && lcov --remove lcov-all.info "*test*" "*mock*" -o lcov.info + run: lcov --capture --directory . --output-file lcov-all.info && lcov --remove lcov-all.info "*test*" "*mock*" -o lcov.info - name: Coveralls uses: coverallsapp/github-action@master with: From faf177db814d5a2d1c862b95c345f1056e1c709b Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 14:05:32 -0700 Subject: [PATCH 16/21] remove test sources --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d29ff20..608b2d8 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -24,7 +24,7 @@ jobs: - name: remove test source coverage run: rm *mock*.gc?? *Mock*.gc?? *test*.gc?? - name: run lcov - run: lcov --capture --directory . --output-file lcov-all.info && lcov --remove lcov-all.info "*test*" "*mock*" -o lcov.info + run: lcov --capture --directory . --output-file lcov.info - name: Coveralls uses: coverallsapp/github-action@master with: From 709b6d4ca9ea290c315200d983e87d932d8b988b Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 14:10:41 -0700 Subject: [PATCH 17/21] reduce coverage --- src/Not_Covered.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Not_Covered.cpp b/src/Not_Covered.cpp index 0128d31..4a0ad80 100644 --- a/src/Not_Covered.cpp +++ b/src/Not_Covered.cpp @@ -38,6 +38,7 @@ unsigned int crc32b_2(unsigned char *message) { } return ~crc; } +#endif unsigned int crc32b_3(unsigned char *message) { int i, j; @@ -61,4 +62,3 @@ void f(void) { } -#endif \ No newline at end of file From d1c6a467c9ba3412aec0ab5167e46b6aef08820c Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 14:13:28 -0700 Subject: [PATCH 18/21] reduce coverage --- src/Not_Covered.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Not_Covered.cpp b/src/Not_Covered.cpp index 4a0ad80..d1e349c 100644 --- a/src/Not_Covered.cpp +++ b/src/Not_Covered.cpp @@ -19,6 +19,7 @@ unsigned int crc32b(unsigned char *message) { } return ~crc; } +#endif unsigned int crc32b_2(unsigned char *message) { @@ -38,7 +39,6 @@ unsigned int crc32b_2(unsigned char *message) { } return ~crc; } -#endif unsigned int crc32b_3(unsigned char *message) { int i, j; From f8bbd804706beb81b9f4376a89e84a885b8b6c59 Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 14:22:17 -0700 Subject: [PATCH 19/21] coverage decrease. Want it to be below 82% to see if it fails against master. --- src/Not_Covered.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/src/Not_Covered.cpp b/src/Not_Covered.cpp index d1e349c..e337896 100644 --- a/src/Not_Covered.cpp +++ b/src/Not_Covered.cpp @@ -1,6 +1,79 @@ // This file is deliberately not covered. The PR can be thrown away once we validate that coveralls rejects it and accepts it when the code is removed. -#if 0 + +unsigned int crc32_4(unsigned char *message) { + int i, j; + unsigned int byte, crc, mask; + + i = 0; + crc = 0xFFFFFFFF; + while (message[i] != 0) { + byte = message[i]; // Get next byte. + crc = crc ^ byte; + for (j = 7; j >= 0; j--) { // Do eight times. + mask = -(crc & 1); + crc = (crc >> 1) ^ (0xEDB88320 & mask); + } + i = i + 1; + } + return ~crc; +} + +unsigned int crc32_3(unsigned char *message) { + int i, j; + unsigned int byte, crc, mask; + + i = 0; + crc = 0xFFFFFFFF; + while (message[i] != 0) { + byte = message[i]; // Get next byte. + crc = crc ^ byte; + for (j = 7; j >= 0; j--) { // Do eight times. + mask = -(crc & 1); + crc = (crc >> 1) ^ (0xEDB88320 & mask); + } + i = i + 1; + } + return ~crc; +} + + +unsigned int crc32_2(unsigned char *message) { + int i, j; + unsigned int byte, crc, mask; + + i = 0; + crc = 0xFFFFFFFF; + while (message[i] != 0) { + byte = message[i]; // Get next byte. + crc = crc ^ byte; + for (j = 7; j >= 0; j--) { // Do eight times. + mask = -(crc & 1); + crc = (crc >> 1) ^ (0xEDB88320 & mask); + } + i = i + 1; + } + return ~crc; +} + + +unsigned int crc32_1(unsigned char *message) { + int i, j; + unsigned int byte, crc, mask; + + i = 0; + crc = 0xFFFFFFFF; + while (message[i] != 0) { + byte = message[i]; // Get next byte. + crc = crc ^ byte; + for (j = 7; j >= 0; j--) { // Do eight times. + mask = -(crc & 1); + crc = (crc >> 1) ^ (0xEDB88320 & mask); + } + i = i + 1; + } + return ~crc; +} unsigned int crc32b(unsigned char *message) { int i, j; @@ -19,7 +92,6 @@ unsigned int crc32b(unsigned char *message) { } return ~crc; } -#endif unsigned int crc32b_2(unsigned char *message) { From 80da65d765eee39d1064b82c398116bb8ddea3f5 Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Wed, 27 Oct 2021 14:34:30 -0700 Subject: [PATCH 20/21] remove not covered code for testing this PR --- src/Not_Covered.cpp | 136 -------------------------------------------- 1 file changed, 136 deletions(-) delete mode 100644 src/Not_Covered.cpp diff --git a/src/Not_Covered.cpp b/src/Not_Covered.cpp deleted file mode 100644 index e337896..0000000 --- a/src/Not_Covered.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// This file is deliberately not covered. The PR can be thrown away once we validate that coveralls rejects it and accepts it when the code is removed. - - -unsigned int crc32_4(unsigned char *message) { - int i, j; - unsigned int byte, crc, mask; - - i = 0; - crc = 0xFFFFFFFF; - while (message[i] != 0) { - byte = message[i]; // Get next byte. - crc = crc ^ byte; - for (j = 7; j >= 0; j--) { // Do eight times. - mask = -(crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } - i = i + 1; - } - return ~crc; -} - -unsigned int crc32_3(unsigned char *message) { - int i, j; - unsigned int byte, crc, mask; - - i = 0; - crc = 0xFFFFFFFF; - while (message[i] != 0) { - byte = message[i]; // Get next byte. - crc = crc ^ byte; - for (j = 7; j >= 0; j--) { // Do eight times. - mask = -(crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } - i = i + 1; - } - return ~crc; -} - - -unsigned int crc32_2(unsigned char *message) { - int i, j; - unsigned int byte, crc, mask; - - i = 0; - crc = 0xFFFFFFFF; - while (message[i] != 0) { - byte = message[i]; // Get next byte. - crc = crc ^ byte; - for (j = 7; j >= 0; j--) { // Do eight times. - mask = -(crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } - i = i + 1; - } - return ~crc; -} - - -unsigned int crc32_1(unsigned char *message) { - int i, j; - unsigned int byte, crc, mask; - - i = 0; - crc = 0xFFFFFFFF; - while (message[i] != 0) { - byte = message[i]; // Get next byte. - crc = crc ^ byte; - for (j = 7; j >= 0; j--) { // Do eight times. - mask = -(crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } - i = i + 1; - } - return ~crc; -} - -unsigned int crc32b(unsigned char *message) { - int i, j; - unsigned int byte, crc, mask; - - i = 0; - crc = 0xFFFFFFFF; - while (message[i] != 0) { - byte = message[i]; // Get next byte. - crc = crc ^ byte; - for (j = 7; j >= 0; j--) { // Do eight times. - mask = -(crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } - i = i + 1; - } - return ~crc; -} - - -unsigned int crc32b_2(unsigned char *message) { - int i, j; - unsigned int byte, crc, mask; - - i = 0; - crc = 0xFFFFFFFF; - while (message[i] != 0) { - byte = message[i]; // Get next byte. - crc = crc ^ byte; - for (j = 7; j >= 0; j--) { // Do eight times. - mask = -(crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } - i = i + 1; - } - return ~crc; -} - -unsigned int crc32b_3(unsigned char *message) { - int i, j; - unsigned int byte, crc, mask; - - i = 0; - crc = 0xFFFFFFFF; - while (message[i] != 0) { - byte = message[i]; // Get next byte. - crc = crc ^ byte; - for (j = 7; j >= 0; j--) { // Do eight times. - mask = -(crc & 1); - crc = (crc >> 1) ^ (0xEDB88320 & mask); - } - i = i + 1; - } - return ~crc; -} - -void f(void) { - -} - From 5ceb71583240c0da70402f555097a7ec66285b42 Mon Sep 17 00:00:00 2001 From: Matthew McGowan Date: Thu, 28 Oct 2021 11:47:03 -0700 Subject: [PATCH 21/21] remove Not_Covered source --- test/run_all_tests.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/run_all_tests.sh b/test/run_all_tests.sh index 82fc0ba..52702be 100755 --- a/test/run_all_tests.sh +++ b/test/run_all_tests.sh @@ -5,7 +5,6 @@ all_tests_result=0 if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running Notecard Test Suite...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ - src/Not_Covered.cpp \ src/Notecard.cpp \ test/Notecard.test.cpp \ test/mock/mock-arduino.cpp \ @@ -33,7 +32,6 @@ fi if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running NoteI2c_Arduino Test Suite (no flags)...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ - src/Not_Covered.cpp \ src/NoteI2c_Arduino.cpp \ test/NoteI2c_Arduino.test.cpp \ test/mock/mock-arduino.cpp \ @@ -58,7 +56,6 @@ fi if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running NoteI2c_Arduino Test Suite (-DWIRE_HAS_END)...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ - src/Not_Covered.cpp \ src/NoteI2c_Arduino.cpp \ test/NoteI2c_Arduino.test.cpp \ test/mock/mock-arduino.cpp \ @@ -84,7 +81,6 @@ fi if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running NoteLog_Arduino Test Suite...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ - src/Not_Covered.cpp \ src/NoteLog_Arduino.cpp \ test/NoteLog_Arduino.test.cpp \ test/mock/mock-arduino.cpp \ @@ -108,7 +104,6 @@ fi if [ 0 -eq $all_tests_result ]; then echo && echo 'Compiling and running NoteSerial_Arduino Test Suite...' g++ -fprofile-arcs -ftest-coverage -Wall -Wextra -Werror -Wpedantic -std=c++11 -O0 -g \ - src/Not_Covered.cpp \ src/NoteSerial_Arduino.cpp \ test/NoteSerial_Arduino.test.cpp \ test/mock/mock-arduino.cpp \