Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: New test for xtimer_now with interrupts disabled #13025

Merged
merged 1 commit into from
May 5, 2020

Conversation

JulianHolzwarth
Copy link
Contributor

@JulianHolzwarth JulianHolzwarth commented Jan 3, 2020

Contribution description

This is a new test for xtimer. It tests if xtimer now (xtimer_now_usec) returns the correct value when interrupts are disabled.

This test is for: #9530

Testing procedure

BOARD=* make -C tests/xtimer_now_irq/ flash term replace * with board
If it returns an Error it is not correct.

Issues/PRs references

#9530

@MichelRottleuthner MichelRottleuthner self-requested a review January 3, 2020 17:02
@MichelRottleuthner MichelRottleuthner self-assigned this Jan 3, 2020
@MichelRottleuthner MichelRottleuthner added Area: tests Area: tests and testing framework Area: timers Area: timer subsystems Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Jan 3, 2020
@@ -0,0 +1,10 @@
BOARD_INSUFFICIENT_MEMORY := \
Copy link
Contributor

Choose a reason for hiding this comment

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

we should re-check this because the test is actually rather small

Copy link
Contributor

Choose a reason for hiding this comment

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

I checked the list and it seems to fit all these boards just fine - so why are they listed as insufficient memory?

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 will remove it.

Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

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

I think the test can be improved and a Python test script should be added to allow automatic testing. The suggestions below should help with the script.

tests/xtimer_now_irq/main.c Outdated Show resolved Hide resolved
tests/xtimer_now_irq/main.c Outdated Show resolved Hide resolved
tests/xtimer_now_irq/main.c Outdated Show resolved Hide resolved
@fjmolinas
Copy link
Contributor

ping @aabadie!

Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

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

I found new problems with the current version.

tests/xtimer_now_irq/main.c Outdated Show resolved Hide resolved
tests/xtimer_now_irq/main.c Outdated Show resolved Hide resolved
tests/xtimer_now_irq/main.c Outdated Show resolved Hide resolved
tests/xtimer_now_irq/tests/01-run.py Outdated Show resolved Hide resolved
tests/xtimer_now_irq/main.c Outdated Show resolved Hide resolved
@JulianHolzwarth
Copy link
Contributor Author

@aabadie @MichelRottleuthner
Thank you for your comments.
A pushed a new commit. What do you think now?

Copy link
Contributor

@MichelRottleuthner MichelRottleuthner left a comment

Choose a reason for hiding this comment

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

The "interpreting the XTIMER_MASK as usecs doesn't make sense" isn't addressed yet

tests/xtimer_now_irq/README.md Outdated Show resolved Hide resolved
tests/xtimer_now_irq/README.md Outdated Show resolved Hide resolved
@JulianHolzwarth
Copy link
Contributor Author

@MichelRottleuthner I changed the README last week. What do you think now?

@MichelRottleuthner
Copy link
Contributor

Apart from the INSUFFICIENT_MEMORY list in Makefile.ci I think this is good to go. @aabadie are all your requests addressed?

@MichelRottleuthner
Copy link
Contributor

@aabadie how bout now?

@MichelRottleuthner MichelRottleuthner added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Feb 25, 2020
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 26, 2020
@kaspar030
Copy link
Contributor

The pinetime errors are unrelated, fix for those is here: #13481

Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

As is, this will be run on the CI, but always timeout. CI jobs time out after 5 minutes.
I suggest to CI blacklist this test (until there's a board with a reasonable bit width for xtimer, e.g., at most 24).

@kaspar030 kaspar030 added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Feb 26, 2020
@kaspar030
Copy link
Contributor

This also needs some squashing.

while (count) {
unsigned int state = irq_disable();
uint32_t t1 = xtimer_now_usec();
xtimer_spin(xtimer_ticks((uint32_t)(~XTIMER_MASK) / 2));
Copy link
Contributor

@kaspar030 kaspar030 Feb 26, 2020

Choose a reason for hiding this comment

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

On 32bit 1mhz, this will spin (0xffffffff / 2) ticks. Doesn't that make the second iteration always fail?

  1. xtimer_now() is somewhere a little higher than zero, so is t1
  2. spin half period
  3. t2 is now somewhere a little higher than a half period
  4. next loop iteration, t1 is now close to t2 (a little higher than a half period)
  5. spin half period
  6. t2 32bit xtimer_now_usec() overflows ("a little higher than a half period" + "half period" > full period)
  7. t2 < t1, error triggers

What am I missing?

Copy link
Contributor

@MichelRottleuthner MichelRottleuthner Feb 26, 2020

Choose a reason for hiding this comment

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

Running it as is for 32 bit timer is madness anyway and we need a better way for testing these corner cases with a bit of mock magic.
Catching the "missed overflow" of the 32 bit timer with the 32 bit xtimer interface obviously doesn't make sense, the 64 bit variant is needed for that ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, how about straight passing if XTIMER_WIDTH == 32?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh just passing it would feel like lying. Why not just replace the uint32_t t1 = xtimer_now_usec(); etc. with the 64 bit variants? Then it works for 32 bit too.
Hmm I guess the problem is then we have no way to CI-run it for 16 bit timers and keep it working for manual 32 bit testing?.
How about an additional flag for manual running of 32 bit + some terminal output warning about 32 bit not being checked without that flag?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh just passing it would feel like lying. Why not just replace the uint32_t t1 = xtimer_now_usec(); etc. with the 64 bit variants? Then it works for 32 bit too.

yyyyyes, but isn't that testing something different then?

How about an additional flag for manual running of 32 bit + some terminal output warning about 32 bit not being checked without that flag?

As long as by default on 32bit on CI, this just prints "not testing anything" "OK", so CI just passes. Could also blacklist.

As is it shouldn't run at all, on 32bit, just so noone actually waits 2**32usec for something to happen. 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

yyyyyes, but isn't that testing something different then?

Didn't test yet, but no not really

As long as by default on 32bit on CI, this just prints "not testing anything" "OK", so CI just passes

I'd prefer some "not testing anything" "OK" over blacklisting.

just so noone actually waits 2**32usec

I definitely had cases when testing timer stuff that made me desperate enough too run such long running tests^^

@bergzand bergzand added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 26, 2020
@JulianHolzwarth
Copy link
Contributor Author

@MichelRottleuthner @kaspar030
Should the test only support <24 bits timer?

@JulianHolzwarth
Copy link
Contributor Author

JulianHolzwarth commented Feb 26, 2020

why is this automatically:

JulianHolzwarth requested review from fjmolinas, leandrolanzieri, miri64 and smlng as code owners

Because of TEST_ON_CI_BLACKLIST += all ?

@MichelRottleuthner
Copy link
Contributor

MichelRottleuthner commented Feb 26, 2020

Should the test only support <24 bits timer?

If anything then <= 24, but actually 32 bit would still be possible when using 64 bit API. In any case 32 Bit must be optional (i.e. only for manual testing). I'd also vote against blacklisting it for all boards - why not CI-run it for 16 and 24 bit?

why is this automatically:

take a look at https://github.com/RIOT-OS/RIOT/blob/master/CODEOWNERS

@JulianHolzwarth
Copy link
Contributor Author

JulianHolzwarth commented Feb 26, 2020

@MichelRottleuthner

If anything then <= 24, but actually 32 bit would still be possible when using 64 bit API. In any case 32 Bit must be optional (i.e. only for manual testing). I'd also vote against blacklisting it for all boards - why not CI-run it for 16 and 24 bit?

I thought @kaspar030 wanted it this way. (only <24 bit and blacklist all)

I suggest to CI blacklist this test

As is it shouldn't run at all, on 32bit, just so noone actually waits 2**32usec for something to happen. wink

Have i misunderstood something?

@JulianHolzwarth JulianHolzwarth force-pushed the pr/xtimer_test_overflow branch from dbbfdb7 to 7db72ee Compare March 5, 2020 16:37
@JulianHolzwarth
Copy link
Contributor Author

JulianHolzwarth commented Mar 5, 2020

@MichelRottleuthner @kaspar030 squashed and all comments addressed.

@MichelRottleuthner MichelRottleuthner added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 5, 2020
@MichelRottleuthner
Copy link
Contributor

ping @kaspar030 all good now?

This test checks, if the timer returns the correct time (xtimer_now_usec() is called), when interrupts are disabled. Specifically tested is if the time is correct after a low-level timer overflow.
@JulianHolzwarth JulianHolzwarth force-pushed the pr/xtimer_test_overflow branch from 7db72ee to 921d9cf Compare May 1, 2020 13:40
@JulianHolzwarth
Copy link
Contributor Author

new rebase (no changes)

@JulianHolzwarth
Copy link
Contributor Author

@kaspar030 Can we merge?

@MichelRottleuthner
Copy link
Contributor

@kaspar030 would you mind removing your block on this one? All your requests should be addressed.

@kaspar030 kaspar030 dismissed their stale review May 5, 2020 10:16

comments addressed

@kaspar030 kaspar030 merged commit d3e18c0 into RIOT-OS:master May 5, 2020
@miri64 miri64 added this to the Release 2020.07 milestone Jun 24, 2020
@JulianHolzwarth JulianHolzwarth deleted the pr/xtimer_test_overflow branch May 8, 2024 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: tests Area: tests and testing framework Area: timers Area: timer subsystems CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants