示例#1
0
int main() {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(Semihost file system);
    MBED_HOSTTEST_START("MBED_A2");

    pc.printf("Test the Stream class\n");

    printf("connected: %s\n", (semihost_connected()) ? ("Yes") : ("No"));

    char mac[16];
    mbed_mac_address(mac);
    printf("mac address: %02x,%02x,%02x,%02x,%02x,%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

    LocalFileSystem local("local");

    FILE *f;
    char *str = TEST_STRING;
    char *buffer = (char *)malloc(sizeof(unsigned char) * strlen(TEST_STRING));
    int str_len = strlen(TEST_STRING);

    // Write
    f = test_open("w");
    test_write(f, str, str_len);
    test_close(f);

    // Read
    f = test_open("r");
    test_read(f, buffer, str_len);
    test_close(f);

    // Check the two strings are equal
    MBED_HOSTTEST_RESULT((strncmp(buffer, str, str_len) == 0));
}
示例#2
0
文件: main.cpp 项目: Babody/mbed
int main() {
    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(Interrupt vector relocation);
    MBED_HOSTTEST_START("MBED_A18");

    // First test, no table reallocation
    {
        printf("Starting first test (interrupts not relocated).\r\n");
        bool ret = test_once();
        if (ret == false) {
            MBED_HOSTTEST_RESULT(false);
        }
    }

    // Relocate interrupt table and test again
    {
        printf("Starting second test (interrupts relocated).\r\n");
        memcpy(int_table, (void*)SCB->VTOR, sizeof(int_table));
        SCB->VTOR = (uint32_t)int_table;

        bool ret = test_once();
        if (ret == false) {
            MBED_HOSTTEST_RESULT(false);
        }
    }

    MBED_HOSTTEST_RESULT(true);
}
示例#3
0
文件: main.cpp 项目: TemcoHeng/mbed
int main (void) {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(Mail messaging);
    MBED_HOSTTEST_START("RTOS_6");

    Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE);
    bool result = true;
    int result_counter = 0;

    while (true) {
        osEvent evt = mail_box.get();
        if (evt.status == osEventMail) {
            mail_t *mail = (mail_t*)evt.value.p;
            const float expected_voltage = CREATE_VOLTAGE(mail->counter);
            const float expected_current = CREATE_CURRENT(mail->counter);
            // Check using macros if received values correspond to values sent via queue
            bool expected_values = (expected_voltage == mail->voltage) &&
                                   (expected_current == mail->current);
            result = result && expected_values;
            const char *result_msg = expected_values ? "OK" : "FAIL";
            printf("%3d %.2fV %.2fA ... [%s]\r\n", mail->counter,
                                                   mail->voltage,
                                                   mail->current,
                                                   result_msg);
            mail_box.free(mail);
            if (result == false || ++result_counter == QUEUE_SIZE) {
                break;
            }
        }
    }
    MBED_HOSTTEST_RESULT(result);
    return 0;
}
示例#4
0
int main() {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(Basic);
    MBED_HOSTTEST_START("MBED_A1");
    MBED_HOSTTEST_RESULT(true);
}
void app_start(int argc, char *argv[])
{
    (void) argc;
    (void) argv;
    MBED_HOSTTEST_TIMEOUT(5);
    MBED_HOSTTEST_SELECT(default);
    MBED_HOSTTEST_DESCRIPTION(Socket Abstraction Layer construction and utility test);
    MBED_HOSTTEST_START("SAL_INIT_UTIL");

    int tests_pass = 1;
    int rc;
    EthernetInterface eth;
    /* Initialise with DHCP, connect, and start up the stack */
    eth.init();
    eth.connect();

    do {
        socket_error_t err = lwipv4_socket_init();
        if (!TEST_EQ(err,SOCKET_ERROR_NONE)) {
            tests_pass = 0;
            break;
        }
        rc = socket_api_test_create_destroy(SOCKET_STACK_LWIP_IPV4, SOCKET_AF_INET6);
        tests_pass = tests_pass && rc;

        rc = socket_api_test_socket_str2addr(SOCKET_STACK_LWIP_IPV4, SOCKET_AF_INET6);
        tests_pass = tests_pass && rc;

    } while (0);
    MBED_HOSTTEST_RESULT(tests_pass);
}
示例#6
0
文件: main.cpp 项目: 0-T-0/openthread
static void run() {
    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_SELECT(default);
    MBED_HOSTTEST_DESCRIPTION(mbed TLS example on hashing);
    MBED_HOSTTEST_START("MBEDTLS_EX_HASHING");
    MBED_HOSTTEST_RESULT(example() == 0);
}
示例#7
0
文件: main.cpp 项目: Archcady/mbed-os
int main() {
    Serial *pc = new Serial(USBTX, USBRX);

    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(serial_nc_tx_auto);
    MBED_HOSTTEST_DESCRIPTION(Serial NC TX);
    MBED_HOSTTEST_START("MBED_38");

    // Wait until we receive start signal from host test
    char c = pc->getc();
    delete pc;

    // If signal is correct, start the test
    if (c == 'S') {
      Serial *pc = new Serial(USBTX, NC);
      pc->printf("TX OK - Expected\r\n");
      wait(0.5);  // wait for characters to finish transmitting

      delete pc;

      pc = new Serial(NC, USBRX);
      pc->printf("TX OK - Unexpected\r\n");
      wait(0.5);  // wait for characters to finish transmitting
      delete pc;
    }

    while (1) {
    }
}
示例#8
0
文件: main.cpp 项目: suparit/gcc4mbed
int main() {
    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(SD FileHandle RW Speed);
    MBED_HOSTTEST_START("PERF_2");

    // Test header
    printf("\r\n");
    printf("SD Card FileHandle Performance Test\r\n");
    printf("File name: %s\r\n", bin_filename);
    printf("Buffer size: %d KiB\r\n", (KIB_RW * sizeof(buffer)) / 1024);

    // Initialize buffer
    srand(testenv_randseed());
    char *buffer_end = buffer + sizeof(buffer);
    std::generate (buffer, buffer_end, RandomChar);

    bool result = true;
    for (;;) {
        printf("Write test...\r\n");
        if (test_sf_file_write_fhandle(bin_filename, KIB_RW) == false) {
            result = false;
            break;
        }

        printf("Read test...\r\n");
        if (test_sf_file_read_fhandle(bin_filename, KIB_RW) == false) {
            result = false;
            break;
        }
        break;
    }
    MBED_HOSTTEST_RESULT(result);
}
示例#9
0
void app_start(int, char *[])
{
    MBED_HOSTTEST_TIMEOUT(60 * 61);
    MBED_HOSTTEST_SELECT(default);
    MBED_HOSTTEST_DESCRIPTION(Overflow test);
    MBED_HOSTTEST_START("Overflow");

    Calendar::setYear(2015);
    Calendar::setMonth(12);
    Calendar::setDate(31);

    Calendar::setHour(23);
    Calendar::setMinute(59);
    Calendar::setSecond(50);

    /* test unix time */
    unixtime = time(NULL);
    MBED_HOSTTEST_ASSERT(unixtime == 1451606390);

    /* schedule tasks */
    minar::Scheduler::postCallback(printTime)
        .period(minar::milliseconds(1000));

    minar::Scheduler::postCallback(endTime)
        .period(minar::milliseconds(60 * 60 * 1000));
}
示例#10
0
int main() {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(stdio_auto);
    MBED_HOSTTEST_DESCRIPTION(stdio);
    MBED_HOSTTEST_START("MBED_2");

    DigitalOut led1(LED1);
    DigitalOut led2(LED2);

    int value_int;
    

    notify_start(); // Just to sync with host test supervisor

    const char* PRINT_PATTERN = "MBED: Your value was: %d\r\n";

    while (true) {
        // SCANF PRINTF family
        value_int = 0;
        led1 = 1;
        scanf("%d", &value_int);
        printf(PRINT_PATTERN, value_int);
        led1 = 0;

        // FSCANF, FPRINTF family
        value_int = 0;
        led2 = 1;
        fscanf(stdin, "%d", &value_int);
        fprintf(stdout, PRINT_PATTERN, value_int);
        led2 = 0;
    }
}
示例#11
0
/* EXPECTED OUTPUT:
*******************
Static::init
Static::stack_test
Stack::init
Stack::hello
Stack::destroy
Static::check_init: OK
Heap::init
Heap::hello
Heap::destroy
*******************/
int main (void) {
    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(C++);
    MBED_HOSTTEST_START("MBED_12");

    bool result = true;
    for (;;)
    {
        // Global stack object simple test
        s.stack_test();
        if (s.check_init() == false)
        {
            result = false;
            break;
        }

        // Heap test object simple test
        Test *m = new Test("Heap");
        m->hello();

        if (m->check_init() == false)
        {
            result = false;
        }
        delete m;
        break;
    }

    MBED_HOSTTEST_RESULT(result);
}
示例#12
0
static void run() {
    MBED_HOSTTEST_TIMEOUT(40);
    MBED_HOSTTEST_SELECT(default);
    MBED_HOSTTEST_DESCRIPTION(mbed TLS selftest program);
    MBED_HOSTTEST_START("MBEDTLS_SELFTEST");
    MBED_HOSTTEST_RESULT(selftest(0, NULL) == 0);
}
示例#13
0
文件: main.cpp 项目: jurgis/mbed
int main() {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(PortInOut);
    MBED_HOSTTEST_START("MBED_A11");

    bool check = true;

    port1.output();
    port2.input();

    port1 = MASK_1; wait(0.1);
    if (port2 != MASK_2) check = false;

    port1 = 0; wait(0.1);
    if (port2 != 0) check = false;

    port1.input();
    port2.output();

    port2 = MASK_2; wait(0.1);
    if (port1 != MASK_1) check = false;

    port2 = 0; wait(0.1);
    if (port1 != 0) check = false;

    MBED_HOSTTEST_RESULT(check);
}
示例#14
0
int main (void) {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(udpecho_server_auto);
    MBED_HOSTTEST_DESCRIPTION(UDP echo server);
    MBED_HOSTTEST_START("NET_5");

    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    printf("MBED: Server IP Address is %s:%d\r\n", eth.getIPAddress(), ECHO_SERVER_PORT);

    UDPSocket server;
    server.bind(ECHO_SERVER_PORT);

    Endpoint client;
    char buffer[BUFFER_SIZE] = {0};
    printf("MBED: Waiting for packet...\r\n");
    while (true) {
        int n = server.receiveFrom(client, buffer, sizeof(buffer));
        if (n > 0) {
            //printf("Received packet from: %s\n", client.get_address());
            const int buffer_string_end_index = n >= BUFFER_SIZE ? BUFFER_SIZE-1 : n;
            buffer[buffer_string_end_index] = '\0';
            //printf("Server received: %s\n", buffer);
            server.sendTo(client, buffer, n);
        }
    }
}
示例#15
0
文件: main.cpp 项目: sg-/mbed-drivers
void app_start(int, char*[]) {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(Blinky);
    MBED_HOSTTEST_START("MBED_BLINKY");
    minar::Scheduler::postCallback(&blink).period(minar::milliseconds(200));
}
示例#16
0
文件: main.cpp 项目: Archcady/mbed-os
int main()
{
    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(SPI C12832 display);
    MBED_HOSTTEST_START("MBED_35");
    
    C12832 lcd(D11, D13, D12, D7, D10);

    // clear the screen
    lcd.cls();
    
    // print the first line and wait 3 sec
    lcd.locate(0,3);
    lcd.printf("mbed application board!");
    
    // print the counter prefix; the number will be printed in the while loop
    lcd.locate(0,15);
    lcd.printf("Counting:");

    int i=1, j=0;
    while(i++,i<=200) {
        lcd.locate(42,15);
        lcd.printf("%d", i);
        if (i % 50 == 0) {
            lcd.invert(j = j ? 0 : 1);
        };
        wait(0.001);
    }
    
    MBED_HOSTTEST_RESULT(1);
}
示例#17
0
文件: main.cpp 项目: Sweet-Peas/mbed
int main (void) {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(Semaphore resource lock);
    MBED_HOSTTEST_START("RTOS_3");

    const int t1_delay = THREAD_DELAY * 1;
    const int t2_delay = THREAD_DELAY * 2;
    const int t3_delay = THREAD_DELAY * 3;
    Thread t1(test_thread, (void *)t1_delay, osPriorityNormal, STACK_SIZE);
    Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
    Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);

    while (true) {
        if (change_counter >= SEM_CHANGES or sem_defect == true) {
            t1.terminate();
            t2.terminate();
            t3.terminate();
            break;
        }
    }

    fflush(stdout);
    MBED_HOSTTEST_RESULT(!sem_defect);
    return 0;
}
示例#18
0
文件: main.cpp 项目: TemcoHeng/mbed
int main (void) {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(ISR (Queue));
    MBED_HOSTTEST_START("RTOS_8");

    Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE);
    Ticker ticker;
    ticker.attach(queue_isr, 1.0);
    int isr_puts_counter = 0;
    bool result = true;

    while (true) {
        osEvent evt = queue.get();
        if (evt.status != osEventMessage) {
            printf("QUEUE_GET: Status(0x%02X) ... [FAIL]\r\n", evt.status);
            result = false;
            break;
        } else {
            printf("QUEUE_GET: Value(%u) ... [OK]\r\n", evt.value.v);
            if (evt.value.v == QUEUE_PUT_ISR_VALUE) {
                isr_puts_counter++;
            }
            if (isr_puts_counter >= QUEUE_SIZE) {
                break;
            }
        }
    }

    MBED_HOSTTEST_RESULT(result);
    return 0;
}
示例#19
0
文件: main.cpp 项目: Sweet-Peas/mbed
int main() {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default);
    MBED_HOSTTEST_DESCRIPTION(Mutex resource lock);
    MBED_HOSTTEST_START("RTOS_2");

    const int t1_delay = THREAD_DELAY * 1;
    const int t2_delay = THREAD_DELAY * 2;
    const int t3_delay = THREAD_DELAY * 3;
    Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
    Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);

    while (true) {
        // Thread 1 action
        Thread::wait(t1_delay);
        manipulate_protected_zone(t1_delay);
        if (change_counter >= SIGNALS_TO_EMIT or mutex_defect == true) {
            t2.terminate();
            t3.terminate();
            break;
        }
    }

    fflush(stdout);
    MBED_HOSTTEST_RESULT(!mutex_defect);
    return 0;
}
示例#20
0
void app_start(int, char*[]) {
    MBED_HOSTTEST_TIMEOUT(5);
    MBED_HOSTTEST_SELECT(hello_auto);
    MBED_HOSTTEST_DESCRIPTION(Hello World);
    MBED_HOSTTEST_START("MBED_10");

    minar::Scheduler::postCallback(&sayHello);
}
示例#21
0
文件: main.cpp 项目: SeppoTakalo/sal
void app_start(int, char**) {
    int rc;
    MBED_HOSTTEST_SELECT(default);
    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_DESCRIPTION(Test the socket stack registry);
    MBED_HOSTTEST_START("STACK_REGISTRY");
    rc = test_socket_stack_registry();
    MBED_HOSTTEST_RESULT(rc);
}
示例#22
0
int main() {
    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(HTTP client hello world);
    MBED_HOSTTEST_START("NET_7");

    char http_request_buffer[BUFFER_SIZE + 1] = {0};
    HTTPClient http;
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();

    //GET data
    {
        bool result = true;
        const char *url_hello_txt = "http://developer.mbed.org/media/uploads/donatien/hello.txt";
        printf("HTTP_GET: Trying to fetch page '%s'...\r\n", url_hello_txt);
        HTTPResult ret = http.get(url_hello_txt, http_request_buffer, BUFFER_SIZE);
        if (ret == HTTP_OK) {
            printf("HTTP_GET: Read %d chars: '%s' ... [OK]\r\n", strlen(http_request_buffer), http_request_buffer);
        } else {
            printf("HTTP_GET: Error(%d). HTTP error(%d) ... [FAIL]\r\n", ret, http.getHTTPResponseCode());
            result = false;
        }

        if (result == false) {
            eth.disconnect();
            MBED_HOSTTEST_RESULT(false);
        }
    }

    //POST data
    {
        bool result = true;
        const char *url_httpbin_post = "http://httpbin.org/post";
        HTTPText text(http_request_buffer, BUFFER_SIZE);
        HTTPMap map;
        map.put("Hello", "World");
        map.put("test", "1234");
        printf("HTTP_POST: Trying to post data to '%s' ...\r\n", url_httpbin_post);
        HTTPResult ret = http.post(url_httpbin_post, map, &text);
        if (ret == HTTP_OK) {
            printf("HTTP_POST: Read %d chars ... [OK]\r\n", strlen(http_request_buffer));
            printf("HTTP_POST: %s\r\n", http_request_buffer);
        } else {
            printf("HTTP_GET: Error(%d). HTTP error(%d) ... [FAIL]\r\n", ret, http.getHTTPResponseCode());
            result = false;
        }

        if (result == false) {
            eth.disconnect();
            MBED_HOSTTEST_RESULT(false);
        }
    }
    eth.disconnect();
    MBED_HOSTTEST_RESULT(true);
}
示例#23
0
void app_start(int, char*[])
{
    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(wait_us_auto);
    MBED_HOSTTEST_DESCRIPTION(Ticker Int us);
    MBED_HOSTTEST_START("MBED_23");

    tick.attach_us(togglePin, 1000);
}
示例#24
0
void app_start(int, char*[]) {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(echo);
    MBED_HOSTTEST_DESCRIPTION(serial interrupt test);
    MBED_HOSTTEST_START("MBED_14");
    computer.baud(115200);
    computer.attach(&txCallback, Serial::TxIrq);
    computer.attach(&rxCallback, Serial::RxIrq);
}
示例#25
0
static void run() {
    /* Use 115200 bps for consistency with other examples */
    Serial pc(USBTX, USBRX);
    pc.baud(115200);

    MBED_HOSTTEST_TIMEOUT(40);
    MBED_HOSTTEST_SELECT(default);
    MBED_HOSTTEST_DESCRIPTION(mbed TLS selftest program);
    MBED_HOSTTEST_START("MBEDTLS_SELFTEST");
    MBED_HOSTTEST_RESULT(selftest(0, NULL) == 0);
}
示例#26
0
void runTest() {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(dev_null_auto);
    MBED_HOSTTEST_DESCRIPTION(stdout redirected to dev null);
    MBED_HOSTTEST_START("EXAMPLE_1");
    
    printf("MBED: re-routing stdout to /null\r\n");
    freopen("/null", "w", stdout);
    printf("MBED: printf redirected to /null\r\n");   // This shouldn't appear
    // If failure message can be seen test should fail :)
    MBED_HOSTTEST_RESULT(false);   // This is 'false' on purpose
}
示例#27
0
void app_start(int, char*[]) {
    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(Sleep Timeout);
    MBED_HOSTTEST_START("MBED_9");
    led1 = 0;
    led2 = 0;
    led1_initial = led1;
    led2_initial = led2;
    to1.attach_us(led1_on, 1000000);
    to2.attach_us(led2_on, 2000000);
}
示例#28
0
int main() {
    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_SELECT(detect_auto);
    MBED_HOSTTEST_DESCRIPTION(Simple detect test);
    MBED_HOSTTEST_START("DTCT_1");

    notify_start();
    printf("MBED: Target '%s'\r\n", TEST_SUITE_TARGET_NAME);
    printf("MBED: Test ID '%s'\r\n", TEST_SUITE_TEST_ID);
    printf("MBED: UUID '%s'\r\n", TEST_SUITE_UUID);
    MBED_HOSTTEST_RESULT(true);
}
示例#29
0
文件: main.cpp 项目: TemcoHeng/mbed
int main() {
    MBED_HOSTTEST_TIMEOUT(15);
    MBED_HOSTTEST_SELECT(wait_us_auto);
    MBED_HOSTTEST_DESCRIPTION(Basic thread);
    MBED_HOSTTEST_START("RTOS_1");

    Thread thread(led2_thread, NULL, osPriorityNormal, STACK_SIZE);

    while (true) {
        led1 = !led1;
        Thread::wait(500);
    }
}
示例#30
0
int main() {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(default_auto);
    MBED_HOSTTEST_DESCRIPTION(SD File write read);
    MBED_HOSTTEST_START("RTOS_9");

    Thread t(sd_thread, NULL, osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25));

    while (true) {
        led2 = !led2;
        Thread::wait(1000);
    }
}