mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
* added project "test_suite" as container for automatic tests. Added test_mutex_trylock_fail as first example
This commit is contained in:
parent
fa12fbf167
commit
1a6ea56b8b
@ -1,5 +0,0 @@
|
||||
SubDir TOP projects test_mutex_trylock_fail ;
|
||||
|
||||
Module test_mutex_trylock_fail : main.c ;
|
||||
|
||||
UseModule test_mutex_trylock_fail ;
|
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 5
|
||||
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
expect {
|
||||
"main: mutex unlocked." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
puts "\nTest successful!\n"
|
||||
|
12
projects/test_suite/Jamfile
Normal file
12
projects/test_suite/Jamfile
Normal file
@ -0,0 +1,12 @@
|
||||
#
|
||||
# Copyright (C) 2008, 2009, 2010 FU Berlin
|
||||
#
|
||||
# Author: Kaspar Schleiser <kaspar.schleiser@fu-berlin.de>
|
||||
#
|
||||
|
||||
SubDir TOP projects test_suite ;
|
||||
|
||||
Module test_suite : test_suite.c mutex_trylock_fail.c
|
||||
: shell posix_io ps uart0 ;
|
||||
|
||||
UseModule test_suite ;
|
@ -14,15 +14,15 @@ void second_thread(void) {
|
||||
}
|
||||
|
||||
tcb second_tcb;
|
||||
char second_stack[8192];
|
||||
char second_stack[KERNEL_CONF_STACKSIZE_MAIN];
|
||||
|
||||
int main(void)
|
||||
void mutex_trylock_fail(char* cmdline)
|
||||
{
|
||||
puts("main: locking mutex...");
|
||||
mutex_lock(&mutex);
|
||||
|
||||
puts("main: creating thread...");
|
||||
int pid = thread_create(&second_tcb, second_stack, 8192, PRIORITY_MAIN-1, CREATE_STACKTEST, second_thread, "nr2");
|
||||
int pid = thread_create(&second_tcb, second_stack, KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN-1, CREATE_STACKTEST, second_thread, "nr2");
|
||||
|
||||
puts("main: thread created. Unlocking mutex...");
|
||||
mutex_unlock(&mutex, true);
|
58
projects/test_suite/test_suite.c
Normal file
58
projects/test_suite/test_suite.c
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2008, 2009, 2010 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include <posix_io.h>
|
||||
#include <shell.h>
|
||||
#include <board_uart0.h>
|
||||
|
||||
void print_teststart(char* str) {
|
||||
printf("[TEST_START]\n");
|
||||
}
|
||||
|
||||
void print_testend(char* str) {
|
||||
printf("[TEST_END]\n");
|
||||
}
|
||||
|
||||
int shell_readc() {
|
||||
char c = 0;
|
||||
posix_read(uart0_handler_pid, &c, 1);
|
||||
return c;
|
||||
}
|
||||
|
||||
void shell_putchar(int c) {
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
void mutex_trylock_fail(char* cmdline);
|
||||
|
||||
const shell_command_t shell_commands[] = {
|
||||
{"start_test", print_teststart},
|
||||
{"end_test", print_testend},
|
||||
{"mutex_trylock_fail", mutex_trylock_fail},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
//printf("Moin. build on %s %s SVN-Revision: %s\n", kernel_builddate, kernel_buildtime, kernel_svnrevision);
|
||||
printf("test_shell.\n");
|
||||
|
||||
board_uart0_init();
|
||||
|
||||
posix_open(uart0_handler_pid, 0);
|
||||
|
||||
shell_t shell;
|
||||
shell_init(&shell, shell_readc, shell_putchar);
|
||||
|
||||
shell.command_list = shell_commands;
|
||||
|
||||
shell_run(&shell);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
30
projects/test_suite/tests/01-basic
Executable file
30
projects/test_suite/tests/01-basic
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 5
|
||||
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
expect {
|
||||
">$" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "start_test\n"
|
||||
expect {
|
||||
"\[TEST_START\]" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
expect {
|
||||
">$" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "end_test\n"
|
||||
|
||||
expect {
|
||||
"\[TEST_END\]" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
puts "\nTest successful!\n"
|
81
projects/test_suite/tests/02-inputlength-regression
Executable file
81
projects/test_suite/tests/02-inputlength-regression
Executable file
@ -0,0 +1,81 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 1
|
||||
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
sleep 1
|
||||
|
||||
expect {
|
||||
">$" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "123456789012345678901234567890123456789012345678901234567890\n"
|
||||
expect {
|
||||
"shell: command not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "123456789012345678901234567890123456789012345678901234567890\n"
|
||||
expect {
|
||||
"shell: command not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "123456789012345678901234567890123456789012345678901234567890\n"
|
||||
expect {
|
||||
"shell: command not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "123456789012345678901234567890123456789012345678901234567890\n"
|
||||
expect {
|
||||
"shell: command not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "123456789012345678901234567890123456789012345678901234567890\n"
|
||||
expect {
|
||||
"shell: command not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "123456789012345678901234567890123456789012345678901234567890\n"
|
||||
expect {
|
||||
"shell: command not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "123456789012345678901234567890123456789012345678901234567890\n"
|
||||
expect {
|
||||
"shell: command not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "123456789012345678901234567890123456789012345678901234567890\n"
|
||||
expect {
|
||||
"shell: command not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
|
||||
send "start_test\n"
|
||||
expect {
|
||||
"\[TEST_START\]" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
expect {
|
||||
">$" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "end_test\n"
|
||||
|
||||
expect {
|
||||
"\[TEST_END\]" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
puts "\nTest successful!\n"
|
20
projects/test_suite/tests/02-unknown-command
Executable file
20
projects/test_suite/tests/02-unknown-command
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 2
|
||||
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
sleep 1
|
||||
|
||||
expect {
|
||||
">$" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "some_definately_unknown_command\n"
|
||||
expect {
|
||||
"shell: command "some_definately_unknown_command" not found." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
puts "\nTest successful!\n"
|
56
projects/test_suite/tests/03-mutex_trylock_fail
Executable file
56
projects/test_suite/tests/03-mutex_trylock_fail
Executable file
@ -0,0 +1,56 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 5
|
||||
|
||||
spawn pseudoterm $env(PORT)
|
||||
|
||||
expect {
|
||||
">$" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "start_test\n"
|
||||
expect {
|
||||
"\[TEST_START\]" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
expect {
|
||||
">$" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "mutex_trylock_fail\n"
|
||||
expect {
|
||||
"main: locking mutex..." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
expect {
|
||||
"main: creating thread..." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
expect {
|
||||
"2nd: trying to lock mutex..." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
expect {
|
||||
"2nd: done." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
expect {
|
||||
"main: thread created. Unlocking mutex..." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
expect {
|
||||
"main: mutex unlocked." {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
send "end_test\n"
|
||||
|
||||
expect {
|
||||
"\[TEST_END\]" {}
|
||||
timeout { exit 1 }
|
||||
}
|
||||
|
||||
puts "\nTest successful!\n"
|
Loading…
Reference in New Issue
Block a user