Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:27:58 2016 +0000
Revision:
0:6c56fb4bc5f0
Moving to library for sharing updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 0:6c56fb4bc5f0 1 #include "mbed.h"
nexpaq 0:6c56fb4bc5f0 2 #include "test_env.h"
nexpaq 0:6c56fb4bc5f0 3
nexpaq 0:6c56fb4bc5f0 4 class DevNull : public Stream {
nexpaq 0:6c56fb4bc5f0 5 public:
nexpaq 0:6c56fb4bc5f0 6 DevNull(const char *name = NULL) : Stream(name) {}
nexpaq 0:6c56fb4bc5f0 7
nexpaq 0:6c56fb4bc5f0 8 protected:
nexpaq 0:6c56fb4bc5f0 9 virtual int _getc() {
nexpaq 0:6c56fb4bc5f0 10 return 0;
nexpaq 0:6c56fb4bc5f0 11 }
nexpaq 0:6c56fb4bc5f0 12 virtual int _putc(int c) {
nexpaq 0:6c56fb4bc5f0 13 return c;
nexpaq 0:6c56fb4bc5f0 14 }
nexpaq 0:6c56fb4bc5f0 15 };
nexpaq 0:6c56fb4bc5f0 16
nexpaq 0:6c56fb4bc5f0 17 DevNull null("null");
nexpaq 0:6c56fb4bc5f0 18
nexpaq 0:6c56fb4bc5f0 19 int main() {
nexpaq 0:6c56fb4bc5f0 20 MBED_HOSTTEST_TIMEOUT(20);
nexpaq 0:6c56fb4bc5f0 21 MBED_HOSTTEST_SELECT(dev_null_auto);
nexpaq 0:6c56fb4bc5f0 22 MBED_HOSTTEST_DESCRIPTION(stdout redirected to dev null);
nexpaq 0:6c56fb4bc5f0 23 MBED_HOSTTEST_START("EXAMPLE_1");
nexpaq 0:6c56fb4bc5f0 24
nexpaq 0:6c56fb4bc5f0 25 printf("MBED: re-routing stdout to /null\r\n");
nexpaq 0:6c56fb4bc5f0 26 freopen("/null", "w", stdout);
nexpaq 0:6c56fb4bc5f0 27 printf("MBED: printf redirected to /null\r\n"); // This shouldn't appear
nexpaq 0:6c56fb4bc5f0 28 // If failure message can be seen test should fail :)
nexpaq 0:6c56fb4bc5f0 29 MBED_HOSTTEST_RESULT(false); // This is 'false' on purpose
nexpaq 0:6c56fb4bc5f0 30 }