Skip to content

Conversation

@philj404
Copy link
Contributor

I decided to create a pull request for my regression test of timer ID collisions, cancel() etc.

... and, I think I discovered a regression.

Now that timer.cancel(anId) returns a bool, AND timers no longer use a counter to randomize Task values, timer.cancel() will always find a Task to cancel, even if it is an empty task.

So... timer.cancel(anId) always returns true... even if anId is cancelled twice in a row.

- name: test platforms
#run: python3 ci/build_platform.py main_platforms
run: python3 ci/build_platform.py main_platforms esp32 esp8266
run: python3 ci/build_platform.py main_platforms
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main_platforms now support/check esp32 and esp8266.

{
struct task * const t = static_cast<struct task * const>(task);

if (t) {
Copy link
Contributor Author

@philj404 philj404 Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanitize inputs: t is never 0 now, and check t is in tasks[] bounds

@philj404
Copy link
Contributor Author

I was concerned that this test would take a lot of time. It is not as bad as I thought.

  • I shortened test time a bit by assuming that creating only 65536+ tasks will be enough to catch hash collisions (enough for processors with a 16-bit size_t). So Arduino Nano takes about 9 seconds to run instead of 30 seconds.
  • Running the test on github only takes about 30 milliseconds (!), not 9 seconds.

@philj404 philj404 marked this pull request as ready for review February 12, 2023 23:49
Timer<0x2, CLOCK::millis, Task *> timer;

assertEqual(timer.size(), 0UL);
assertEqual((unsigned long) timer.size(), 0UL);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run my test on an Arduino Nano. I got an error because size_t is NOT unsigned long. This cast should make the test work on all platforms.

@contrem
Copy link
Owner

contrem commented Feb 25, 2023

Looks good - can we consolidate the commits into fewer, more concise chunks?

@philj404
Copy link
Contributor Author

philj404 commented Mar 6, 2023

Looks good - can we consolidate the commits into fewer, more concise chunks?

I will see what I can do. Part of the reason for the smaller commits is that I usually write code using a Windows computer, so it is more difficult to test how the EpoxyDuino platform will behave without trying it out with the GitHub Action -- I had to use a commit to test remotely.

BUT I can squash these changes to another branch before setting up a pull request for you to review.

philj404 added 4 commits March 7, 2023 14:14
see if redundant task IDs allocated
see if NULL task ID created
see if a double cancel() kills another task

makefile rule for timerMultiCancelTest

EpoxyDuino doesn't support serial print HEX.
cancel() returns success only if it removed a task

check cancel with stale pointer fails

cancelling a removed task should fail

add range check for cancel() arg
@philj404 philj404 force-pushed the pj/taskCollisionTest branch from 63c4d30 to a4c075b Compare March 7, 2023 22:17
@philj404
Copy link
Contributor Author

philj404 commented Mar 7, 2023

I consolidated the PR into 4 commits total (rebased to 3 commits, plus a new commit for your parenthesis suggestion).

This is the first time I have used git rebase -i or git push --force-with-lease. Let me know if there is a problem.

@contrem contrem merged commit a4c075b into contrem:master Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants