tests: provide tests for trace module

This commit is contained in:
Martine Lenders 2017-06-16 13:32:53 +02:00 committed by Martine Lenders
parent 875a5c165d
commit 87d45c1719
3 changed files with 70 additions and 0 deletions

14
tests/trace/Makefile Normal file
View File

@ -0,0 +1,14 @@
# name of your application
APPLICATION = trace
include ../Makefile.tests_common
USEMODULE += trace
BOARD_WHITELIST := native
include $(RIOTBASE)/Makefile.include
test:
# `testrunner` calls `make term` recursively, results in duplicated `TERMFLAGS`.
# So clears `TERMFLAGS` before run.
TERMFLAGS= tests/01-run.py

30
tests/trace/main.c Normal file
View File

@ -0,0 +1,30 @@
/*
* Copyright (C) 2016 Freie Universität Berlin
*
* 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 Tests od module.
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#include "trace.h"
int main(void)
{
printf("TRACE_SIZE: %u\n", TRACE_SIZE);
trace_print();
return 0;
}

26
tests/trace/tests/01-run.py Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env python3
# Copyright (C) 2016 Freie Universität Berlin
#
# 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
def testfunc(child):
child.expect(r"TRACE_SIZE: (\d+)")
trace_size = int(child.match.group(1))
for i in range(trace_size):
child.expect("0x[0-9a-f]{7,8}")
print("All tests successful")
if __name__ == "__main__":
sys.path.append(os.path.join(os.environ['RIOTBASE'],
'dist/tools/testrunner'))
import testrunner
sys.exit(testrunner.run(testfunc, timeout=1, echo=True, traceback=True))