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/xtimer_usleep: improved test, added pin toggle #8865

Merged
merged 1 commit into from
Jun 4, 2018

Conversation

Josar
Copy link
Contributor

@Josar Josar commented Apr 2, 2018

Added ERROR_US 500 to emphasize when errors occur.
Added SLEEP_PIN and to probe sleep times at SLEEP_GPIO_PIN.

Atmega mcu will "hang" when the main ends, which will not matter here but should be addressed, imho.

@Josar Josar force-pushed the xtimer_usleep_improved branch 2 times, most recently from ec463fc to 6b3a559 Compare April 3, 2018 09:44
@kYc0o
Copy link
Contributor

kYc0o commented Apr 3, 2018

Can you explain more the purpose of this PR? I acknowledge for increasing the test cases, but I don't understand the need of the sleep pin.

@kYc0o kYc0o self-assigned this Apr 3, 2018
@kYc0o kYc0o added Area: tests Area: tests and testing framework Area: timers Area: timer subsystems labels Apr 3, 2018
@Josar
Copy link
Contributor Author

Josar commented Apr 3, 2018

You can use an oscilloscope to see if the timer runs as expected.
Or a seleae logic or other hardware, for hardware in the loop tests.

@kYc0o
Copy link
Contributor

kYc0o commented Apr 3, 2018

Well the line you removed // getchar(); is actually for that, it waits the test program to be launched to perform the checking through UART, so a pin is not needed and can be automatically tested. Have you checked the python script test under tests/?

@Josar
Copy link
Contributor Author

Josar commented Apr 3, 2018

Ok, so i run make BOARD=jiminy-mega256rfr2 flash test

Still i think measuring with a scope could come handy when debuging.

@kYc0o
Copy link
Contributor

kYc0o commented Apr 3, 2018

Ok, so i run make BOARD=jiminy-mega256rfr2 flash test

Yes, that's enough to run the test.

Still i think measuring with a scope could come handy when debuging.

Yes, however for the general use-case of the test it comes less handy, and even being optional, I think adding more code to the test may not help that much. However, if others have find it useful, I won't object.

@miri64 @kaspar030 do you have an opinion on this?

Copy link
Contributor

@kYc0o kYc0o left a comment

Choose a reason for hiding this comment

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

Several code and style errors found. I'll run murdock to see if it passes the compile tests.

and by providing capabilities to compare against an external timer.

The sleep times can be probed at a pin if SLEEP_PIN` is set to 1 and the respective
gpio pin is define as `SLEEP_GPIO_PIN`.
Copy link
Contributor

Choose a reason for hiding this comment

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

You missed a ` before SLEEP_PIN. You might give more hints on how to use it, e.g. add that it can be probed with an scope or something like that.

puts("Please hit any key and then ENTER to continue");
getchar();
puts("Please hit any key and then ENTER to continue\n");
// getchar();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please uncomment this line, it's needed for the automated test.


printf("Running test %u times with %u distinct sleep times\n", RUNS,
(unsigned)SLEEP_TIMES_NUMOF);
puts("Please hit any key and then ENTER to continue");
getchar();
puts("Please hit any key and then ENTER to continue\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

puts() doesn't need any \n. Please remove.

uint32_t diff, start;
start = xtimer_now_usec();

start_sleep = xtimer_now_usec();
Copy link
Contributor

Choose a reason for hiding this comment

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

Change the scope of your variables, they might be defined only in the context they're used.

}
}
testtime = xtimer_now_usec() - start_test;
printf("Test ran for %" PRIu32 " us\n", testtime);
printf("\nTest ran for %" PRIu32 " us\n", testtime);
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to add another \n.


/* atmega mcu will hang if main ends */
while(1){}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is another issue. This test is intended to run on any platform, and this is not needed.

}else{
printf("Slept for %" PRIu32 " us (expected: %" PRIu32 " us)\n",
diff, sleep_times[n]);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Your if - else statements are very off on spacing, please stick to coding conventions.


#define ERROR_US 500
Copy link
Contributor

Choose a reason for hiding this comment

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

Errors of more than 500 microseconds are way too big IMHO. xtimer_usleep() is used for very short periods of time. If your hardware doesn't support it, it must be blacklisted for this test (e.g. running a very low speed timer).

int32_t err;

#if SLEEP_PIN
gpio_init( SLEEP_GPIO_PIN, GPIO_OUT );
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the spaces after and before the parenthesis.

#if SLEEP_PIN
#include "board.h"
#include "periph/gpio.h"
#define SLEEP_GPIO_PIN GPIO_PIN(PORT_F, 7)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be surrounded by an #ifndef and the pin number should be passed from the outside (Makefile or command line) if you want to use it in this way. Hardcoded GPIO might lead to failures e.g. while flashing on certain devices. The default pin might be GPIO_UNDEF, but still I'm not convinced this is a generic way to perform a test like this.

@kYc0o kYc0o added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Apr 3, 2018
@Josar Josar force-pushed the xtimer_usleep_improved branch 2 times, most recently from 87cf471 to 3a65d23 Compare April 3, 2018 18:09
@miri64
Copy link
Member

miri64 commented Apr 3, 2018

@Josar please provide fixup commits until the review says it's you can squash, so it is easier to track your changes.

@miri64
Copy link
Member

miri64 commented Apr 3, 2018

Also, please specify in your commit message, what you did to the readme and how the tests were improved. A good style is to use an imperative style:

  • tests/xtimer_usleep: Update README to describe foo
  • tests/xtimer_usleep: Add test cases to consider bar

@Josar Josar force-pushed the xtimer_usleep_improved branch 9 times, most recently from 4a36c84 to 780f6a1 Compare April 3, 2018 23:25
@@ -24,16 +26,33 @@

#include "xtimer.h"
#include "timex.h"
#include "stdlib.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a standard header, so include <stdlib.h> and put above our headers.


diff = xtimer_now_usec() - start_sleep;

if(sleep_times[n] < diff - ERROR_US
Copy link
Contributor

Choose a reason for hiding this comment

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

this if needs some cleanup. parentheses, spaces, else on new line, ...

Copy link
Contributor

@kYc0o kYc0o 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 some more details.

Please look to the coding conventions to address Kaspar comments.

and the respective gpio `SLEEP_PORT` is defined in the makefile.

CFLAGS += SLEEP_PIN=7
CFLAGS += SLEEP_PORT=PORTF
Copy link
Contributor

Choose a reason for hiding this comment

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

The doc and the Makefile are not consistent on this.


## Usage
Executed from the project directory
```
make BOARD=<BoardName> flash test
Copy link
Contributor

Choose a reason for hiding this comment

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

Please avoid CamelCase.

```
### On Error with terminal
```

Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this empty?

@Josar Josar force-pushed the xtimer_usleep_improved branch 3 times, most recently from bdbc326 to c812f9c Compare April 5, 2018 16:20
@Josar
Copy link
Contributor Author

Josar commented Apr 12, 2018

@kaspar030 some further comments?

@Josar Josar force-pushed the xtimer_usleep_improved branch from c812f9c to 5417b7d Compare April 25, 2018 17:01
@Josar
Copy link
Contributor Author

Josar commented Apr 25, 2018

@kYc0o squashed and rebased. Also changed the port initialization. Could you please test it again. 😅
@kaspar030 could you have a second look and approve?

@Josar
Copy link
Contributor Author

Josar commented May 8, 2018

@kaspar030 any further thoughts?

Copy link
Contributor

@kYc0o kYc0o left a comment

Choose a reason for hiding this comment

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

Minor change to activate CI HIL tests.

#FEATURES_REQUIRED += periph_gpio
#CFLAGS += -DSLEEP_PIN=7
#CFLAGS += -DSLEEP_PORT=PORT_F

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add just here TEST_ON_CI_WHITELIST += all

@Josar
Copy link
Contributor Author

Josar commented May 14, 2018

@kYc0o @kaspar030 further requests?

@kYc0o kYc0o added CI: run tests If set, CI server will run tests on hardware for the labeled PR 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 May 14, 2018
@kYc0o
Copy link
Contributor

kYc0o commented May 14, 2018

Everything goof for me. HIL tests passed.

@Josar
Copy link
Contributor Author

Josar commented May 23, 2018

@kaspar030 any further requests?

@kYc0o
Copy link
Contributor

kYc0o commented May 29, 2018

@Josar apparently you need to rebase this one to solve the conflicts.

@Josar Josar force-pushed the xtimer_usleep_improved branch from 0a25273 to ffb8c27 Compare May 29, 2018 14:11
@kYc0o kYc0o 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 May 30, 2018
@kYc0o
Copy link
Contributor

kYc0o commented May 31, 2018

Great! It's green now. @kaspar030 can you confirm if your concerns were addressed to move on here?

@kYc0o
Copy link
Contributor

kYc0o commented May 31, 2018

@cladmi if you want to test it would be awesome!

@cladmi
Copy link
Contributor

cladmi commented Jun 1, 2018

Test run correctly on IoT-LAB nodes:

  • iotlab-m3: offset 14 us
  • iotlab-a8-m3: offset 14 us
  • wsn430-v1_3b: offset 135 us
  • arduino-zero (samd21 cpu): offset 50us
  • samr21-xpro: offset 44us

@kYc0o
Copy link
Contributor

kYc0o commented Jun 4, 2018

@kaspar030 can you check if your concerns were addressed? This PR has 2 ACKs and I think we can merge it ASAP.

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.

(untested) ACK.

@kaspar030 kaspar030 merged commit dbc70f3 into RIOT-OS:master Jun 4, 2018
@cladmi cladmi added this to the Release 2018.07 milestone Jul 10, 2018
@Josar Josar deleted the xtimer_usleep_improved branch July 10, 2018 13:07
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 CI: run tests If set, CI server will run tests on hardware for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants