1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests: add small values test for xtimer_usleep

This commit is contained in:
MichelRottleuthner 2017-07-11 10:37:34 +02:00
parent 39c6051090
commit 2390ea87d8
3 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,8 @@
include ../Makefile.tests_common
USEMODULE += xtimer
include $(RIOTBASE)/Makefile.include
test:
./tests/01-run.py

View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2017 HAW-Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief xtimer_usleep_short test application
*
* @author Michel Rottleuthner <michel.rottleuthner@haw-hamburg.de>
* @}
*/
#include <stdio.h>
#include "xtimer.h"
#define TEST_USLEEP_MIN (0)
#define TEST_USLEEP_MAX (500)
int main(void)
{
xtimer_sleep(3);
printf("This test will call xtimer_usleep for values from %d down to %d\n",
TEST_USLEEP_MAX, TEST_USLEEP_MIN);
for (int i = TEST_USLEEP_MAX; i >= TEST_USLEEP_MIN; i--) {
printf("going to sleep %d usecs...\n", i);
xtimer_usleep(i);
}
puts("Test end.");
return 0;
}

View File

@ -0,0 +1,34 @@
#!/usr/bin/env python
# Copyright (C) 2017 Michel Rottleuthner <michel.rottleuthner@haw-hamburg.de>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
import os
import sys
import pexpect
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
import testrunner
def testfunc(child):
child.expect(u"This test will call xtimer_usleep for values from \\d+ down to \\d+\r\n")
i = 500
while (i >= 0):
try:
child.expect(u"going to sleep \\d+ usecs...\r\n", timeout=3)
except pexpect.TIMEOUT:
print("xtimer stuck when trying to sleep %d usecs" % (i+1));
print("[FAILED]")
break;
i = i -1
child.expect(u"Test end.", timeout=3)
if __name__ == "__main__":
sys.exit(testrunner.run(testfunc))