mirror of https://github.com/ARMmbed/mbed-os.git
Added EXAMPLE_1 /dev/null redirection host test to automation suite
parent
04b488dcc4
commit
602a4ed8eb
|
@ -1,9 +1,10 @@
|
|||
#include "mbed.h"
|
||||
#include "test_env.h"
|
||||
|
||||
class DevNull : public Stream {
|
||||
|
||||
public:
|
||||
DevNull(const char *name=NULL) : Stream(name) {}
|
||||
DevNull(const char *name = NULL) : Stream(name) {}
|
||||
|
||||
protected:
|
||||
virtual int _getc() {return 0;}
|
||||
|
@ -13,14 +14,10 @@ protected:
|
|||
DevNull null("null");
|
||||
|
||||
int main() {
|
||||
printf("re-routing stdout to /null\n");
|
||||
|
||||
printf("MBED: re-routing stdout to /null\n");
|
||||
freopen("/null", "w", stdout);
|
||||
printf("printf redirected to /null\n");
|
||||
|
||||
DigitalOut led(LED1);
|
||||
while (true) {
|
||||
led = !led;
|
||||
wait(1);
|
||||
}
|
||||
printf("MBED: printf redirected to /null\n"); // This shouldn't appear
|
||||
// If failure message can be seen test should fail :)
|
||||
notify_completion(false); // This is 'false' on purpose
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2011-2013 ARM Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from host_test import Test, DefaultTest
|
||||
from sys import stdout
|
||||
|
||||
class DevNullTest(DefaultTest):
|
||||
|
||||
def print_result(self, result):
|
||||
print "\n{%s}\n{end}" % result
|
||||
|
||||
def run(self):
|
||||
test_result = True
|
||||
c = self.mbed.serial.read(512)
|
||||
print "Received %d bytes" % len(c)
|
||||
if "{failure}" not in c:
|
||||
self.print_result('success')
|
||||
else:
|
||||
self.print_result('failure')
|
||||
stdout.flush()
|
||||
|
||||
if __name__ == '__main__':
|
||||
DevNullTest().run()
|
|
@ -767,7 +767,9 @@ TESTS = [
|
|||
{
|
||||
"id": "EXAMPLE_1", "description": "/dev/null",
|
||||
"source_dir": join(TEST_DIR, "mbed", "dev_null"),
|
||||
"dependencies": [MBED_LIBRARIES],
|
||||
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
|
||||
"automated": True,
|
||||
"host_test" : "dev_null_auto",
|
||||
},
|
||||
{
|
||||
"id": "EXAMPLE_2", "description": "FS + RTOS",
|
||||
|
|
Loading…
Reference in New Issue